Skip to content

Commit e907cd0

Browse files
[Backport 2.17] Quick fix for flaky integ test reprovisioning before template update (#882)
Quick fix for flaky integ test reprovisioning before template update (#880) (cherry picked from commit 22c994b) Signed-off-by: Daniel Widdis <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 71379bf commit e907cd0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/test/java/org/opensearch/flowframework/rest/FlowFrameworkRestApiIT.java

+12
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ public void testReprovisionWorkflow() throws Exception {
446446
assertTrue(getPipelineResponse.pipelines().get(0).getConfigAsMap().toString().contains(modelId));
447447

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

467+
// The template doesn't get updated until after the resources are created which can cause a race condition and flaky failure
468+
// See https://github.com/opensearch-project/flow-framework/issues/870
469+
// Making sure the template got updated before reprovisioning again.
470+
// Quick fix to stop this from being flaky, needs a more permanent fix to synchronize template update with COMPLETED provisioning
471+
assertBusy(() -> {
472+
Response r = getWorkflow(client(), workflowId);
473+
assertEquals(RestStatus.OK.getStatus(), r.getStatusLine().getStatusCode());
474+
Template t = Template.parse(EntityUtils.toString(r.getEntity(), StandardCharsets.UTF_8));
475+
assertTrue(t.lastUpdatedTime().isAfter(preUpdateTime));
476+
}, 30, TimeUnit.SECONDS);
477+
466478
// Reprovision template to remove default ingest pipeline
467479
template = TestHelpers.createTemplateFromFile("registerremotemodel-ingestpipeline-updateindex.json");
468480
response = reprovisionWorkflow(client(), workflowId, template);

0 commit comments

Comments
 (0)