From e8b197315437cac84872752e2ea090d8fb233941 Mon Sep 17 00:00:00 2001 From: Parshad Patel Date: Tue, 20 Nov 2018 14:46:45 +0900 Subject: Rename test classes in apex-pdp Make test classes name consistence under auth, model, plugins, testsuits, tools projects Issue-ID: POLICY-1263 Change-Id: I49ec9a9f5b457d6381e693de2c04ec0268ad1b02 Signed-off-by: Parshad Patel --- .../engine/benchmark/ApexEngineBenchmark.java | 183 --------------------- .../engine/benchmark/ApexEngineBenchmarkTest.java | 183 +++++++++++++++++++++ .../engine/benchmark/ApexEventListenerTest.java | 126 ++++++++++++++ .../engine/benchmark/TestApexEventListener.java | 126 -------------- .../performance/context/metrics/MetricsTest.java | 94 +++++++++++ .../performance/context/metrics/TestMetrics.java | 94 ----------- 6 files changed, 403 insertions(+), 403 deletions(-) delete mode 100644 testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/engine/benchmark/ApexEngineBenchmark.java create mode 100644 testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/engine/benchmark/ApexEngineBenchmarkTest.java create mode 100644 testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/engine/benchmark/ApexEventListenerTest.java delete mode 100644 testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/engine/benchmark/TestApexEventListener.java create mode 100644 testsuites/performance/performance-context-metrics/src/test/java/org/onap/policy/apex/testsuites/performance/context/metrics/MetricsTest.java delete mode 100644 testsuites/performance/performance-context-metrics/src/test/java/org/onap/policy/apex/testsuites/performance/context/metrics/TestMetrics.java (limited to 'testsuites/performance') diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/engine/benchmark/ApexEngineBenchmark.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/engine/benchmark/ApexEngineBenchmark.java deleted file mode 100644 index fa2a9934c..000000000 --- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/engine/benchmark/ApexEngineBenchmark.java +++ /dev/null @@ -1,183 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.testsuites.performance.benchmark.engine.benchmark; - -import static org.junit.Assert.assertEquals; - -import java.util.concurrent.TimeUnit; - -import org.junit.Before; -import org.junit.Test; -import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; -import org.onap.policy.apex.service.engine.event.ApexEvent; -import org.onap.policy.apex.testsuites.integration.common.model.EvalDomainModelFactory; -import org.onap.policy.apex.testsuites.performance.benchmark.engine.utils.Utils; -import org.python.icu.impl.Assert; -import org.slf4j.ext.XLogger; -import org.slf4j.ext.XLoggerFactory; - -/** - * The Class ApexEngineBenchmark. - */ -public class ApexEngineBenchmark { - // Logger for this class - private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexEngineBenchmark.class); - - private static final String TARGET = "apex"; - private static final String SOURCE = "test"; - private static final String NAME = "Event0000"; - private static final String VERSION = "0.0.1"; - private static final String PACKAGE = "org.onap.policy.apex.domains.sample.events"; - - private static final long TIME_OUT_IN_MILLISEC = TimeUnit.MINUTES.toMillis(1); - - private String apexEcaModelString; - private String apexOodaModelString; - - /** - * Sets the up. - * - * @throws Exception the exception - */ - @Before - public void setUp() throws Exception { - apexEcaModelString = Utils.getModelString(new EvalDomainModelFactory().getEcaPolicyModel()); - apexOodaModelString = Utils.getModelString(new EvalDomainModelFactory().getOodaPolicyModel()); - } - - /** - * Test benchmark singleton worker. - * - * @throws Exception the exception - */ - @Test - public void testBenchmark_SingletonWorker() throws Exception { - executeTest(apexEcaModelString, 100, 1, 20); - executeTest(apexOodaModelString, 100, 1, 20); - } - - /** - * Test benchmark 3 thread worker. - * - * @throws Exception the exception - */ - @Test - public void testBenchmark_3ThreadWorker() throws Exception { - executeTest(apexEcaModelString, 1000, 3, 10); - executeTest(apexOodaModelString, 100, 3, 10); - } - - /** - * Test benchmark 10 thread worker. - * - * @throws Exception the exception - */ - @Test - public void testBenchmark_10ThreadWorker() throws Exception { - executeTest(apexEcaModelString, 2000, 10, 10); - executeTest(apexOodaModelString, 2000, 10, 10); - } - - /** - * Test benchmark 50 thread worker. - * - * @throws Exception the exception - */ - @Test - public void testBenchmark_50ThreadWorker() throws Exception { - executeTest(apexEcaModelString, 3000, 50, 10); - executeTest(apexOodaModelString, 3000, 50, 10); - } - - /** - * Test available processors thread worker. - * - * @throws Exception the exception - */ - @Test - public void testAvailableProcessorsThreadWorker() throws Exception { - final int cores = Runtime.getRuntime().availableProcessors(); - executeTest(apexEcaModelString, 3000, cores, 10); - executeTest(apexOodaModelString, 3000, cores, 10); - } - - /** - * Execute test. - * - * @param policyModel the policy model - * @param eventsCount the events count - * @param threads the threads - * @param loop the loop - * @throws Exception the exception - */ - private void executeTest(final String policyModel, final int eventsCount, final int threads, final int loop) - throws Exception { - - LOGGER.info("Running Test with Event count: {}, Instance count: {} and loop: {}", eventsCount, threads, loop); - final TestApexEventListener apexEventListener = new TestApexEventListener(); - - final ApexBaseBenchMarkTest apexBaseBenchMarkTest = - new ApexBaseBenchMarkTest(policyModel, threads, apexEventListener); - - try { - apexBaseBenchMarkTest.setUp(); - for (int i = 0; i < loop; i++) { - sendEvents(apexBaseBenchMarkTest, eventsCount); - final long currentTimeInMillSec = System.currentTimeMillis(); - while (apexEventListener.getEventReceived() < eventsCount) { - if (System.currentTimeMillis() - currentTimeInMillSec > TIME_OUT_IN_MILLISEC) { - LOGGER.warn("Wait timed out ... "); - break; - } - ThreadUtilities.sleep(500); - } - assertEquals(eventsCount, apexEventListener.getEventReceived()); - apexEventListener.printResult(); - apexEventListener.reset(); - } - } catch (final Exception exception) { - Assert.fail(exception); - } finally { - apexBaseBenchMarkTest.destroy(); - LOGGER.info("Finished Running Test with Event count: {}, Instance count: {} and loop: {}", eventsCount, - threads, loop); - } - } - - /** - * Send events. - * - * @param apexBaseBenchMarkTest the apex base bench mark test - * @param eventsCount the events count - * @throws Exception the exception - */ - public void sendEvents(final ApexBaseBenchMarkTest apexBaseBenchMarkTest, final int eventsCount) throws Exception { - for (int eventNum = 0; eventNum < eventsCount; eventNum++) { - final long currentTimeMillis = System.currentTimeMillis(); - final ApexEvent event = new ApexEvent(NAME, VERSION, PACKAGE, SOURCE, TARGET); - event.put("TestTemperature", eventNum); - event.put("FirstEventTimestamp", currentTimeMillis); - event.put("SentTimestamp", currentTimeMillis); - event.put("EventNumber", eventNum); - apexBaseBenchMarkTest.sendEvent(event); - } - } -} diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/engine/benchmark/ApexEngineBenchmarkTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/engine/benchmark/ApexEngineBenchmarkTest.java new file mode 100644 index 000000000..99035f7bf --- /dev/null +++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/engine/benchmark/ApexEngineBenchmarkTest.java @@ -0,0 +1,183 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.testsuites.performance.benchmark.engine.benchmark; + +import static org.junit.Assert.assertEquals; + +import java.util.concurrent.TimeUnit; + +import org.junit.Before; +import org.junit.Test; +import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; +import org.onap.policy.apex.service.engine.event.ApexEvent; +import org.onap.policy.apex.testsuites.integration.common.model.EvalDomainModelFactory; +import org.onap.policy.apex.testsuites.performance.benchmark.engine.utils.Utils; +import org.python.icu.impl.Assert; +import org.slf4j.ext.XLogger; +import org.slf4j.ext.XLoggerFactory; + +/** + * The Class ApexEngineBenchmark. + */ +public class ApexEngineBenchmarkTest { + // Logger for this class + private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexEngineBenchmarkTest.class); + + private static final String TARGET = "apex"; + private static final String SOURCE = "test"; + private static final String NAME = "Event0000"; + private static final String VERSION = "0.0.1"; + private static final String PACKAGE = "org.onap.policy.apex.domains.sample.events"; + + private static final long TIME_OUT_IN_MILLISEC = TimeUnit.MINUTES.toMillis(1); + + private String apexEcaModelString; + private String apexOodaModelString; + + /** + * Sets the up. + * + * @throws Exception the exception + */ + @Before + public void setUp() throws Exception { + apexEcaModelString = Utils.getModelString(new EvalDomainModelFactory().getEcaPolicyModel()); + apexOodaModelString = Utils.getModelString(new EvalDomainModelFactory().getOodaPolicyModel()); + } + + /** + * Test benchmark singleton worker. + * + * @throws Exception the exception + */ + @Test + public void testBenchmark_SingletonWorker() throws Exception { + executeTest(apexEcaModelString, 100, 1, 20); + executeTest(apexOodaModelString, 100, 1, 20); + } + + /** + * Test benchmark 3 thread worker. + * + * @throws Exception the exception + */ + @Test + public void testBenchmark_3ThreadWorker() throws Exception { + executeTest(apexEcaModelString, 1000, 3, 10); + executeTest(apexOodaModelString, 100, 3, 10); + } + + /** + * Test benchmark 10 thread worker. + * + * @throws Exception the exception + */ + @Test + public void testBenchmark_10ThreadWorker() throws Exception { + executeTest(apexEcaModelString, 2000, 10, 10); + executeTest(apexOodaModelString, 2000, 10, 10); + } + + /** + * Test benchmark 50 thread worker. + * + * @throws Exception the exception + */ + @Test + public void testBenchmark_50ThreadWorker() throws Exception { + executeTest(apexEcaModelString, 3000, 50, 10); + executeTest(apexOodaModelString, 3000, 50, 10); + } + + /** + * Test available processors thread worker. + * + * @throws Exception the exception + */ + @Test + public void testAvailableProcessorsThreadWorker() throws Exception { + final int cores = Runtime.getRuntime().availableProcessors(); + executeTest(apexEcaModelString, 3000, cores, 10); + executeTest(apexOodaModelString, 3000, cores, 10); + } + + /** + * Execute test. + * + * @param policyModel the policy model + * @param eventsCount the events count + * @param threads the threads + * @param loop the loop + * @throws Exception the exception + */ + private void executeTest(final String policyModel, final int eventsCount, final int threads, final int loop) + throws Exception { + + LOGGER.info("Running Test with Event count: {}, Instance count: {} and loop: {}", eventsCount, threads, loop); + final ApexEventListenerTest apexEventListener = new ApexEventListenerTest(); + + final ApexBaseBenchMarkTest apexBaseBenchMarkTest = + new ApexBaseBenchMarkTest(policyModel, threads, apexEventListener); + + try { + apexBaseBenchMarkTest.setUp(); + for (int i = 0; i < loop; i++) { + sendEvents(apexBaseBenchMarkTest, eventsCount); + final long currentTimeInMillSec = System.currentTimeMillis(); + while (apexEventListener.getEventReceived() < eventsCount) { + if (System.currentTimeMillis() - currentTimeInMillSec > TIME_OUT_IN_MILLISEC) { + LOGGER.warn("Wait timed out ... "); + break; + } + ThreadUtilities.sleep(500); + } + assertEquals(eventsCount, apexEventListener.getEventReceived()); + apexEventListener.printResult(); + apexEventListener.reset(); + } + } catch (final Exception exception) { + Assert.fail(exception); + } finally { + apexBaseBenchMarkTest.destroy(); + LOGGER.info("Finished Running Test with Event count: {}, Instance count: {} and loop: {}", eventsCount, + threads, loop); + } + } + + /** + * Send events. + * + * @param apexBaseBenchMarkTest the apex base bench mark test + * @param eventsCount the events count + * @throws Exception the exception + */ + public void sendEvents(final ApexBaseBenchMarkTest apexBaseBenchMarkTest, final int eventsCount) throws Exception { + for (int eventNum = 0; eventNum < eventsCount; eventNum++) { + final long currentTimeMillis = System.currentTimeMillis(); + final ApexEvent event = new ApexEvent(NAME, VERSION, PACKAGE, SOURCE, TARGET); + event.put("TestTemperature", eventNum); + event.put("FirstEventTimestamp", currentTimeMillis); + event.put("SentTimestamp", currentTimeMillis); + event.put("EventNumber", eventNum); + apexBaseBenchMarkTest.sendEvent(event); + } + } +} diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/engine/benchmark/ApexEventListenerTest.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/engine/benchmark/ApexEventListenerTest.java new file mode 100644 index 000000000..a5950df97 --- /dev/null +++ b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/engine/benchmark/ApexEventListenerTest.java @@ -0,0 +1,126 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.testsuites.performance.benchmark.engine.benchmark; + +import static org.junit.Assert.assertNull; + +import java.util.Queue; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.atomic.AtomicLong; + +import org.onap.policy.apex.service.engine.event.ApexEvent; +import org.onap.policy.apex.service.engine.runtime.ApexEventListener; +import org.slf4j.ext.XLogger; +import org.slf4j.ext.XLoggerFactory; + +/** + * The listener interface for receiving testApexEvent events. + * The class that is interested in processing a testApexEvent + * event implements this interface, and the object created + * with that class is registered with a component using the + * component's addTestApexEventListener method. When + * the testApexEvent event occurs, that object's appropriate + * method is invoked. + * + * @see TestApexEventEvent + */ +public class ApexEventListenerTest implements ApexEventListener { + + private static final String SENT_TIMESTAMP = "SentTimestamp"; + private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexEventListenerTest.class); + private static final String RECVD_TIMESTAMP = "RecvdTimestamp"; + private Queue queue; + + private final AtomicLong eventReceived = new AtomicLong(); + + /** + * Instantiates a new test apex event listener. + */ + public ApexEventListenerTest() { + this.queue = new ConcurrentLinkedQueue(); + } + + /* (non-Javadoc) + * @see org.onap.policy.apex.service.engine.runtime.ApexEventListener#onApexEventApexEvent) + */ + @Override + public void onApexEvent(final ApexEvent apexEvent) { + apexEvent.put(RECVD_TIMESTAMP, System.currentTimeMillis()); + eventReceived.incrementAndGet(); + queue.add(apexEvent); + } + + /** + * Prints the result. + */ + public void printResult() { + if (!queue.isEmpty()) { + long maxTimeInMilliSeconds = 0; + long minTimeInMilliSeconds = Long.MAX_VALUE; + final long numEvents = queue.size(); + long totalTimeInMilliSeconds = 0; + for (final ApexEvent apexEvent : queue) { + assertNull(apexEvent.getExceptionMessage()); + final Long endTimeInMilliSeconds = (Long) apexEvent.get(RECVD_TIMESTAMP); + final Long startTimeInMilliSeconds = (Long) apexEvent.get(SENT_TIMESTAMP); + final long timeTaken = endTimeInMilliSeconds - startTimeInMilliSeconds; + totalTimeInMilliSeconds += timeTaken; + if (timeTaken > maxTimeInMilliSeconds) { + maxTimeInMilliSeconds = timeTaken; + } + if (timeTaken < minTimeInMilliSeconds) { + minTimeInMilliSeconds = timeTaken; + } + } + LOGGER.info("Average Time Taken to process {} events: {} ms", numEvents, + (totalTimeInMilliSeconds / numEvents)); + LOGGER.info("Max Time Taken: {} ms", maxTimeInMilliSeconds); + LOGGER.info("Min Time Taken: {} ms", minTimeInMilliSeconds); + } + } + + /** + * Reset. + */ + public void reset() { + this.queue = new ConcurrentLinkedQueue(); + eventReceived.set(0);; + } + + /** + * Gets the queue. + * + * @return the queue + */ + public Queue getQueue() { + return queue; + } + + /** + * Gets the event received. + * + * @return the event received + */ + public long getEventReceived() { + return eventReceived.get(); + } + +} diff --git a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/engine/benchmark/TestApexEventListener.java b/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/engine/benchmark/TestApexEventListener.java deleted file mode 100644 index 2b6c89de7..000000000 --- a/testsuites/performance/performance-benchmark-test/src/test/java/org/onap/policy/apex/testsuites/performance/benchmark/engine/benchmark/TestApexEventListener.java +++ /dev/null @@ -1,126 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.testsuites.performance.benchmark.engine.benchmark; - -import static org.junit.Assert.assertNull; - -import java.util.Queue; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.atomic.AtomicLong; - -import org.onap.policy.apex.service.engine.event.ApexEvent; -import org.onap.policy.apex.service.engine.runtime.ApexEventListener; -import org.slf4j.ext.XLogger; -import org.slf4j.ext.XLoggerFactory; - -/** - * The listener interface for receiving testApexEvent events. - * The class that is interested in processing a testApexEvent - * event implements this interface, and the object created - * with that class is registered with a component using the - * component's addTestApexEventListener method. When - * the testApexEvent event occurs, that object's appropriate - * method is invoked. - * - * @see TestApexEventEvent - */ -public class TestApexEventListener implements ApexEventListener { - - private static final String SENT_TIMESTAMP = "SentTimestamp"; - private static final XLogger LOGGER = XLoggerFactory.getXLogger(TestApexEventListener.class); - private static final String RECVD_TIMESTAMP = "RecvdTimestamp"; - private Queue queue; - - private final AtomicLong eventReceived = new AtomicLong(); - - /** - * Instantiates a new test apex event listener. - */ - public TestApexEventListener() { - this.queue = new ConcurrentLinkedQueue(); - } - - /* (non-Javadoc) - * @see org.onap.policy.apex.service.engine.runtime.ApexEventListener#onApexEventApexEvent) - */ - @Override - public void onApexEvent(final ApexEvent apexEvent) { - apexEvent.put(RECVD_TIMESTAMP, System.currentTimeMillis()); - eventReceived.incrementAndGet(); - queue.add(apexEvent); - } - - /** - * Prints the result. - */ - public void printResult() { - if (!queue.isEmpty()) { - long maxTimeInMilliSeconds = 0; - long minTimeInMilliSeconds = Long.MAX_VALUE; - final long numEvents = queue.size(); - long totalTimeInMilliSeconds = 0; - for (final ApexEvent apexEvent : queue) { - assertNull(apexEvent.getExceptionMessage()); - final Long endTimeInMilliSeconds = (Long) apexEvent.get(RECVD_TIMESTAMP); - final Long startTimeInMilliSeconds = (Long) apexEvent.get(SENT_TIMESTAMP); - final long timeTaken = endTimeInMilliSeconds - startTimeInMilliSeconds; - totalTimeInMilliSeconds += timeTaken; - if (timeTaken > maxTimeInMilliSeconds) { - maxTimeInMilliSeconds = timeTaken; - } - if (timeTaken < minTimeInMilliSeconds) { - minTimeInMilliSeconds = timeTaken; - } - } - LOGGER.info("Average Time Taken to process {} events: {} ms", numEvents, - (totalTimeInMilliSeconds / numEvents)); - LOGGER.info("Max Time Taken: {} ms", maxTimeInMilliSeconds); - LOGGER.info("Min Time Taken: {} ms", minTimeInMilliSeconds); - } - } - - /** - * Reset. - */ - public void reset() { - this.queue = new ConcurrentLinkedQueue(); - eventReceived.set(0);; - } - - /** - * Gets the queue. - * - * @return the queue - */ - public Queue getQueue() { - return queue; - } - - /** - * Gets the event received. - * - * @return the event received - */ - public long getEventReceived() { - return eventReceived.get(); - } - -} diff --git a/testsuites/performance/performance-context-metrics/src/test/java/org/onap/policy/apex/testsuites/performance/context/metrics/MetricsTest.java b/testsuites/performance/performance-context-metrics/src/test/java/org/onap/policy/apex/testsuites/performance/context/metrics/MetricsTest.java new file mode 100644 index 000000000..af6b46918 --- /dev/null +++ b/testsuites/performance/performance-context-metrics/src/test/java/org/onap/policy/apex/testsuites/performance/context/metrics/MetricsTest.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.testsuites.performance.context.metrics; + +import static org.junit.Assert.fail; + +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.SortedSet; + +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.onap.policy.apex.context.test.utils.NetworkUtils; +import org.onap.policy.apex.testsuites.performance.context.metrics.ConcurrentContextMetrics; +import org.onap.policy.common.utils.resources.ResourceUtils; +import org.slf4j.ext.XLogger; +import org.slf4j.ext.XLoggerFactory; + +/** + * The Class TestMetrics. + */ +public class MetricsTest { + // Logger for this class + private static final XLogger LOGGER = XLoggerFactory.getXLogger(MetricsTest.class); + private static final String HAZELCAST_CONFIG = "hazelcast.config"; + + private static final String JAVA_NET_PREFER_IPV4_STACK = "java.net.preferIPv4Stack"; + private static final String HAZELCAST_XML_FILE = "src/test/resources/hazelcast/hazelcast.xml"; + + @Rule + public final TemporaryFolder folder = new TemporaryFolder(); + + /** + * Configure. + * + * @throws Exception the exception + */ + @BeforeClass + public static void configure() throws Exception { + System.setProperty(JAVA_NET_PREFER_IPV4_STACK, "true"); + final String hazelCastfileLocation = ResourceUtils.getFilePath4Resource(HAZELCAST_XML_FILE); + System.setProperty(HAZELCAST_CONFIG, hazelCastfileLocation); + + final SortedSet ipAddressSet = NetworkUtils.getIPv4NonLoopAddresses(); + + if (ipAddressSet.size() == 0) { + throw new Exception("cound not find real IP address for test"); + } + LOGGER.info("For Infinispan, setting jgroups.tcp.address to: {}", ipAddressSet.first()); + System.setProperty("jgroups.tcp.address", ipAddressSet.first()); + + } + + /** + * Gets the single jvm metrics. + * + * @throws IOException Signals that an I/O exception has occurred. + */ + @Test + public void getSingleJvmMetrics() throws IOException { + final File zookeeperDirectory = folder.newFolder("zookeeperDirectory"); + final String[] args = {"singleJVMTestNL", "1", "32", "1000", "65536", "0", "localhost", "62181", + zookeeperDirectory.getAbsolutePath()}; + + LOGGER.info("Starting with args: {}", Arrays.toString(args)); + try { + ConcurrentContextMetrics.main(args); + } catch (final Exception exception) { + LOGGER.error("Unexpected error", exception); + fail("Metrics test failed"); + } + } +} diff --git a/testsuites/performance/performance-context-metrics/src/test/java/org/onap/policy/apex/testsuites/performance/context/metrics/TestMetrics.java b/testsuites/performance/performance-context-metrics/src/test/java/org/onap/policy/apex/testsuites/performance/context/metrics/TestMetrics.java deleted file mode 100644 index 13610121a..000000000 --- a/testsuites/performance/performance-context-metrics/src/test/java/org/onap/policy/apex/testsuites/performance/context/metrics/TestMetrics.java +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.testsuites.performance.context.metrics; - -import static org.junit.Assert.fail; - -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.SortedSet; - -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import org.onap.policy.apex.context.test.utils.NetworkUtils; -import org.onap.policy.apex.testsuites.performance.context.metrics.ConcurrentContextMetrics; -import org.onap.policy.common.utils.resources.ResourceUtils; -import org.slf4j.ext.XLogger; -import org.slf4j.ext.XLoggerFactory; - -/** - * The Class TestMetrics. - */ -public class TestMetrics { - // Logger for this class - private static final XLogger LOGGER = XLoggerFactory.getXLogger(TestMetrics.class); - private static final String HAZELCAST_CONFIG = "hazelcast.config"; - - private static final String JAVA_NET_PREFER_IPV4_STACK = "java.net.preferIPv4Stack"; - private static final String HAZELCAST_XML_FILE = "src/test/resources/hazelcast/hazelcast.xml"; - - @Rule - public final TemporaryFolder folder = new TemporaryFolder(); - - /** - * Configure. - * - * @throws Exception the exception - */ - @BeforeClass - public static void configure() throws Exception { - System.setProperty(JAVA_NET_PREFER_IPV4_STACK, "true"); - final String hazelCastfileLocation = ResourceUtils.getFilePath4Resource(HAZELCAST_XML_FILE); - System.setProperty(HAZELCAST_CONFIG, hazelCastfileLocation); - - final SortedSet ipAddressSet = NetworkUtils.getIPv4NonLoopAddresses(); - - if (ipAddressSet.size() == 0) { - throw new Exception("cound not find real IP address for test"); - } - LOGGER.info("For Infinispan, setting jgroups.tcp.address to: {}", ipAddressSet.first()); - System.setProperty("jgroups.tcp.address", ipAddressSet.first()); - - } - - /** - * Gets the single jvm metrics. - * - * @throws IOException Signals that an I/O exception has occurred. - */ - @Test - public void getSingleJvmMetrics() throws IOException { - final File zookeeperDirectory = folder.newFolder("zookeeperDirectory"); - final String[] args = {"singleJVMTestNL", "1", "32", "1000", "65536", "0", "localhost", "62181", - zookeeperDirectory.getAbsolutePath()}; - - LOGGER.info("Starting with args: {}", Arrays.toString(args)); - try { - ConcurrentContextMetrics.main(args); - } catch (final Exception exception) { - LOGGER.error("Unexpected error", exception); - fail("Metrics test failed"); - } - } -} -- cgit 1.2.3-korg