Skip to content

Commit

Permalink
Rename param, add comments
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Widdis <[email protected]>
  • Loading branch information
dbwiddis committed Mar 8, 2024
1 parent c997281 commit c600d9e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,14 @@ public void updateTemplateInGlobalContext(String documentId, Template template,
* @param documentId the document Id
* @param template the use-case template
* @param listener action listener
* @param force if set true, ignores the requirement that the provisioning is not started
* @param ignoreNotStartedCheck if set true, ignores the requirement that the provisioning is not started
*/
public void updateTemplateInGlobalContext(String documentId, Template template, ActionListener<IndexResponse> listener, boolean force) {
public void updateTemplateInGlobalContext(
String documentId,
Template template,
ActionListener<IndexResponse> listener,
boolean ignoreNotStartedCheck
) {
if (!doesIndexExist(GLOBAL_CONTEXT_INDEX)) {
String errorMessage = "Failed to update template for workflow_id : " + documentId + ", global_context index does not exist.";
logger.error(errorMessage);
Expand All @@ -415,7 +420,7 @@ public void updateTemplateInGlobalContext(String documentId, Template template,
doesTemplateExist(documentId, templateExists -> {
if (templateExists) {
isWorkflowNotStarted(documentId, workflowIsNotStarted -> {
if (workflowIsNotStarted || force) {
if (workflowIsNotStarted || ignoreNotStartedCheck) {
IndexRequest request = new IndexRequest(GLOBAL_CONTEXT_INDEX).id(documentId);
try (
XContentBuilder builder = XContentFactory.jsonBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,29 +102,29 @@ public static ClusterType parse(String value) {

@SuppressWarnings("unchecked")
public void testBackwardsCompatibility() throws Exception {
// This iteration of nodes is only to get plugins installed on each node. We don't currently use its functionality but in case we
// ever need version-based dependencies in future BWC tests it will be needed. It's directly copied from similar implementations
// in other plugins.
String uri = getUri();
Map<String, Map<String, Object>> responseMap = (Map<String, Map<String, Object>>) getAsMap(uri).get("nodes");
for (Map<String, Object> response : responseMap.values()) {
List<Map<String, Object>> plugins = (List<Map<String, Object>>) response.get("plugins");
Set<Object> pluginNames = plugins.stream().map(map -> map.get("name")).collect(Collectors.toSet());
assertTrue(pluginNames.contains("opensearch-flow-framework"));
String workflowId = createNoopTemplate();
Template t = getTemplate(workflowId);
switch (CLUSTER_TYPE) {
case OLD:
assertTrue(pluginNames.contains("opensearch-flow-framework"));
// mapping for 2.12 does not include time stamps
assertNull(t.createdTime());
assertNull(t.lastUpdatedTime());
assertNull(t.lastProvisionedTime());
break;
case MIXED:
assertTrue(pluginNames.contains("opensearch-flow-framework"));
// Time stamps may or may not be null depending on whether index has been accessed by new version node
// So just test that the template parses
assertNull(t.lastProvisionedTime());
break;
case UPGRADED:
assertTrue(pluginNames.contains("opensearch-flow-framework"));
// mapping for 2.13+ includes time stamps
assertNotNull(t.createdTime());
assertEquals(t.createdTime(), t.lastUpdatedTime());
Expand Down

0 comments on commit c600d9e

Please sign in to comment.