summaryrefslogtreecommitdiff
path: root/java/integrationtests/src/main/java/org/apache/qpid/sustained/SustainedTestCase.java
blob: 0077b4727a6e8824624a072c7860a42817b586f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF 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.apache.qpid.sustained;

import org.apache.log4j.Logger;

import org.apache.qpid.client.AMQSession;
import org.apache.qpid.test.framework.DropInTest;
import org.apache.qpid.test.framework.FrameworkBaseCase;

import javax.jms.JMSException;
import javax.jms.Message;

import java.util.Properties;

/**
 * SustainedTestCase is a {@link FrameworkBaseCase} that runs the "Perf_SustainedPubSub" test case. This consists of one
 * test client sending, and several receiving, and attempts to find the highest rate at which messages can be broadcast
 * to the receivers. It is also a {@link DropInTest} to which more test clients may be added during a test run.
 *
 * <p/><table id="crc"><caption>CRC Card</caption>
 * <tr><th> Responsibilities <th> Collaborations
 * <tr><td>
 * </table>
 */
public class SustainedTestCase extends FrameworkBaseCase implements DropInTest
{
    /** Used for debugging. */
    Logger log = Logger.getLogger(SustainedTestCase.class);

    /** Holds the root name of the topic on which to send the test messages. */
    private static final String SUSTAINED_KEY = "Perf_SustainedPubSub";

    /**
     * Creates a new coordinating test case with the specified name.
     *
     * @param name The test case name.
     */
    public SustainedTestCase(String name)
    {
        super(name);
    }

    /**
     * Performs a single test run of the sustained test.
     *
     * @throws Exception Any exceptions are allowed to fall through and fail the test.
     */
    public void testBasicPubSub() throws Exception
    {
        log.debug("public void testSinglePubSubCycle(): called");

        Properties testConfig = new Properties();
        testConfig.put("TEST_NAME", "Perf_SustainedPubSub");
        testConfig.put("SUSTAINED_KEY", SUSTAINED_KEY);
        testConfig.put("SUSTAINED_NUM_RECEIVERS", Integer.getInteger("numReceives", 2));
        testConfig.put("SUSTAINED_UPDATE_INTERVAL", Integer.getInteger("batchSize", 1000));
        testConfig.put("SUSTAINED_UPDATE_KEY", SUSTAINED_KEY + ".UPDATE");
        testConfig.put("ACKNOWLEDGE_MODE", Integer.getInteger("ackMode", AMQSession.AUTO_ACKNOWLEDGE));

        log.info("Created Config: " + testConfig.entrySet().toArray());

        getCircuitFactory().sequenceTest(null, null, testConfig);
    }

    /**
     * Accepts a late joining client into this test case. The client will be enlisted with a control message
     * with the 'CONTROL_TYPE' field set to the value 'LATEJOIN'. It should also provide values for the fields:
     *
     * <p/><table>
     * <tr><td> CLIENT_NAME <td> A unique name for the new client.
     * <tr><td> CLIENT_PRIVATE_CONTROL_KEY <td> The key for the route on which the client receives its control messages.
     * </table>
     *
     * @param message The late joiners join message.
     *
     * @throws JMSException Any JMS Exception are allowed to fall through, indicating that the join failed.
     */
    public void lateJoin(Message message) throws JMSException
    {
        throw new RuntimeException("Not implemented.");
        /*
        // Extract the joining clients details from its join request message.
        TestClientDetails clientDetails = new TestClientDetails();
        clientDetails.clientName = message.getStringProperty("CLIENT_NAME");
        clientDetails.privateControlKey = message.getStringProperty("CLIENT_PRIVATE_CONTROL_KEY");

        // Register the joining client, but do block for confirmation as cannot do a synchronous receivers during this
        // method call, as it may have been called from an 'onMessage' method.
        assignReceiverRole(clientDetails, new Properties(), false);
         */
    }

    /**
     * Should provide a translation from the junit method name of a test to its test case name as known to the test
     * clients that will run the test. The purpose of this is to convert the JUnit method name into the correct test
     * case name to place into the test invite. For example the method "testP2P" might map onto the interop test case
     * name "TC2_BasicP2P".
     *
     * @param methodName The name of the JUnit test method.
     *
     * @return The name of the corresponding interop test case.
     */
    public String getTestCaseNameForTestMethod(String methodName)
    {
        return "Perf_SustainedPubSub";
    }
}