diff --git a/data-prepper-api/src/main/java/org/opensearch/dataprepper/model/configuration/DataPrepperVersion.java b/data-prepper-api/src/main/java/org/opensearch/dataprepper/model/configuration/DataPrepperVersion.java index 629f649e0e..a357385bff 100644 --- a/data-prepper-api/src/main/java/org/opensearch/dataprepper/model/configuration/DataPrepperVersion.java +++ b/data-prepper-api/src/main/java/org/opensearch/dataprepper/model/configuration/DataPrepperVersion.java @@ -58,9 +58,8 @@ public Optional getMinorVersion() { /** * Determines if the provided Data Prepper Version is compatible with this. * - * The initial implementation is a basic implementation that enforces equivalent versions, any shorthand format version - * compared with full format with equivalent major versions and equivalent major version but the comparing minor version - * is less than this minor version are compatible. + * The initial implementation is a basic implementation that will return true only when the comparing version is + * less than or equal to this version. * * @param o - the other DataPrepperVersion to compare with * @return return true if the versions are compatible, otherwise false @@ -68,11 +67,11 @@ public Optional getMinorVersion() { */ public boolean compatibleWith(DataPrepperVersion o) { - if (this.majorVersion != o.getMajorVersion()) { + if (this.majorVersion < o.getMajorVersion()) { return false; } - if (this.minorVersion != null && o.getMinorVersion().isPresent()) { + if ((this.majorVersion == o.majorVersion) && (this.minorVersion != null && o.getMinorVersion().isPresent())) { if (!this.minorVersion.equals(o.getMinorVersion().get())) { return this.minorVersion > o.getMinorVersion().get(); } diff --git a/data-prepper-api/src/test/java/org/opensearch/dataprepper/model/configuration/DataPrepperVersionTest.java b/data-prepper-api/src/test/java/org/opensearch/dataprepper/model/configuration/DataPrepperVersionTest.java index 11c1085046..f8cd1e723c 100644 --- a/data-prepper-api/src/test/java/org/opensearch/dataprepper/model/configuration/DataPrepperVersionTest.java +++ b/data-prepper-api/src/test/java/org/opensearch/dataprepper/model/configuration/DataPrepperVersionTest.java @@ -13,7 +13,6 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.CoreMatchers.notNullValue; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -62,7 +61,11 @@ private static Stream compatibleDataPrepperVersions() { Arguments.of("1.4", "1.2"), Arguments.of("342.0", "342.0"), Arguments.of("342.8", "342.8"), - Arguments.of("13", "13") + Arguments.of("13", "13"), + Arguments.of("13", "2.0"), + Arguments.of("7.0", "5"), + Arguments.of("42.0", "34.0"), + Arguments.of("13", "11") ); } @@ -83,11 +86,7 @@ private static Stream nonCompatibleDataPrepperVersions() { Arguments.of("2.0", "5"), Arguments.of("42.0", "343.0"), Arguments.of("42.0", "42.1"), - Arguments.of("13", "15"), - Arguments.of("13", "2.0"), - Arguments.of("7.0", "5"), - Arguments.of("42.0", "34.0"), - Arguments.of("13", "11") + Arguments.of("13", "15") ); } diff --git a/data-prepper-core/src/test/java/org/opensearch/dataprepper/parser/PipelineParserTests.java b/data-prepper-core/src/test/java/org/opensearch/dataprepper/parser/PipelineParserTests.java index 19b8cbcf2e..df4f2d93d6 100644 --- a/data-prepper-core/src/test/java/org/opensearch/dataprepper/parser/PipelineParserTests.java +++ b/data-prepper-core/src/test/java/org/opensearch/dataprepper/parser/PipelineParserTests.java @@ -160,7 +160,7 @@ void parseConfiguration_with_incompatible_version_should_throw() { final RuntimeException actualException = assertThrows(RuntimeException.class, pipelineParser::parseConfiguration); assertThat(actualException.getMessage(), - equalTo(String.format("The version: 1.0 is not compatible with the current version: %s", DataPrepperVersion.getCurrentVersion()))); + equalTo(String.format("The version: 3005.0 is not compatible with the current version: %s", DataPrepperVersion.getCurrentVersion()))); } @Test diff --git a/data-prepper-core/src/test/resources/incompatible_version.yml b/data-prepper-core/src/test/resources/incompatible_version.yml index 3dcbf3b777..48c49d6565 100644 --- a/data-prepper-core/src/test/resources/incompatible_version.yml +++ b/data-prepper-core/src/test/resources/incompatible_version.yml @@ -1,5 +1,5 @@ -version: "1.0" #outdated version since the compatibility check was introduced. +version: "3005.0" #far out future version. test-pipeline-1: source: stdin: diff --git a/data-prepper-logstash-configuration/build.gradle b/data-prepper-logstash-configuration/build.gradle index 433a24edb6..f3ca9cea5b 100644 --- a/data-prepper-logstash-configuration/build.gradle +++ b/data-prepper-logstash-configuration/build.gradle @@ -13,7 +13,7 @@ ext { } dependencies { - antlr('org.antlr:antlr4:4.10.1') { + antlr('org.antlr:antlr4:4.12.0') { exclude group: 'org.glassfish', module: 'javax.json' } implementation project(':data-prepper-api') diff --git a/docs/configuration.md b/docs/configuration.md index 1c255090ea..9a3a58bdde 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -75,10 +75,9 @@ This sample pipeline creates a source to receive trace data and outputs transfor The pipeline configuration file now supports an optional `version` attribute. This can help users ensure the pipeline configuration used is compatible with the running data prepper version. Data Prepper now compares the version supplied in the confirmation at start -time and will throw an exception if the version in the pipeline is not compatible with the running Data Prepper version. +time and will throw an exception if the version in the pipeline is greater than the running Data Prepper version. This attribute can be specified with a shorthand format with only the major version (i.e. `2`) or major and minor version -(i.e. `2.1`). Data prepper will conclude equivalent versions, any shorthand format version with equivalent major version, -and an equivalent major version with a previously released minor version are compatible. +(i.e. `2.1`). #### Version Compatibility Matrix @@ -88,8 +87,8 @@ and an equivalent major version with a previously released minor version are com | 2.1 | 2.1 | true | | 2.1 | 2.0 | true | | 2.1 | null | true | -| 2.1 | 1.5 | false | -| 2.1 | 1 | false | +| 2.1 | 1.5 | true | +| 2.1 | 1 | true | | 2.1 | 3.0 | false | | 2.1 | 3 | false |