@@ -446,6 +446,7 @@ public void testReprovisionWorkflow() throws Exception {
446
446
assertTrue (getPipelineResponse .pipelines ().get (0 ).getConfigAsMap ().toString ().contains (modelId ));
447
447
448
448
// Reprovision template to add index which uses default ingest pipeline
449
+ Instant preUpdateTime = Instant .now (); // Store a timestamp
449
450
template = TestHelpers .createTemplateFromFile ("registerremotemodel-ingestpipeline-createindex.json" );
450
451
response = reprovisionWorkflow (client (), workflowId , template );
451
452
assertEquals (RestStatus .CREATED , TestHelpers .restStatus (response ));
@@ -463,6 +464,17 @@ public void testReprovisionWorkflow() throws Exception {
463
464
Map <String , Object > indexSettings = getIndexSettingsAsMap (indexName );
464
465
assertEquals (pipelineId , indexSettings .get ("index.default_pipeline" ));
465
466
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
+
466
478
// Reprovision template to remove default ingest pipeline
467
479
template = TestHelpers .createTemplateFromFile ("registerremotemodel-ingestpipeline-updateindex.json" );
468
480
response = reprovisionWorkflow (client (), workflowId , template );
0 commit comments