Tests for ASTERIXDB-1725 Just inserts a really big record, stops, and starts again. This should always work, but for the bug, it'd cause a nullpointer upon querying the dataset.
Change-Id: I8b241acebbdcd658e734a43d03259a1ea24d8b57 Reviewed-on: https://asterix-gerrit.ics.uci.edu/1344 Sonar-Qube: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Reviewed-by: Michael Blow <mb...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/38845d54 Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/38845d54 Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/38845d54 Branch: refs/heads/master Commit: 38845d54f1cd0d8b867bb3adfe0c8120cb94e167 Parents: 9af8a4b Author: Ian Maxon <ima...@apache.org> Authored: Mon Nov 7 11:25:09 2016 -0800 Committer: Ian Maxon <ima...@apache.org> Committed: Tue Nov 8 13:18:33 2016 -0800 ---------------------------------------------------------------------- .../installer/test/AsterixRestartIT.java | 61 +++++++++++++------- .../integrationts/restart/hugeobject.adm | 1 + .../issue-1725/issue-1725.1.ddl.aql | 29 ++++++++++ .../issue-1725/issue-1725.2.update.aql | 28 +++++++++ .../issue-1725/issue-1725.3.mgx.aql | 2 + .../issue-1725/issue-1725.4.mgx.aql | 2 + .../issue-1725/issue-1725.5.query.aql | 27 +++++++++ .../storage-restart/issue-1725/issue-1725.5.aql | 1 + .../integrationts/restart/testsuite.xml | 7 +++ 9 files changed, 138 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/asterixdb/blob/38845d54/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AsterixRestartIT.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AsterixRestartIT.java b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AsterixRestartIT.java index 6d7eaa4..d567145 100644 --- a/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AsterixRestartIT.java +++ b/asterixdb/asterix-installer/src/test/java/org/apache/asterix/installer/test/AsterixRestartIT.java @@ -19,38 +19,47 @@ package org.apache.asterix.installer.test; import java.io.File; +import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Map; import java.util.logging.Logger; +import org.apache.asterix.common.config.AsterixStorageProperties; import org.apache.asterix.event.model.AsterixInstance.State; import org.apache.asterix.test.aql.TestExecutor; import org.apache.asterix.test.base.RetainLogsRule; import org.apache.asterix.testframework.context.TestCaseContext; import org.apache.commons.lang3.StringUtils; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; +import org.junit.*; import org.junit.rules.TestRule; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; //This is just a simple derivative of all of the other IT test cases specifically for test cases which revolve around //some behavior where stopping and starting Asterix causes issues + +@RunWith(Parameterized.class) public class AsterixRestartIT { private static final String PATH_BASE = "src/test/resources/integrationts/restart/"; private static final String PATH_ACTUAL = "target" + File.separator + "ittest" + File.separator; private static final Logger LOGGER = Logger.getLogger(AsterixRestartIT.class.getName()); - private static List<TestCaseContext> testCaseCollection; private static String reportPath = new File( StringUtils.join(new String[] { "target", "failsafe-reports" }, File.separator)).getAbsolutePath(); private final TestExecutor testExecutor = new TestExecutor(); + private TestCaseContext tcCtx; private static String scriptHomePath; private static File asterixInstallerPath; private static ProcessBuilder pb; private static Map<String, String> env; + + public AsterixRestartIT(TestCaseContext tcCtx) { + this.tcCtx = tcCtx; + } + @Rule public TestRule retainLogs = new RetainLogsRule(AsterixInstallerIntegrationUtil.getManagixHome(), reportPath); @@ -65,9 +74,6 @@ public class AsterixRestartIT { + File.separator + "scripts"; env.put("SCRIPT_HOME", scriptHomePath); AsterixInstallerIntegrationUtil.init(); - AsterixInstallerIntegrationUtil.transformIntoRequiredState(State.ACTIVE); - TestCaseContext.Builder b = new TestCaseContext.Builder(); - testCaseCollection = b.build(new File(PATH_BASE)); } catch (Throwable th) { th.printStackTrace(); throw th; @@ -79,24 +85,39 @@ public class AsterixRestartIT { AsterixInstallerIntegrationUtil.deinit(); } + @Before + public void before() throws Exception { + AsterixInstallerIntegrationUtil.transformIntoRequiredState(State.INACTIVE); + AsterixInstallerIntegrationUtil.transformIntoRequiredState(State.ACTIVE); + } + + + @After + public void after() throws Exception{ + AsterixInstallerIntegrationUtil.transformIntoRequiredState(State.INACTIVE); + } + @Test public void test() throws Exception { - for (TestCaseContext testCaseCtx : testCaseCollection) { - testExecutor.executeTest(PATH_ACTUAL, testCaseCtx, pb, false); - } + testExecutor.executeTest(PATH_ACTUAL, tcCtx, pb, false); + } + @Parameterized.Parameters(name = "RestartIT {index}: {0}") + public static Collection<Object[]> tests() throws Exception { + Collection<Object[]> testArgs = buildTestsInXml(TestCaseContext.DEFAULT_TESTSUITE_XML_NAME); + if (testArgs.size() == 0) { + testArgs = buildTestsInXml(TestCaseContext.DEFAULT_TESTSUITE_XML_NAME); + } + return testArgs; } - public static void main(String[] args) throws Exception { - try { - setUp(); - new AsterixRestartIT().test(); - } catch (Exception e) { - e.printStackTrace(); - LOGGER.info("TEST CASES FAILED"); - } finally { - tearDown(); + protected static Collection<Object[]> buildTestsInXml(String xmlfile) throws Exception { + Collection<Object[]> testArgs = new ArrayList<>(); + TestCaseContext.Builder b = new TestCaseContext.Builder(); + for (TestCaseContext ctx : b.build(new File(PATH_BASE), xmlfile)) { + testArgs.add(new Object[] { ctx }); } + return testArgs; } }