From 4dbe30abfef6c2f336053f0b20a64db4d637565e Mon Sep 17 00:00:00 2001 From: Sascha Peukert Date: Fri, 26 Jan 2018 16:38:22 +0100 Subject: [PATCH] Introducing BaseFeatureTest and refactoring common code of TCKTests and AcceptanceTests into it --- .../cypher/features/AcceptanceTest.scala | 163 ------------------ .../cypher/features/AcceptanceTests.scala | 52 ++++++ .../cypher/compatibility-spec-suite/pom.xml | 2 +- .../test/scala/cypher/features/TCKTests.scala | 43 +++++ enterprise/cypher/pom.xml | 1 + .../cypher/spec-suite-tools/LICENSES.txt | 11 +- enterprise/cypher/spec-suite-tools/NOTICE.txt | 6 +- enterprise/cypher/spec-suite-tools/pom.xml | 4 - .../cypher/features/BaseFeatureTest.scala} | 97 +++++------ 9 files changed, 150 insertions(+), 229 deletions(-) delete mode 100644 enterprise/cypher/acceptance-spec-suite/src/test/scala/cypher/features/AcceptanceTest.scala create mode 100644 enterprise/cypher/acceptance-spec-suite/src/test/scala/cypher/features/AcceptanceTests.scala create mode 100644 enterprise/cypher/compatibility-spec-suite/src/test/scala/cypher/features/TCKTests.scala rename enterprise/cypher/{compatibility-spec-suite/src/test/scala/cypher/features/TCKTest.scala => spec-suite-tools/src/test/scala/cypher/features/BaseFeatureTest.scala} (60%) diff --git a/enterprise/cypher/acceptance-spec-suite/src/test/scala/cypher/features/AcceptanceTest.scala b/enterprise/cypher/acceptance-spec-suite/src/test/scala/cypher/features/AcceptanceTest.scala deleted file mode 100644 index 391da973eaaa8..0000000000000 --- a/enterprise/cypher/acceptance-spec-suite/src/test/scala/cypher/features/AcceptanceTest.scala +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2002-2018 "Neo Technology," - * Network Engine for Objects in Lund AB [http://neotechnology.com] - * - * This file is part of Neo4j. - * - * Neo4j is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package cypher.features - -import java.io.File -import java.net.URI -import java.util.Collection - -import cypher.features.ScenarioTestHelper._ -import org.junit.jupiter.api.Assertions.fail -import org.junit.jupiter.api.{DynamicTest, Test, TestFactory} -import org.opencypher.tools.tck.api.{CypherTCK, Scenario} - -class AcceptanceTest { - - // these two should be empty on commit! - val featureToRun = "" - val scenarioToRun = "" - - val featuresURI: URI = getClass.getResource("/cypher/features").toURI - - val scenarios: Seq[Scenario] = { - val all = CypherTCK.parseFilesystemFeatures(new File(featuresURI)).flatMap(_.scenarios) - if (featureToRun.nonEmpty) { - val filteredFeature = all.filter(s => s.featureName == featureToRun) - if (scenarioToRun.nonEmpty) { - filteredFeature.filter(s => s.name == scenarioToRun) - } else - filteredFeature - } else if (scenarioToRun.nonEmpty) { - all.filter(s => s.name == scenarioToRun) - } else - all - } - - @TestFactory - def runAcceptanceTestsDefault(): Collection[DynamicTest] = { - createTests(scenarios, DefaultTestConfig) - } - - @TestFactory - def runAcceptanceTestsCostSlotted(): Collection[DynamicTest] = { - createTests(scenarios, CostSlottedTestConfig) - } - - // Morsel engine is not complete and executes tests very slowly - // eg. MorselExecutionContext.createClone is not implemented - // @TestFactory - // def runAcceptanceTestsCostMorsel(): Collection[DynamicTest] = { - // TODO: once Morsel is complete, generate blacklist with: generateBlacklistAcceptanceCostMorsel further down - // createTests(scenarios, CostMorselTestConfig) - // } - - @TestFactory - def runAcceptanceTestsCostCompiled(): Collection[DynamicTest] = { - createTests(scenarios, CostCompiledTestConfig) - } - - @TestFactory - def runAcceptanceTestsCost(): Collection[DynamicTest] = { - createTests(scenarios, CostTestConfig) - } - - @TestFactory - def runAcceptanceTestsCompatibility33(): Collection[DynamicTest] = { - createTests(scenarios, Compatibility33TestConfig) - } - - @TestFactory - def runAcceptanceTestsCompatibility31(): Collection[DynamicTest] = { - createTests(scenarios, Compatibility31TestConfig) - } - - @TestFactory - def runAcceptanceTestsCompatibility23(): Collection[DynamicTest] = { - def isFlakyOn23(scenario: Scenario): Boolean = { //TODO: Investigate - scenario.name == "STARTS WITH should handle null prefix" && scenario.featureName == "IndexAcceptance" - } - createTests(scenarios.filterNot(isFlakyOn23), Compatibility23TestConfig) - } - - @Test - def debugTokensNeedToBeEmpty(): Unit = { - // besides the obvious reason this test is also here (and not using assert) - // to ensure that any import optimizer doesn't remove the correct import for fail (used by the commented out methods further down) - if (!scenarioToRun.equals("")) - fail("scenarioToRun is only for debugging and should not be committed") - - if (!featureToRun.equals("")) - fail("featureToRun is only for debugging and should not be committed") - } - - /* - All methods for generating blacklists. Comment them out for commit - */ -/* - @Test - def generateBlacklistAcceptanceDefault(): Unit = { - printComputedBlacklist(scenarios, DefaultTestConfig) - fail("Do not forget to comment this method out") - } - - @Test - def generateBlacklistAcceptanceCostSlotted(): Unit = { - printComputedBlacklist(scenarios, CostSlottedTestConfig) - fail("Do not forget to comment this method out") - } - - // Morsel engine is not complete and executes tests very slowly - // eg. MorselExecutionContext.createClone is not implemented - // @Test - // def generateBlacklistAcceptanceCostMorsel(): Unit = { - // printComputedBlacklist(scenarios, CostMorselTestConfig) - // fail("Do not forget to comment this method out") - // } - - @Test - def generateBlacklistAcceptanceCostCompiled(): Unit = { - printComputedBlacklist(scenarios, CostCompiledTestConfig) - fail("Do not forget to comment this method out") - } - - @Test - def generateBlacklistAcceptanceCost(): Unit = { - printComputedBlacklist(scenarios, CostTestConfig) - fail("Do not forget to comment this method out") - } - - @Test - def generateBlacklistAcceptanceCompatibility33(): Unit = { - printComputedBlacklist(scenarios, Compatibility33TestConfig) - fail("Do not forget to comment this method out") - } - - @Test - def generateBlacklistAcceptanceCompatibility31(): Unit = { - printComputedBlacklist(scenarios, Compatibility31TestConfig) - fail("Do not forget to comment this method out") - } - @Test - def generateBlacklistAcceptanceCompatibility23(): Unit = { - printComputedBlacklist(scenarios, Compatibility23TestConfig) - fail("Do not forget to comment this method out") - } -*/ -} diff --git a/enterprise/cypher/acceptance-spec-suite/src/test/scala/cypher/features/AcceptanceTests.scala b/enterprise/cypher/acceptance-spec-suite/src/test/scala/cypher/features/AcceptanceTests.scala new file mode 100644 index 0000000000000..3753a43b02bef --- /dev/null +++ b/enterprise/cypher/acceptance-spec-suite/src/test/scala/cypher/features/AcceptanceTests.scala @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2002-2018 "Neo Technology," + * Network Engine for Objects in Lund AB [http://neotechnology.com] + * + * This file is part of Neo4j. + * + * Neo4j is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package cypher.features + +import java.io.File +import java.net.URI +import java.util.Collection + +import cypher.features.ScenarioTestHelper._ +import org.junit.jupiter.api.Assertions.fail +import org.junit.jupiter.api.{DynamicTest, Test, TestFactory} +import org.opencypher.tools.tck.api.{CypherTCK, Scenario} + +class AcceptanceTests extends BaseFeatureTest { + + // these two should be empty on commit! + override val featureToRun = "" + override val scenarioToRun = "" + + val featuresURI: URI = getClass.getResource("/cypher/features").toURI + + override val scenarios: Seq[Scenario] = { + val all = CypherTCK.parseFilesystemFeatures(new File(featuresURI)).flatMap(_.scenarios) + filterScenarios(all) + } + + @TestFactory + override def runCompatibility23(): Collection[DynamicTest] = { + //TODO: Investigate flakiness + def isFlakyOn23(scenario: Scenario): Boolean = { + scenario.name == "STARTS WITH should handle null prefix" && scenario.featureName == "IndexAcceptance" + } + createTests(scenarios.filterNot(isFlakyOn23), Compatibility23TestConfig) + } +} diff --git a/enterprise/cypher/compatibility-spec-suite/pom.xml b/enterprise/cypher/compatibility-spec-suite/pom.xml index 5ae16b2e8828d..c28762147de20 100644 --- a/enterprise/cypher/compatibility-spec-suite/pom.xml +++ b/enterprise/cypher/compatibility-spec-suite/pom.xml @@ -60,7 +60,7 @@ org.opencypher tck - 1.0.0-M09 + ${opencypher.version} diff --git a/enterprise/cypher/compatibility-spec-suite/src/test/scala/cypher/features/TCKTests.scala b/enterprise/cypher/compatibility-spec-suite/src/test/scala/cypher/features/TCKTests.scala new file mode 100644 index 0000000000000..95933ddf051f1 --- /dev/null +++ b/enterprise/cypher/compatibility-spec-suite/src/test/scala/cypher/features/TCKTests.scala @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2002-2018 "Neo Technology," + * Network Engine for Objects in Lund AB [http://neotechnology.com] + * + * This file is part of Neo4j. + * + * Neo4j is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package cypher.features + +import java.nio.file.FileSystems + +import org.junit.jupiter.api.AfterEach +import org.opencypher.tools.tck.api.{CypherTCK, Scenario} + +class TCKTests extends BaseFeatureTest { + + // these two should be empty on commit! + override val featureToRun = "" + override val scenarioToRun = "" + + override val scenarios: Seq[Scenario] = { + val allScenarios: Seq[Scenario] = CypherTCK.allTckScenarios + filterScenarios(allScenarios) + } + + @AfterEach + def tearDown(): Unit = { + //TODO: This method can be removed with new release of TCK (1.0.0-M10) + FileSystems.getFileSystem(CypherTCK.getClass.getResource(CypherTCK.featuresPath).toURI).close() + } +} diff --git a/enterprise/cypher/pom.xml b/enterprise/cypher/pom.xml index 9fd045eb28fbd..67d845b79009c 100644 --- a/enterprise/cypher/pom.xml +++ b/enterprise/cypher/pom.xml @@ -20,6 +20,7 @@ notice-agpl-prefix.txt AGPL-3-header.txt + 1.0.0-M09 diff --git a/enterprise/cypher/spec-suite-tools/LICENSES.txt b/enterprise/cypher/spec-suite-tools/LICENSES.txt index 72ba5f1d852c3..76002f6e87c43 100644 --- a/enterprise/cypher/spec-suite-tools/LICENSES.txt +++ b/enterprise/cypher/spec-suite-tools/LICENSES.txt @@ -3,7 +3,6 @@ libraries. For an overview of the licenses see the NOTICE.txt file. ------------------------------------------------------------------------------ Apache Software License, Version 2.0 - Apache Commons IO Apache Commons Lang Caffeine cache casbah-commons @@ -15,13 +14,13 @@ Apache Software License, Version 2.0 json4s-ast json4s-core json4s-native - Logging Lucene Core Lucene Memory MongoDB Java Driver Netty/All-in-One nscala-time - openCypher TCK Developer Tools + openCypher TCK API + openCypher TCK Features and Graphs org.apiguardian:apiguardian-api org.opentest4j:opentest4j parboiled-core @@ -277,6 +276,7 @@ SUCH DAMAGE. ------------------------------------------------------------------------------ BSD License + ANTLR 4 Runtime ParaNamer Core Scala Compiler scala-parser-combinators @@ -611,8 +611,8 @@ No third-party beneficiary rights are created under this Agreement. Exhibit A - Form of Secondary Licenses Notice -"This Source Code may also be made available under the following -Secondary Licenses when the conditions for such availability set forth +"This Source Code may also be made available under the following +Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: {name license(s), version(s), and exceptions or additional permissions here}." @@ -656,4 +656,3 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/enterprise/cypher/spec-suite-tools/NOTICE.txt b/enterprise/cypher/spec-suite-tools/NOTICE.txt index 24e0da88725aa..049e8c0fabcd7 100644 --- a/enterprise/cypher/spec-suite-tools/NOTICE.txt +++ b/enterprise/cypher/spec-suite-tools/NOTICE.txt @@ -25,7 +25,6 @@ Third-party licenses -------------------- Apache Software License, Version 2.0 - Apache Commons IO Apache Commons Lang Caffeine cache casbah-commons @@ -37,13 +36,13 @@ Apache Software License, Version 2.0 json4s-ast json4s-core json4s-native - Logging Lucene Core Lucene Memory MongoDB Java Driver Netty/All-in-One nscala-time - openCypher TCK Developer Tools + openCypher TCK API + openCypher TCK Features and Graphs org.apiguardian:apiguardian-api org.opentest4j:opentest4j parboiled-core @@ -55,6 +54,7 @@ BSD - Scala License Scala Library BSD License + ANTLR 4 Runtime ParaNamer Core Scala Compiler scala-parser-combinators diff --git a/enterprise/cypher/spec-suite-tools/pom.xml b/enterprise/cypher/spec-suite-tools/pom.xml index ddd84d04a8f36..59c2dc0e4cd69 100644 --- a/enterprise/cypher/spec-suite-tools/pom.xml +++ b/enterprise/cypher/spec-suite-tools/pom.xml @@ -44,10 +44,6 @@ - - 1.0.0-M09 - - diff --git a/enterprise/cypher/compatibility-spec-suite/src/test/scala/cypher/features/TCKTest.scala b/enterprise/cypher/spec-suite-tools/src/test/scala/cypher/features/BaseFeatureTest.scala similarity index 60% rename from enterprise/cypher/compatibility-spec-suite/src/test/scala/cypher/features/TCKTest.scala rename to enterprise/cypher/spec-suite-tools/src/test/scala/cypher/features/BaseFeatureTest.scala index 0c9380a2f2c48..605c3f90e4815 100644 --- a/enterprise/cypher/compatibility-spec-suite/src/test/scala/cypher/features/TCKTest.scala +++ b/enterprise/cypher/spec-suite-tools/src/test/scala/cypher/features/BaseFeatureTest.scala @@ -19,22 +19,22 @@ */ package cypher.features -import java.nio.file.FileSystems import java.util.Collection import cypher.features.ScenarioTestHelper._ +import org.junit.Ignore import org.junit.jupiter.api.Assertions.fail -import org.junit.jupiter.api.{AfterEach, DynamicTest, Test, TestFactory} -import org.opencypher.tools.tck.api.{CypherTCK, Scenario} - -class TCKTest { +import org.junit.jupiter.api.{DynamicTest, Test, TestFactory} +import org.opencypher.tools.tck.api.Scenario +abstract class BaseFeatureTest { // these two should be empty on commit! val featureToRun = "" val scenarioToRun = "" - val allScenarios = CypherTCK.allTckScenarios - val scenarios: Seq[Scenario] = { + val scenarios: Seq[Scenario] + + def filterScenarios(allScenarios: Seq[Scenario]): Seq[Scenario] = { if (featureToRun.nonEmpty) { val filteredFeature = allScenarios.filter(s => s.featureName == featureToRun) if (scenarioToRun.nonEmpty) { @@ -47,52 +47,46 @@ class TCKTest { allScenarios } - @AfterEach - def tearDown(): Unit = { - //TODO: This method can be removed with new release of TCK (1.0.0-M10) - FileSystems.getFileSystem(CypherTCK.getClass.getResource(CypherTCK.featuresPath).toURI).close() - } - @TestFactory - def runTCKTestsDefault(): Collection[DynamicTest] = { + def runDefault(): Collection[DynamicTest] = { createTests(scenarios, DefaultTestConfig) } @TestFactory - def runTCKTestsCostSlotted(): Collection[DynamicTest] = { + def runCostSlotted(): Collection[DynamicTest] = { createTests(scenarios, CostSlottedTestConfig) } // Morsel engine is not complete and executes tests very slowly // eg. MorselExecutionContext.createClone is not implemented // @TestFactory - // def runTCKTestsCostMorsel(): Collection[DynamicTest] = { - // TODO: once Morsel is complete, generate blacklist with: generateBlacklistTCKTestCostMorsel further down + // def runCostMorsel(): Collection[DynamicTest] = { + // TODO: once Morsel is complete, generate blacklist with: generateBlacklistCostMorsel further down // createTests(scenarios, CostMorselTestConfig) // } @TestFactory - def runTCKTestsCostCompiled(): Collection[DynamicTest] = { + def runCostCompiled(): Collection[DynamicTest] = { createTests(scenarios, CostCompiledTestConfig) } @TestFactory - def runTCKTestsCost(): Collection[DynamicTest] = { + def runCost(): Collection[DynamicTest] = { createTests(scenarios, CostTestConfig) } @TestFactory - def runTCKTestsCompatibility33(): Collection[DynamicTest] = { + def runCompatibility33(): Collection[DynamicTest] = { createTests(scenarios, Compatibility33TestConfig) } @TestFactory - def runTCKTestsCompatibility31(): Collection[DynamicTest] = { + def runCompatibility31(): Collection[DynamicTest] = { createTests(scenarios, Compatibility31TestConfig) } @TestFactory - def runTCKTestsCompatibility23(): Collection[DynamicTest] = { + def runCompatibility23(): Collection[DynamicTest] = { createTests(scenarios, Compatibility23TestConfig) } @@ -108,57 +102,56 @@ class TCKTest { } /* - All methods for generating blacklists. Comment them out for commit + All methods for generating blacklists. Ignore them for commit */ -/* - @Test - def generateBlacklistTCKTestDefault(): Unit = { + + @Ignore + def generateBlacklistDefault(): Unit = { printComputedBlacklist(scenarios, DefaultTestConfig) - fail("Do not forget to comment this method out") + fail("Do not forget to add @ignore to this method") } - @Test - def generateBlacklistTCKTestCostSlotted(): Unit = { + @Ignore + def generateBlacklistCostSlotted(): Unit = { printComputedBlacklist(scenarios, CostSlottedTestConfig) - fail("Do not forget to comment this method out") + fail("Do not forget to add @ignore to this method") } // Morsel engine is not complete and executes tests very slowly - // eg. MorselExecutionContext.createClone is not implemented - // @Test - // def generateBlacklistTCKTestCostMorsel(): Unit = { - // printComputedBlacklist(scenarios, CostMorselTestConfig) - // fail("Do not forget to comment this method out") - // } + //eg. MorselExecutionContext.createClone is not implemented + @Ignore + def generateBlacklistTCKTestCostMorsel(): Unit = { + printComputedBlacklist(scenarios, CostMorselTestConfig) + fail("Do not forget to add @ignore to this method") + } - @Test - def generateBlacklistTCKTestCostCompiled(): Unit = { + @Ignore + def generateBlacklistCostCompiled(): Unit = { printComputedBlacklist(scenarios, CostCompiledTestConfig) - fail("Do not forget to comment this method out") + fail("Do not forget to add @ignore to this method") } - @Test - def generateBlacklistTCKTestCost(): Unit = { + @Ignore + def generateBlacklistCost(): Unit = { printComputedBlacklist(scenarios, CostTestConfig) - fail("Do not forget to comment this method out") + fail("Do not forget to add @ignore to this method") } - @Test - def generateBlacklistTCKTestCompatibility33(): Unit = { + @Ignore + def generateBlacklistCompatibility33(): Unit = { printComputedBlacklist(scenarios, Compatibility33TestConfig) - fail("Do not forget to comment this method out") + fail("Do not forget to add @ignore to this method") } - @Test - def generateBlacklistTCKTestCompatibility31(): Unit = { + @Ignore + def generateBlacklistCompatibility31(): Unit = { printComputedBlacklist(scenarios, Compatibility31TestConfig) - fail("Do not forget to comment this method out") + fail("Do not forget to add @ignore to this method") } - @Test - def generateBlacklistTCKTestCompatibility23(): Unit = { + @Ignore + def generateBlacklistCompatibility23(): Unit = { printComputedBlacklist(scenarios, Compatibility23TestConfig) - fail("Do not forget to comment this method out") + fail("Do not forget to add @ignore to this method") } -*/ }