From de92abf12e0703cbed0598c07a5ff6c3fec60387 Mon Sep 17 00:00:00 2001 From: moodiRealist <40175386+moodiRealist@users.noreply.github.com> Date: Tue, 12 Dec 2023 08:45:26 -0500 Subject: [PATCH] [DATAGO-64298] rename correlationId to commandCorrelationId in missed spots --- .../ep/event/management/agent/command/CommandManager.java | 3 ++- .../maas/ep/event/management/agent/constants/Command.java | 8 ++++++++ .../management/agent/processor/CommandLogsProcessor.java | 3 ++- .../management/agent/publisher/CommandLogsPublisher.java | 3 ++- .../management/agent/publisher/CommandPublisher.java | 5 +++-- .../management/agent/subscriber/SolaceMessageHandler.java | 3 ++- .../agent/commandManager/CommandManagerTests.java | 3 ++- .../agent/plugin/command/model/CommandRequest.java | 2 +- .../terraform/manager/TerraformLogProcessingService.java | 2 +- .../agent/plugin/terraform/manager/TerraformManager.java | 4 ++-- .../agent/plugin/terraform/TerraformCommandIT.java | 2 +- .../plugin/terraform/real/TerraformClientRealTests.java | 4 ++-- 12 files changed, 28 insertions(+), 14 deletions(-) create mode 100644 service/application/src/main/java/com/solace/maas/ep/event/management/agent/constants/Command.java diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/command/CommandManager.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/command/CommandManager.java index 84a7f3acd..8d111c927 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/command/CommandManager.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/command/CommandManager.java @@ -21,6 +21,7 @@ import java.util.List; import java.util.Map; +import static com.solace.maas.ep.event.management.agent.constants.Command.COMMAND_CORRELATION_ID; import static com.solace.maas.ep.event.management.agent.plugin.terraform.manager.TerraformManager.LOG_LEVEL_ERROR; import static com.solace.maas.ep.event.management.agent.plugin.terraform.manager.TerraformManager.setCommandError; @@ -88,7 +89,7 @@ private void sendResponse(CommandMessage request) { Map topicVars = Map.of( "orgId", request.getOrgId(), "runtimeAgentId", eventPortalProperties.getRuntimeAgentId(), - "correlationId", request.getCommandCorrelationId() + COMMAND_CORRELATION_ID, request.getCommandCorrelationId() ); commandPublisher.sendCommandResponse(request, topicVars); } diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/constants/Command.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/constants/Command.java new file mode 100644 index 000000000..9a94154d3 --- /dev/null +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/constants/Command.java @@ -0,0 +1,8 @@ +package com.solace.maas.ep.event.management.agent.constants; + +import com.solace.maas.ep.event.management.agent.plugin.jacoco.ExcludeFromJacocoGeneratedReport; + +@ExcludeFromJacocoGeneratedReport +public class Command { + public static final String COMMAND_CORRELATION_ID = "commandCorrelationId"; +} diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/CommandLogsProcessor.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/CommandLogsProcessor.java index f7e3ec960..0e45b85e5 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/CommandLogsProcessor.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/processor/CommandLogsProcessor.java @@ -3,6 +3,7 @@ import ch.qos.logback.classic.spi.ILoggingEvent; import com.solace.maas.ep.common.messages.CommandLogMessage; import com.solace.maas.ep.event.management.agent.config.eventPortal.EventPortalProperties; +import com.solace.maas.ep.event.management.agent.constants.Command; import com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants; import com.solace.maas.ep.event.management.agent.publisher.CommandLogsPublisher; import lombok.extern.slf4j.Slf4j; @@ -51,7 +52,7 @@ public void process(Exchange exchange) throws Exception { topicDetails.put("orgId", orgId); topicDetails.put("runtimeAgentId", runtimeAgentId); topicDetails.put("messagingServiceId", messagingServiceId); - topicDetails.put("commandCorrelationId", commandCorrelationId); + topicDetails.put(Command.COMMAND_CORRELATION_ID, commandCorrelationId); logDataPublisher.sendCommandLogData(logDataMessage, topicDetails); } diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/CommandLogsPublisher.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/CommandLogsPublisher.java index aa035a763..c4cfd3f60 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/CommandLogsPublisher.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/CommandLogsPublisher.java @@ -2,6 +2,7 @@ import com.solace.maas.ep.common.messages.CommandLogMessage; import com.solace.maas.ep.event.management.agent.config.SolaceConfiguration; +import com.solace.maas.ep.event.management.agent.constants.Command; import com.solace.maas.ep.event.management.agent.plugin.publisher.SolacePublisher; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -26,7 +27,7 @@ public CommandLogsPublisher(SolacePublisher solacePublisher, SolaceConfiguration public void sendCommandLogData(CommandLogMessage message, Map topicDetails) { String topicString = solaceConfiguration.getTopicPrefix() + - String.format("commandLogs/v1/%s", topicDetails.get("commandCorrelationId")); + String.format("commandLogs/v1/%s", topicDetails.get(Command.COMMAND_CORRELATION_ID)); solacePublisher.publish(message, topicString); } diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/CommandPublisher.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/CommandPublisher.java index 6fade9fba..7aa5126db 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/CommandPublisher.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/CommandPublisher.java @@ -1,6 +1,7 @@ package com.solace.maas.ep.event.management.agent.publisher; import com.solace.maas.ep.event.management.agent.config.SolaceConfiguration; +import com.solace.maas.ep.event.management.agent.constants.Command; import com.solace.maas.ep.event.management.agent.plugin.mop.MOPMessage; import com.solace.maas.ep.event.management.agent.plugin.publisher.SolacePublisher; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -24,7 +25,7 @@ public CommandPublisher(SolacePublisher solacePublisher, SolaceConfiguration sol * Sends the command response to EP. *

* The topic for command response: - * sc/ep/runtime/{orgId}/{runtimeAgentId}/commandResponse/v1/{correlationId} + * sc/ep/runtime/{orgId}/{runtimeAgentId}/commandResponse/v1/{commandCorrelationId} */ public void sendCommandResponse(MOPMessage message, Map topicDetails) { @@ -32,7 +33,7 @@ public void sendCommandResponse(MOPMessage message, Map topicDet String topicString = String.format("%scommandResponse/v1/%s", solaceConfiguration.getTopicPrefix(), - topicDetails.get("correlationId")); + topicDetails.get(Command.COMMAND_CORRELATION_ID)); solacePublisher.publish(message, topicString); } diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/SolaceMessageHandler.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/SolaceMessageHandler.java index 24713d85f..e0eda299f 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/SolaceMessageHandler.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/SolaceMessageHandler.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.module.SimpleModule; +import com.solace.maas.ep.event.management.agent.constants.Command; import com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants; import com.solace.maas.ep.event.management.agent.plugin.mop.EnumDeserializer; import com.solace.maas.ep.event.management.agent.plugin.mop.MOPConstants; @@ -97,7 +98,7 @@ private static void setupMDC(String messageAsString, String receivedClassName) t } if (commandClassNames.contains(receivedClassName)) { - MDC.put(RouteConstants.COMMAND_CORRELATION_ID, map.get("correlationId")); + MDC.put(RouteConstants.COMMAND_CORRELATION_ID, map.get(Command.COMMAND_CORRELATION_ID)); MDC.put(RouteConstants.MESSAGING_SERVICE_ID, map.get("serviceId")); } } diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/commandManager/CommandManagerTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/commandManager/CommandManagerTests.java index 5abe29890..68d003ba6 100644 --- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/commandManager/CommandManagerTests.java +++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/commandManager/CommandManagerTests.java @@ -24,6 +24,7 @@ import java.util.List; import java.util.Map; +import static com.solace.maas.ep.event.management.agent.constants.Command.COMMAND_CORRELATION_ID; import static com.solace.maas.ep.event.management.agent.plugin.mop.MOPMessageType.generic; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doNothing; @@ -101,6 +102,6 @@ public void testCommandManager() { Map topicVars = topicArgCaptor.getValue(); assert topicVars.get("orgId").equals(eventPortalProperties.getOrganizationId()); assert topicVars.get("runtimeAgentId").equals(eventPortalProperties.getRuntimeAgentId()); - assert topicVars.get("correlationId").equals(message.getCommandCorrelationId()); + assert topicVars.get(COMMAND_CORRELATION_ID).equals(message.getCommandCorrelationId()); } } diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/command/model/CommandRequest.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/command/model/CommandRequest.java index f4c62c646..46ffa697f 100644 --- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/command/model/CommandRequest.java +++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/command/model/CommandRequest.java @@ -12,7 +12,7 @@ @NoArgsConstructor @AllArgsConstructor public class CommandRequest { - private String correlationId; + private String commandCorrelationId; private String context; private String serviceId; private List commandBundles; diff --git a/service/terraform-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/terraform/manager/TerraformLogProcessingService.java b/service/terraform-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/terraform/manager/TerraformLogProcessingService.java index 2805fa177..50885bad4 100644 --- a/service/terraform-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/terraform/manager/TerraformLogProcessingService.java +++ b/service/terraform-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/terraform/manager/TerraformLogProcessingService.java @@ -56,7 +56,7 @@ public void saveLogToFile(CommandRequest request, List logs) throws IOEx } Path out = Files.createTempFile(logPath, System.currentTimeMillis() + "-" - + request.getCorrelationId() + "-job", ".log"); + + request.getCommandCorrelationId() + "-job", ".log"); Files.write(out, logs, Charset.defaultCharset()); } diff --git a/service/terraform-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/terraform/manager/TerraformManager.java b/service/terraform-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/terraform/manager/TerraformManager.java index 53c6c3fc0..93d35c31b 100644 --- a/service/terraform-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/terraform/manager/TerraformManager.java +++ b/service/terraform-plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/terraform/manager/TerraformManager.java @@ -43,11 +43,11 @@ public TerraformManager(TerraformLogProcessingService terraformLogProcessingServ public void execute(CommandRequest request, Command command, Map envVars) { - MDC.put(RouteConstants.COMMAND_CORRELATION_ID, request.getCorrelationId()); + MDC.put(RouteConstants.COMMAND_CORRELATION_ID, request.getCommandCorrelationId()); MDC.put(RouteConstants.MESSAGING_SERVICE_ID, request.getServiceId()); log.debug("Executing command {} for serviceId {} correlationId {} context {}", command.getCommand(), request.getServiceId(), - request.getCorrelationId(), request.getContext()); + request.getCommandCorrelationId(), request.getContext()); try (TerraformClient terraformClient = terraformClientFactory.createClient()) { diff --git a/service/terraform-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/terraform/TerraformCommandIT.java b/service/terraform-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/terraform/TerraformCommandIT.java index bf26088dc..0d7276f11 100644 --- a/service/terraform-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/terraform/TerraformCommandIT.java +++ b/service/terraform-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/terraform/TerraformCommandIT.java @@ -329,7 +329,7 @@ private static CommandRequest generateCommandRequest(Command commandRequest) { .exitOnFailure(false) .commands(List.of(commandRequest)) .build())) - .correlationId("234") + .commandCorrelationId("234") .context("app123") .serviceId("ms1234") .build(); diff --git a/service/terraform-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/terraform/real/TerraformClientRealTests.java b/service/terraform-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/terraform/real/TerraformClientRealTests.java index 04ca884f0..f46ebfc98 100644 --- a/service/terraform-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/terraform/real/TerraformClientRealTests.java +++ b/service/terraform-plugin/src/test/java/com/solace/maas/ep/event/management/agent/plugin/terraform/real/TerraformClientRealTests.java @@ -112,7 +112,7 @@ public void importResource() { .build(); CommandRequest terraformRequest = CommandRequest.builder() - .correlationId("abc123") + .commandCorrelationId("abc123") .context("app123-consumer") .commandBundles(List.of( CommandBundle.builder() @@ -156,7 +156,7 @@ private List executeTerraformCommand(String hclFileName, String t .build())) .context(context) .serviceId("abc123") - .correlationId("myCorrelationId") + .commandCorrelationId("myCorrelationId") .build(); for (Command command : terraformRequest.getCommandBundles().get(0).getCommands()) {