Skip to content

Commit ad2f7b7

Browse files
committed
debug
1 parent d970559 commit ad2f7b7

3 files changed

Lines changed: 28 additions & 10 deletions

File tree

docker-compose.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ services:
1616
- EDGE_PORT=5001
1717
- KMS_PROVIDER=local-kms
1818
- LOCALSTACK_HOST=localstack
19+
- SERVICES=s3,sqs,kms
20+
- DEFAULT_REGION=us-east-1
21+
- AWS_DEFAULT_REGION=us-east-1
1922
healthcheck:
2023
test: awslocal s3api wait bucket-exists --bucket test-core-bucket
2124
&& awslocal s3api wait bucket-exists --bucket test-optout-bucket
@@ -67,7 +70,7 @@ services:
6770
&& wget --tries=1 --spider http://localhost:8082/ops/healthcheck || exit 1
6871
interval: 5s
6972
timeout: 10s
70-
retries: 6
73+
retries: 12
7174
networks:
7275
- e2e_default
7376

src/test/java/app/component/Optout.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,21 @@ private String getOptoutInternalApiKey() {
4141
* Triggers delta production on the optout service.
4242
* This reads from the SQS queue and produces delta files.
4343
* The endpoint is on port 8082 (optout port + 1).
44+
*
45+
* @return JsonNode with response, or null if job already running (409)
4446
*/
4547
public JsonNode triggerDeltaProduce() throws Exception {
4648
String deltaProduceUrl = getDeltaProducerBaseUrl() + "/optout/deltaproduce";
47-
String response = HttpClient.post(deltaProduceUrl, "", getOptoutInternalApiKey());
48-
return OBJECT_MAPPER.readTree(response);
49+
try {
50+
String response = HttpClient.post(deltaProduceUrl, "", getOptoutInternalApiKey());
51+
return OBJECT_MAPPER.readTree(response);
52+
} catch (HttpClient.HttpException e) {
53+
if (e.getCode() == 409) {
54+
// Job already running - this is fine, we'll just wait for it
55+
return null;
56+
}
57+
throw e;
58+
}
4959
}
5060

5161
/**
@@ -59,10 +69,12 @@ public JsonNode getDeltaProduceStatus() throws Exception {
5969

6070
/**
6171
* Triggers delta production and waits for it to complete.
72+
* If a job is already running, waits for that job instead.
6273
* @param maxWaitSeconds Maximum time to wait for completion
6374
* @return true if delta production completed successfully
6475
*/
6576
public boolean triggerDeltaProduceAndWait(int maxWaitSeconds) throws Exception {
77+
// Try to trigger - will return null if job already running (409)
6678
triggerDeltaProduce();
6779

6880
long startTime = System.currentTimeMillis();
@@ -77,6 +89,11 @@ public boolean triggerDeltaProduceAndWait(int maxWaitSeconds) throws Exception {
7789
if ("COMPLETED".equals(state) || "FAILED".equals(state)) {
7890
return "COMPLETED".equals(state);
7991
}
92+
93+
// If idle (no job), try to trigger again
94+
if ("idle".equalsIgnoreCase(state) || state.isEmpty()) {
95+
triggerDeltaProduce();
96+
}
8097
}
8198

8299
return false; // Timed out

src/test/java/suite/optout/OptoutTest.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,15 @@ public void testV2LogoutWithV2IdentityMap(String label, Operator operator, Strin
9595
public void triggerDeltaProduction() throws Exception {
9696
LOGGER.info("Triggering delta production on optout service");
9797

98-
// Trigger delta production
99-
JsonNode response = optoutService.triggerDeltaProduce();
100-
LOGGER.info("Delta production triggered: {}", response);
101-
102-
// Wait for completion
98+
// Trigger delta production and wait for completion
99+
// This handles 409 (job already running) gracefully
103100
boolean success = optoutService.triggerDeltaProduceAndWait(DELTA_PRODUCE_WAIT_SECONDS);
104-
assertThat(success).as("Delta production should complete successfully").isTrue();
105101

106102
// Get final status
107103
JsonNode status = optoutService.getDeltaProduceStatus();
108-
LOGGER.info("Delta production completed: {}", status);
104+
LOGGER.info("Delta production completed with status: {}", status);
105+
106+
assertThat(success).as("Delta production should complete successfully").isTrue();
109107
}
110108

111109
@Order(5)

0 commit comments

Comments
 (0)