/* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ import org.opensearch.gradle.testclusters.StandaloneRestIntegTestTask import org.apache.tools.ant.taskdefs.condition.Os apply from : "$rootDir/qa/build.gradle" String default_bwc_version = System.getProperty("bwc.version") String knn_bwc_version = System.getProperty("tests.bwc.version", default_bwc_version) boolean isSnapshot = knn_bwc_version.contains("-SNAPSHOT") String knn_bwc_version_no_qualifier = isSnapshot ? knn_bwc_version - "-SNAPSHOT" : knn_bwc_version String baseName = "knnBwcCluster-restart" // Creates a test cluster of previous version and loads k-NN plugin of bwcVersion testClusters { "${baseName}" { testDistribution = "ARCHIVE" versions = [knn_bwc_version, opensearch_version] numberOfNodes = 3 plugin(project.tasks.zipBwcPlugin.archiveFile) setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}" setting 'http.content_type.required', 'true' environment "LD_LIBRARY_PATH", "${buildDir}/testclusters/${baseName}-0/distro/${knn_bwc_version_no_qualifier}-ARCHIVE/plugins/opensearch-knn/knnlib;${buildDir}/testclusters/${baseName}-0/distro/${knn_bwc_version_no_qualifier}-ARCHIVE/plugins/opensearch-knn/lib" if (Os.isFamily(Os.FAMILY_WINDOWS)) { // While running on Windows OS, setting the PATH environment variable to include the paths to dlls of JNI libraries and windows dependencies environment('PATH', System.getenv('PATH') + ";$rootDir/jni/release" + ";$rootDir/src/main/resources/windowsDependencies") systemProperty "java.library.path", "${buildDir}/testclusters/${baseName}-0/distro/${knn_bwc_version_no_qualifier}-ARCHIVE/plugins/opensearch-knn/knnlib;${buildDir}/testclusters/${baseName}-0/distro/${knn_bwc_version_no_qualifier}-ARCHIVE/plugins/opensearch-knn/lib" } else { systemProperty "java.library.path", "${buildDir}/testclusters/${baseName}-0/distro/${knn_bwc_version_no_qualifier}-ARCHIVE/plugins/opensearch-knn/knnlib:${buildDir}/testclusters/${baseName}-0/distro/${knn_bwc_version_no_qualifier}-ARCHIVE/plugins/opensearch-knn/lib" } } } // Task to run BWC tests against the old cluster task testAgainstOldCluster(type: StandaloneRestIntegTestTask) { dependsOn "zipBwcPlugin" useCluster testClusters."${baseName}" systemProperty 'tests.rest.bwcsuite_cluster', 'old_cluster' systemProperty 'tests.is_old_cluster', 'true' systemProperty 'tests.skip_delete_model_index', 'true' systemProperty 'tests.plugin_bwc_version', knn_bwc_version // Skip test if version is 1.0 or 1.1 as they are not supported in those versions if (knn_bwc_version.startsWith("1.0") || knn_bwc_version.startsWith("1.1")) { filter { excludeTestsMatching "org.opensearch.knn.bwc.ModelIT" excludeTestsMatching "org.opensearch.knn.bwc.IndexingIT.testKNNIndexCustomMethodFieldMapping" excludeTestsMatching "org.opensearch.knn.bwc.WarmupIT.testKNNWarmupCustomMethodFieldMapping" } } // Skip test if version is 1.2 or 1.3 as they are not supported in those versions if (knn_bwc_version.startsWith("1.2") || knn_bwc_version.startsWith("1.3")) { filter { excludeTestsMatching "org.opensearch.knn.bwc.IndexingIT.testNullParametersOnUpgrade" } } // Skip test if version is 1.0, 1.1, 1.2 or 1.3 as they are not supported in those versions if (knn_bwc_version.startsWith("1.") || knn_bwc_version.startsWith("2.")) { filter { excludeTestsMatching "org.opensearch.knn.bwc.IndexingIT.testEmptyParametersOnUpgrade" } } nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}") nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}") systemProperty 'tests.security.manager', 'false' } // All nodes are upgraded to latest version and run the tests task testRestartUpgrade(type: StandaloneRestIntegTestTask) { dependsOn "testAgainstOldCluster" dependsOn rootProject.tasks.buildJniLib dependsOn rootProject.tasks.assemble useCluster testClusters."${baseName}" doFirst { testClusters."${baseName}".environment("LD_LIBRARY_PATH", "$rootDir/jni/release") testClusters."${baseName}".systemProperty("java.library.path", "$rootDir/jni/release") testClusters."${baseName}".upgradeAllNodesAndPluginsToNextVersion([rootProject.tasks.bundlePlugin.archiveFile]) } systemProperty 'tests.rest.bwcsuite_cluster', 'upgraded_cluster' systemProperty 'tests.skip_delete_model_index', 'true' systemProperty 'tests.is_old_cluster', 'false' systemProperty 'tests.plugin_bwc_version', knn_bwc_version // Skip test if version is 1.0 or 1.1 as they are not supported in those versions if (knn_bwc_version.startsWith("1.0") || knn_bwc_version.startsWith("1.1")) { filter { excludeTestsMatching "org.opensearch.knn.bwc.ModelIT" excludeTestsMatching "org.opensearch.knn.bwc.IndexingIT.testKNNIndexCustomMethodFieldMapping" excludeTestsMatching "org.opensearch.knn.bwc.WarmupIT.testKNNWarmupCustomMethodFieldMapping" } } // Skip test if version is 1.2 or 1.3 as they are not supported in those versions if (knn_bwc_version.startsWith("1.2") || knn_bwc_version.startsWith("1.3")) { filter { excludeTestsMatching "org.opensearch.knn.bwc.IndexingIT.testNullParametersOnUpgrade" } } // Skip test if version is 1.0, 1.1, 1.2 or 1.3 as they are not supported in those versions if (knn_bwc_version.startsWith("1.") || knn_bwc_version.startsWith("2.")) { filter { excludeTestsMatching "org.opensearch.knn.bwc.IndexingIT.testEmptyParametersOnUpgrade" } } nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}") nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}".getName()}") systemProperty 'tests.security.manager', 'false' }