Skip to content

Commit

Permalink
Quick fix for flaky integ test reprovisioning before template update
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Widdis <[email protected]>
  • Loading branch information
dbwiddis committed Sep 24, 2024
1 parent 43a9f87 commit a5155b8
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ public void testReprovisionWorkflow() throws Exception {
assertTrue(getPipelineResponse.pipelines().get(0).getConfigAsMap().toString().contains(modelId));

// Reprovision template to add index which uses default ingest pipeline
Instant preUpdateTime = Instant.now(); // Store a timestamp
template = TestHelpers.createTemplateFromFile("registerremotemodel-ingestpipeline-createindex.json");
response = reprovisionWorkflow(client(), workflowId, template);
assertEquals(RestStatus.CREATED, TestHelpers.restStatus(response));
Expand All @@ -463,6 +464,17 @@ public void testReprovisionWorkflow() throws Exception {
Map<String, Object> indexSettings = getIndexSettingsAsMap(indexName);
assertEquals(pipelineId, indexSettings.get("index.default_pipeline"));

// The template doesn't get updated until after the resources are created which can cause a race condition and flaky failure
// See https://github.com/opensearch-project/flow-framework/issues/870
// Making sure the template got updated before reprovisioning again.
// Quick fix to stop this from being flaky, needs a more permanent fix to synchronize template update with COMPLETED provisioning
assertBusy(() -> {
Response r = getWorkflow(client(), workflowId);
assertEquals(RestStatus.OK.getStatus(), r.getStatusLine().getStatusCode());
Template t = Template.parse(EntityUtils.toString(r.getEntity(), StandardCharsets.UTF_8));
assertTrue(t.lastUpdatedTime().isAfter(preUpdateTime));
}, 30, TimeUnit.SECONDS);

// Reprovision template to remove default ingest pipeline
template = TestHelpers.createTemplateFromFile("registerremotemodel-ingestpipeline-updateindex.json");
response = reprovisionWorkflow(client(), workflowId, template);
Expand Down

0 comments on commit a5155b8

Please sign in to comment.