From do-not-reply at jboss.org Tue Sep 14 20:39:31 2010 Content-Type: multipart/mixed; boundary="===============0069671737339826374==" MIME-Version: 1.0 From: do-not-reply at jboss.org To: hornetq-commits at lists.jboss.org Subject: [hornetq-commits] JBoss hornetq SVN: r9688 - trunk/tests/src/org/hornetq/tests/soak/client. Date: Tue, 14 Sep 2010 20:39:31 -0400 Message-ID: <201009150039.o8F0dVga015994@svn01.web.mwc.hst.phx2.redhat.com> --===============0069671737339826374== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: clebert.suconic(a)jboss.com Date: 2010-09-14 20:39:30 -0400 (Tue, 14 Sep 2010) New Revision: 9688 Added: trunk/tests/src/org/hornetq/tests/soak/client/ClientNonDivertedSoakTest.= java Log: Adding new test (without diverts) Added: trunk/tests/src/org/hornetq/tests/soak/client/ClientNonDivertedSoakT= est.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/tests/src/org/hornetq/tests/soak/client/ClientNonDivertedSoakTest= .java (rev 0) +++ trunk/tests/src/org/hornetq/tests/soak/client/ClientNonDivertedSoakTest= .java 2010-09-15 00:39:30 UTC (rev 9688) @@ -0,0 +1,157 @@ +/* + * Copyright 2010 Red Hat, Inc. + * Red Hat licenses this file to you under the Apache License, version + * 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package org.hornetq.tests.soak.client; + +import java.util.HashMap; +import java.util.concurrent.TimeUnit; + +import org.hornetq.api.core.SimpleString; +import org.hornetq.api.core.client.ClientMessage; +import org.hornetq.api.core.client.ClientProducer; +import org.hornetq.api.core.client.ClientSession; +import org.hornetq.api.core.client.ClientSessionFactory; +import org.hornetq.core.config.Configuration; +import org.hornetq.core.server.HornetQServer; +import org.hornetq.core.settings.impl.AddressSettings; +import org.hornetq.tests.util.ServiceTestBase; + +/** + * A ClientSoakTest + * + * @author Clebert Suconic<= /a> + * + * + */ +public class ClientNonDivertedSoakTest extends ServiceTestBase +{ + + // Constants ----------------------------------------------------- + + // Attributes ---------------------------------------------------- + + private static final SimpleString ADDRESS =3D new SimpleString("ADD"); + + private static final boolean IS_NETTY =3D false; + + private static final boolean IS_JOURNAL =3D false; + + public static final int MIN_MESSAGES_ON_QUEUE =3D 5000; + + // Static -------------------------------------------------------- + + // Constructors -------------------------------------------------- + + // Public -------------------------------------------------------- + + private HornetQServer server; + + @Override + protected void setUp() throws Exception + { + clearData(); + + Configuration config =3D createDefaultConfig(ClientNonDivertedSoakTe= st.IS_NETTY); + + config.setJournalFileSize(10 * 1024 * 1024); + + server =3D createServer(IS_JOURNAL, config, -1, -1, new HashMap()); + + server.start(); + + ClientSessionFactory sf =3D createFactory(ClientNonDivertedSoakTest.= IS_NETTY); + + ClientSession session =3D sf.createSession(); + + session.createQueue(ClientNonDivertedSoakTest.ADDRESS, ClientNonDive= rtedSoakTest.ADDRESS, true); + + session.close(); + + sf.close(); + + } + + @Override + protected void tearDown() throws Exception + { + server.stop(); + server =3D null; + } + + public void testSoakClient() throws Exception + { + final ClientSessionFactory sf =3D createFactory(IS_NETTY); + + ClientSession session =3D sf.createSession(false, false); + + ClientProducer producer =3D session.createProducer(ADDRESS); + + for (int i =3D 0; i < MIN_MESSAGES_ON_QUEUE; i++) + { + ClientMessage msg =3D session.createMessage(true); + msg.putLongProperty("count", i); + msg.getBodyBuffer().writeBytes(new byte[10 * 1024]); + producer.send(msg); + + if (i % 1000 =3D=3D 0) + { + System.out.println("Sent " + i + " messages"); + session.commit(); + } + } + + session.commit(); + + session.close(); + sf.close(); + + Receiver rec1 =3D new Receiver(createFactory(IS_NETTY), ADDRESS.toSt= ring()); + + Sender send =3D new Sender(createFactory(IS_NETTY), ADDRESS.toString= (), new Receiver[] { rec1 }); + + send.start(); + rec1.start(); + + long timeEnd =3D System.currentTimeMillis() + TimeUnit.HOURS.toMilli= s(1); + while (timeEnd > System.currentTimeMillis()) + { + if (send.getErrorsCount() !=3D 0 || rec1.getErrorsCount() !=3D 0 ) + { + System.out.println("There are sequence errors in some of the c= lients, please look at the logs"); + break; + } + = + System.out.println("count =3D " + send.msgs); + Thread.sleep(10000); + } + + send.setRunning(false); + rec1.setRunning(false); + + send.join(); + rec1.join(); + + assertEquals(0, send.getErrorsCount()); + assertEquals(0, rec1.getErrorsCount()); + + } + + // Package protected --------------------------------------------- + + // Protected ----------------------------------------------------- + + // Private ------------------------------------------------------- + + // Inner classes ------------------------------------------------- + +} --===============0069671737339826374==--