diff options
author | liamfallon <liam.fallon@ericsson.com> | 2018-11-14 17:01:39 +0000 |
---|---|---|
committer | liamfallon <liam.fallon@ericsson.com> | 2018-11-15 11:24:59 +0000 |
commit | cf0521066debe5c7f5d63c0086b6fa59d80b42ff (patch) | |
tree | 509c540c014669c50ea7a6a972f396fef6276567 /testsuites/integration | |
parent | 32497610bd7bc721bb73f0d753fc1426bba677e2 (diff) |
Refactored Asynchronous tests to integration
Moved the tests of asynchronous and synchronous inputs and outputs
for Apex from benchmark tests to integration tests which is where
they should be. Also the tests were amended to use the common
integration test data.
Change-Id: Id2d098b0a7d70c50dbb4547b0386cc7bcf6245a9
Issue-ID: POLICY-954
Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'testsuites/integration')
10 files changed, 419 insertions, 0 deletions
diff --git a/testsuites/integration/integration-common/src/main/resources/examples/events/SampleDomain/EventsInMulti0.jsons b/testsuites/integration/integration-common/src/main/resources/examples/events/SampleDomain/EventsInMulti0.json index da11b2c94..da11b2c94 100644 --- a/testsuites/integration/integration-common/src/main/resources/examples/events/SampleDomain/EventsInMulti0.jsons +++ b/testsuites/integration/integration-common/src/main/resources/examples/events/SampleDomain/EventsInMulti0.json diff --git a/testsuites/integration/integration-common/src/main/resources/examples/events/SampleDomain/EventsInMulti1.jsons b/testsuites/integration/integration-common/src/main/resources/examples/events/SampleDomain/EventsInMulti1.json index da11b2c94..da11b2c94 100644 --- a/testsuites/integration/integration-common/src/main/resources/examples/events/SampleDomain/EventsInMulti1.jsons +++ b/testsuites/integration/integration-common/src/main/resources/examples/events/SampleDomain/EventsInMulti1.json diff --git a/testsuites/integration/integration-common/src/main/resources/examples/events/SampleDomain/EventsInMulti2.jsons b/testsuites/integration/integration-common/src/main/resources/examples/events/SampleDomain/EventsInMulti2.json index da11b2c94..da11b2c94 100644 --- a/testsuites/integration/integration-common/src/main/resources/examples/events/SampleDomain/EventsInMulti2.jsons +++ b/testsuites/integration/integration-common/src/main/resources/examples/events/SampleDomain/EventsInMulti2.json diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventMimoTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventMimoTest.java new file mode 100644 index 000000000..cb01af388 --- /dev/null +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventMimoTest.java @@ -0,0 +1,56 @@ +/*- + * ============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.integration.uservice.adapt.events.syncasync; + +import java.io.File; + +import org.junit.After; +import org.junit.Test; + +public class AsyncEventMimoTest extends BaseEventTest { + private final String[] outFilePaths = { + "target/examples/events/SampleDomain/EventsOutMulti0.json", + "target/examples/events/SampleDomain/EventsOutMulti1.json", + "target/examples/events/SampleDomain/EventsOutMulti2.json" + }; + + /** + * Delete output files. + */ + @After + public void deleteOutputFiles() { + for (String filePath : outFilePaths) { + new File(filePath).delete(); + } + } + + @Test + public void testJsonFileAsyncMimo() throws Exception { + final String[] args = { + "-rfr", + "target", + "-c", + "target/examples/config/SampleDomain/File2FileJsonEventAsyncMIMO.json" + }; + + testFileEvents(args, outFilePaths, 300); + } +} diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventMisoTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventMisoTest.java new file mode 100644 index 000000000..ca4e1ecc1 --- /dev/null +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventMisoTest.java @@ -0,0 +1,54 @@ +/*- + * ============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.integration.uservice.adapt.events.syncasync; + +import java.io.File; + +import org.junit.After; +import org.junit.Test; + +public class AsyncEventMisoTest extends BaseEventTest { + private final String[] outFilePaths = { + "target/examples/events/SampleDomain/EventsOutSingle.json" + }; + + /** + * Delete output files. + */ + @After + public void deleteOutputFiles() { + for (String filePath : outFilePaths) { + new File(filePath).delete(); + } + } + + @Test + public void testJsonFileAsyncMiso() throws Exception { + final String[] args = { + "-rfr", + "target", + "-c", + "target/examples/config/SampleDomain/File2FileJsonEventAsyncMISO.json" + }; + + testFileEvents(args, outFilePaths, 300); + } +} diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventSimoTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventSimoTest.java new file mode 100644 index 000000000..d11fc012d --- /dev/null +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventSimoTest.java @@ -0,0 +1,58 @@ +/*- + * ============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.integration.uservice.adapt.events.syncasync; + +import java.io.File; + +import org.junit.After; +import org.junit.Test; + +public class AsyncEventSimoTest extends BaseEventTest { + private final String[] outFilePaths = { + "target/examples/events/SampleDomain/EventsOutMulti0.json", + "target/examples/events/SampleDomain/EventsOutMulti1.json", + "target/examples/events/SampleDomain/EventsOutMulti2.json" + }; + + /** + * Delete output files. + */ + @After + public void deleteOutputFiles() { + for (String filePath : outFilePaths) { + new File(filePath).delete(); + } + } + + @Test + public void testJsonFileAsyncSimo() throws Exception { + final String[] args = { + "-rfr", + "target", + "-c", + "target/examples/config/SampleDomain/File2FileJsonEventAsyncSIMO.json" + }; + + + testFileEvents(args, outFilePaths, 100); + } + +} diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventSisoTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventSisoTest.java new file mode 100644 index 000000000..bd77b424b --- /dev/null +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/AsyncEventSisoTest.java @@ -0,0 +1,53 @@ +/*- + * ============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.integration.uservice.adapt.events.syncasync; + +import java.io.File; + +import org.junit.After; +import org.junit.Test; + +public class AsyncEventSisoTest extends BaseEventTest { + private final String[] outFilePaths = { + "target/examples/events/SampleDomain/EventsOutSingle.json" + }; + + /** + * Delete output files. + */ + @After + public void deleteOutputFiles() { + for (String filePath : outFilePaths) { + new File(filePath).delete(); + } + } + + @Test + public void testJsonFileAsyncSiso() throws Exception { + final String[] args = { + "-rfr", + "target", + "-c", + "target/examples/config/SampleDomain/File2FileJsonEventAsyncSISO.json"}; + + testFileEvents(args, outFilePaths, 100); + } +} diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/BaseEventTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/BaseEventTest.java new file mode 100644 index 000000000..9199d2a98 --- /dev/null +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/BaseEventTest.java @@ -0,0 +1,88 @@ +/*- + * ============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.integration.uservice.adapt.events.syncasync; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.IOException; + +import org.apache.commons.lang3.StringUtils; +import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; +import org.onap.policy.apex.model.utilities.TextFileUtils; +import org.onap.policy.apex.service.engine.main.ApexMain; + +public class BaseEventTest { + private static final long TIME_OUT_IN_MS = 10000; + + private void waitForOutFiles(final String[] expectedFileNames, final long expectedFileSize) throws IOException { + final long totalExpectedSize = expectedFileSize * expectedFileNames.length; + + long startWaitTime = System.currentTimeMillis(); + long lastTotalSize = 0; + + do { + long totalSize = 0; + + for (String expectedFileName : expectedFileNames) { + totalSize += getEventCount(expectedFileName); + } + + if (totalSize >= totalExpectedSize) { + return; + } + + // We're making progress, extend the timeout + if (totalSize > lastTotalSize) { + lastTotalSize = totalSize; + startWaitTime = System.currentTimeMillis(); + } + + ThreadUtilities.sleep(100); + } + while (TIME_OUT_IN_MS >= System.currentTimeMillis() - startWaitTime); + } + + private int getEventCount(final String expectedFileName) throws IOException { + File expectedFile = new File(expectedFileName); + + if (!expectedFile.exists()) { + return 0; + } + + String expectedFileContents = TextFileUtils.getTextFileAsString(expectedFileName); + + return StringUtils.countMatches(expectedFileContents, "{"); + } + + protected void testFileEvents(final String[] args, final String[] expectedFileNames, final long expectedFileSize) + throws Exception { + final ApexMain apexMain = new ApexMain(args); + + waitForOutFiles(expectedFileNames, expectedFileSize); + + apexMain.shutdown(); + + for (final String expectedFileName : expectedFileNames) { + assertEquals(expectedFileSize, getEventCount(expectedFileName)); + } + } +} diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/SyncEventMimoTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/SyncEventMimoTest.java new file mode 100644 index 000000000..cf86d2fc1 --- /dev/null +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/SyncEventMimoTest.java @@ -0,0 +1,57 @@ +/*- + * ============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.integration.uservice.adapt.events.syncasync; + +import java.io.File; + +import org.junit.After; +import org.junit.Test; + +public class SyncEventMimoTest extends BaseEventTest { + private final String[] outFilePaths = { + "target/examples/events/SampleDomain/EventsOutMulti0.json", + "target/examples/events/SampleDomain/EventsOutMulti1.json", + "target/examples/events/SampleDomain/EventsOutMulti2.json" + }; + + /** + * Delete output files. + */ + @After + public void deleteOutputFiles() { + for (String filePath : outFilePaths) { + new File(filePath).delete(); + } + } + + @Test + public void testJsonFileAsyncMimo() throws Exception { + final String[] args = { + "-rfr", + "target", + "-c", + "target/examples/config/SampleDomain/File2FileJsonEventSyncMIMO.json" + }; + + testFileEvents(args, outFilePaths, 300); + } + +} diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/SyncEventSisoTest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/SyncEventSisoTest.java new file mode 100644 index 000000000..7fed77bf2 --- /dev/null +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/events/syncasync/SyncEventSisoTest.java @@ -0,0 +1,53 @@ +/*- + * ============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.integration.uservice.adapt.events.syncasync; + +import java.io.File; + +import org.junit.After; +import org.junit.Test; + +public class SyncEventSisoTest extends BaseEventTest { + private final String[] outFilePaths = { + "target/examples/events/SampleDomain/EventsOutSingle.json" + }; + + /** + * Delete output files. + */ + @After + public void deleteOutputFiles() { + for (String filePath : outFilePaths) { + new File(filePath).delete(); + } + } + + @Test + public void testJsonFileAsyncSiso() throws Exception { + final String[] args = { + "-rfr", + "target", + "-c", + "target/examples/config/SampleDomain/File2FileJsonEventSyncSISO.json"}; + + testFileEvents(args, outFilePaths, 100); + } +} |