From b27daf36a6d91de8480eaacbf33c43ded37a8b64 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 24 Sep 2024 18:19:00 +0000 Subject: [PATCH] Quick fix for flaky integ test reprovisioning before template update (#880) Signed-off-by: Daniel Widdis (cherry picked from commit 22c994b1b4dc8872b295d19d85a554b332b6afb1) Signed-off-by: github-actions[bot] --- .../flowframework/rest/FlowFrameworkRestApiIT.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/test/java/org/opensearch/flowframework/rest/FlowFrameworkRestApiIT.java b/src/test/java/org/opensearch/flowframework/rest/FlowFrameworkRestApiIT.java index a2893172a..072a480dd 100644 --- a/src/test/java/org/opensearch/flowframework/rest/FlowFrameworkRestApiIT.java +++ b/src/test/java/org/opensearch/flowframework/rest/FlowFrameworkRestApiIT.java @@ -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)); @@ -463,6 +464,17 @@ public void testReprovisionWorkflow() throws Exception { Map 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);