Skip to content

Commit

Permalink
runtime-v2: fix entryPoint in effective yaml (#685)
Browse files Browse the repository at this point in the history
  • Loading branch information
brig authored Dec 7, 2022
1 parent 2565483 commit fc4cf2e
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 1 deletion.
5 changes: 5 additions & 0 deletions it/server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@
<artifactId>jackson-datatype-jsr310</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@
* =====
*/

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.walmartlabs.concord.ApiException;
import com.walmartlabs.concord.client.*;
import com.walmartlabs.concord.client.ProcessEntry.StatusEnum;
import com.walmartlabs.concord.common.ConfigurationUtils;
import com.walmartlabs.concord.common.IOUtils;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -289,4 +293,25 @@ public void testForkInitiatorFromApiKey() throws Exception {
assertLog(".*initiator: .*" + userAName.toLowerCase() + ".*", ab);
}
}

@Test
@SuppressWarnings("unchecked")
public void testEffectiveYaml() throws Exception {
byte[] payload = archive(ProcessIT.class.getResource("effectiveYaml").toURI());

ProcessApi processApi = new ProcessApi(getApiClient());
StartProcessResponse spr = start("test", payload);

// ---

ProcessEntry pir = waitForCompletion(processApi, spr.getInstanceId());
assertEquals(ProcessEntry.StatusEnum.FINISHED, pir.getStatus());

File effectiveYaml = processApi.downloadStateFile(pir.getInstanceId(), ".concord/effective.concord.yml");
assertNotNull(effectiveYaml);

Map<String, Object> m = new ObjectMapper(new YAMLFactory()).readValue(effectiveYaml, Map.class);
String entryPoint = (String) ConfigurationUtils.get(m, "configuration", "entryPoint");
assertEquals("test", entryPoint);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
configuration:
runtime: concord-v2

flows:
default:
- log: "default"

test:
- log: "test"
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public interface Options {
@Nullable
UUID parentInstanceId();

String entryPoint();

@Value.Default
@AllowNulls
default Map<String, Object> configuration() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void serialize(Options options, OutputStream out) throws Exception {

ProcessDefinition pd = ProcessDefinition.builder().from(delegate)
.configuration(ProcessDefinitionConfiguration.builder().from(delegate.configuration())
.entryPoint(options.entryPoint())
.arguments(arguments)
.build())
.flows(flows)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public Payload process(Chain chain, Payload payload) {

Options opts = Options.builder()
.instanceId(payload.getProcessKey().getInstanceId())
.entryPoint(payload.getHeader(Payload.ENTRY_POINT))
.parentInstanceId(payload.getHeader(Payload.PARENT_INSTANCE_ID))
.configuration(sanitizeConfiguration(payload.getHeader(Payload.CONFIGURATION, Collections.emptyMap())))
.activeProfiles(payload.getHeader(Payload.ACTIVE_PROFILES, Collections.emptyList()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public Payload process(Chain chain, Payload payload) {
}

cfg.put(Constants.Request.ENTRY_POINT_KEY, s);
payload = payload.putHeader(Payload.CONFIGURATION, cfg);
payload = payload.putHeader(Payload.CONFIGURATION, cfg)
.putHeader(Payload.ENTRY_POINT, s);

logManager.info(payload.getProcessKey(), "Using entry point: {}", s);

Expand Down

0 comments on commit fc4cf2e

Please sign in to comment.