Skip to content

Commit

Permalink
Skip rolling upgrade bwc on major version change
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Widdis <[email protected]>
  • Loading branch information
dbwiddis committed Mar 7, 2024
1 parent 6b18d84 commit a9b0a51
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
28 changes: 21 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import java.nio.file.Paths
buildscript {
ext {
opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT")
bwcVersionShort = "2.12.0"
buildVersionQualifier = System.getProperty("build.version_qualifier", "")
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
version_tokens = opensearch_version.tokenize('-')
Expand Down Expand Up @@ -207,6 +206,12 @@ jacocoTestReport {
}
tasks.named("check").configure { dependsOn(jacocoTestReport) }

tasks.named("yamlRestTest").configure {
filter {
excludeTestsMatching "org.opensearch.flowframework.rest.*IT"
excludeTestsMatching "org.opensearch.flowframework.bwc.*IT"
}
}

// Set up integration tests
task integTest(type: RestIntegTestTask) {
Expand Down Expand Up @@ -246,17 +251,17 @@ integTest {
}
}

// Exclude integration tests that require security plugin
if (System.getProperty("https") == null || System.getProperty("https") == "false") {
// Exclude BWC tests, run separately
if (System.getProperty("tests.rest.bwcsuite") == null) {
filter {
excludeTestsMatching "org.opensearch.flowframework.rest.FlowFrameworkSecureRestApiIT"
excludeTestsMatching "org.opensearch.flowframework.bwc.*IT"
}
}

// Exclude BWC tests, run separately
if (System.getProperty("tests.rest.bwcsuite") == null) {
// Exclude integration tests that require security plugin
if (System.getProperty("https") == null || System.getProperty("https") == "false") {
filter {
excludeTestsMatching "org.opensearch.flowframework.bwc.*IT"
excludeTestsMatching "org.opensearch.flowframework.rest.FlowFrameworkSecureRestApiIT"
}
}

Expand Down Expand Up @@ -505,6 +510,7 @@ List<Provider<RegularFile>> plugins = [
// Creates 2 test clusters with 3 nodes of the old version.
2.times {i ->
task "${baseName}#oldVersionClusterTask$i"(type: StandaloneRestIntegTestTask) {
onlyIf { isSameMajorVersion || (i == 1) }
useCluster testClusters."${baseName}$i"
filter {
includeTestsMatching "org.opensearch.flowframework.bwc.*IT"
Expand All @@ -521,6 +527,7 @@ List<Provider<RegularFile>> plugins = [
// This results in a mixed cluster with 2 nodes on the old version and 1 upgraded node.
// This is also used as a one third upgraded cluster for a rolling upgrade.
task "${baseName}#mixedClusterTask"(type: StandaloneRestIntegTestTask) {
onlyIf { isSameMajorVersion }
useCluster testClusters."${baseName}0"
dependsOn "${baseName}#oldVersionClusterTask0"
doFirst {
Expand All @@ -540,6 +547,7 @@ task "${baseName}#mixedClusterTask"(type: StandaloneRestIntegTestTask) {
// This results in a mixed cluster with 1 node on the old version and 2 upgraded nodes.
// This is used for rolling upgrade.
task "${baseName}#twoThirdsUpgradedClusterTask"(type: StandaloneRestIntegTestTask) {
onlyIf { isSameMajorVersion }
dependsOn "${baseName}#mixedClusterTask"
useCluster testClusters."${baseName}0"
doFirst {
Expand All @@ -559,6 +567,7 @@ task "${baseName}#twoThirdsUpgradedClusterTask"(type: StandaloneRestIntegTestTas
// This results in a fully upgraded cluster.
// This is used for rolling upgrade.
task "${baseName}#rollingUpgradeClusterTask"(type: StandaloneRestIntegTestTask) {
onlyIf { isSameMajorVersion }
dependsOn "${baseName}#twoThirdsUpgradedClusterTask"
useCluster testClusters."${baseName}0"
doFirst {
Expand Down Expand Up @@ -614,6 +623,11 @@ allprojects {
}
}
}
// Needed for Gradle 9.0
tasks.withType(StandaloneRestIntegTestTask).configureEach {
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath
}
}

// Automatically sets up the integration test cluster locally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public void testCreateAndProvisionAgentFrameworkWorkflow() throws Exception {

public void testTimestamps() throws Exception {
Template noopTemplate = TestHelpers.createTemplateFromFile("noop.json");
// Create the template
// Create the template, should have created and updated matching
Response response = createWorkflow(client(), noopTemplate);
Map<String, Object> responseMap = entityAsMap(response);
String workflowId = (String) responseMap.get(WORKFLOW_ID);
Expand All @@ -333,6 +333,7 @@ public void testTimestamps() throws Exception {
assertEquals(createdTime, lastUpdatedTime);
assertNull(t.lastProvisionedTime());

// Update the template, should have created same as before and updated newer
response = updateWorkflow(client(), workflowId, noopTemplate);
assertEquals(RestStatus.CREATED.getStatus(), response.getStatusLine().getStatusCode());

Expand All @@ -344,6 +345,7 @@ public void testTimestamps() throws Exception {
lastUpdatedTime = t.lastUpdatedTime();
assertNull(t.lastProvisionedTime());

// Provision the template, should have created and updated same as before and provisioned newer
response = provisionWorkflow(client(), workflowId);
assertEquals(RestStatus.OK.getStatus(), response.getStatusLine().getStatusCode());

Expand All @@ -354,6 +356,7 @@ public void testTimestamps() throws Exception {
assertEquals(lastUpdatedTime, t.lastUpdatedTime());
assertTrue(t.lastProvisionedTime().isAfter(lastUpdatedTime));

// Clean up
response = deleteWorkflow(client(), workflowId);
assertEquals(RestStatus.OK.getStatus(), response.getStatusLine().getStatusCode());
}
Expand Down

0 comments on commit a9b0a51

Please sign in to comment.