Skip to content

Commit

Permalink
add retry for creating connector
Browse files Browse the repository at this point in the history
Signed-off-by: Hailong Cui <[email protected]>
  • Loading branch information
Hailong-am committed Jun 11, 2024
1 parent bcaee80 commit 4aac076
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -962,10 +962,18 @@ public void waitForTask(String taskId, MLTaskState targetState) throws Interrupt
}

public String registerConnector(String createConnectorInput) throws IOException, InterruptedException {
Response response = RestMLRemoteInferenceIT.createConnector(createConnectorInput);
Response response;
try {
response = RestMLRemoteInferenceIT.createConnector(createConnectorInput);
} catch (Throwable throwable) {
// Add retry for `The ML encryption master key has not been initialized yet. Please retry after waiting for 10 seconds.`
TimeUnit.SECONDS.sleep(10);
response = RestMLRemoteInferenceIT.createConnector(createConnectorInput);
}
Map responseMap = parseResponseToMap(response);
String connectorId = (String) responseMap.get("connector_id");
return connectorId;

}

public String registerRemoteModel(String createConnectorInput, String modelName, boolean deploy) throws IOException,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ public void tearDown() throws Exception {
}

public void testConnectorToolInFlowAgent_WrongAction() throws IOException, ParseException {
if (AWS_ACCESS_KEY_ID == null || AWS_SECRET_ACCESS_KEY == null || AWS_SESSION_TOKEN == null) {
return;
}
String registerAgentRequestBody = "{\n"
+ " \"name\": \"Test agent with connector tool\",\n"
+ " \"type\": \"flow\",\n"
Expand All @@ -109,6 +112,9 @@ public void testConnectorToolInFlowAgent_WrongAction() throws IOException, Parse
}

public void testConnectorToolInFlowAgent() throws IOException, ParseException {
if (AWS_ACCESS_KEY_ID == null || AWS_SECRET_ACCESS_KEY == null || AWS_SESSION_TOKEN == null) {
return;
}
String registerAgentRequestBody = "{\n"
+ " \"name\": \"Test agent with connector tool\",\n"
+ " \"type\": \"flow\",\n"
Expand Down

0 comments on commit 4aac076

Please sign in to comment.