Skip to content

Commit c8f7d0b

Browse files
committed
ci: updating contract tests to use list of synchronizers
1 parent bfde41d commit c8f7d0b

3 files changed

Lines changed: 25 additions & 52 deletions

File tree

lib/sdk/server/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ run-contract-tests:
3232
@curl -s https://raw.githubusercontent.com/launchdarkly/sdk-test-harness/v2/downloader/run.sh \
3333
| VERSION=v2 PARAMS="-url http://localhost:$(TEST_SERVICE_PORT) -debug -skip-from=$(SUPPRESSION_FILE) $(TEST_HARNESS_PARAMS)" sh
3434
@echo "Running SDK contract test v3.0.0-alpha.1..."
35-
@curl -s https://raw.githubusercontent.com/launchdarkly/sdk-test-harness/v3.0.0-alpha.1/downloader/run.sh \
36-
| VERSION=v3.0.0-alpha.1 PARAMS="-url http://localhost:$(TEST_SERVICE_PORT) -debug -stop-service-at-end -skip-from=$(SUPPRESSION_FILE_FDV2) $(TEST_HARNESS_PARAMS)" sh
35+
@curl -s https://raw.githubusercontent.com/launchdarkly/sdk-test-harness/v3.0.0-alpha.3/downloader/run.sh \
36+
| VERSION=v3.0.0-alpha.3 PARAMS="-url http://localhost:$(TEST_SERVICE_PORT) -debug -stop-service-at-end -skip-from=$(SUPPRESSION_FILE_FDV2) $(TEST_HARNESS_PARAMS)" sh
3737

3838
contract-tests: build-contract-tests start-contract-test-service-bg run-contract-tests
3939

lib/sdk/server/contract-tests/service/src/main/java/sdktest/Representations.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ public static class SdkConfigDataSystemParams {
133133
SdkConfigDataStoreParams store;
134134
Integer storeMode;
135135
SdkConfigDataInitializerParams[] initializers;
136-
SdkConfigSynchronizersParams synchronizers;
136+
/** List of synchronizers (matches servicedef DataSystem.Synchronizers). */
137+
SdkConfigSynchronizerParams[] synchronizers;
137138
String payloadFilter;
138139
}
139140

@@ -161,11 +162,6 @@ public static class SdkConfigDataInitializerParams {
161162
SdkConfigPollingParams polling;
162163
}
163164

164-
public static class SdkConfigSynchronizersParams {
165-
SdkConfigSynchronizerParams primary;
166-
SdkConfigSynchronizerParams secondary;
167-
}
168-
169165
public static class SdkConfigSynchronizerParams {
170166
SdkConfigStreamingParams streaming;
171167
SdkConfigPollingParams polling;

lib/sdk/server/contract-tests/service/src/main/java/sdktest/SdkClientEntity.java

Lines changed: 21 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
import sdktest.Representations.SdkConfigParams;
7171
import sdktest.Representations.SdkConfigDataSystemParams;
7272
import sdktest.Representations.SdkConfigDataInitializerParams;
73-
import sdktest.Representations.SdkConfigSynchronizersParams;
7473
import sdktest.Representations.SdkConfigSynchronizerParams;
7574
import sdktest.Representations.SdkConfigPollingParams;
7675
import sdktest.Representations.SdkConfigStreamingParams;
@@ -542,34 +541,23 @@ private LDConfig buildSdkConfig(SdkConfigParams params, String tag) {
542541
}
543542
}
544543

545-
// Configure synchronizers
546-
if (params.dataSystem.synchronizers != null) {
547-
List<DataSourceBuilder<Synchronizer>> synchronizers = new ArrayList<>();
548544

549-
// Primary synchronizer
550-
if (params.dataSystem.synchronizers.primary != null) {
551-
DataSourceBuilder<Synchronizer> primary = createSynchronizer(params.dataSystem.synchronizers.primary, params.dataSystem.payloadFilter);
552-
if (primary != null) {
553-
synchronizers.add(primary);
545+
if (params.dataSystem.synchronizers != null && params.dataSystem.synchronizers.length > 0) {
546+
List<DataSourceBuilder<Synchronizer>> synchronizerBuilders = new ArrayList<>();
547+
for (SdkConfigSynchronizerParams syncParams : params.dataSystem.synchronizers) {
548+
DataSourceBuilder<Synchronizer> sync = createSynchronizer(syncParams, params.dataSystem.payloadFilter);
549+
if (sync != null) {
550+
synchronizerBuilders.add(sync);
554551
}
555552
}
556-
557-
// Secondary synchronizer (optional)
558-
if (params.dataSystem.synchronizers.secondary != null) {
559-
DataSourceBuilder<Synchronizer> secondary = createSynchronizer(params.dataSystem.synchronizers.secondary, params.dataSystem.payloadFilter);
560-
if (secondary != null) {
561-
synchronizers.add(secondary);
562-
}
563-
}
564-
565-
if (!synchronizers.isEmpty()) {
566-
dataSystemBuilder.synchronizers(synchronizers.toArray(new DataSourceBuilder[0]));
553+
if (!synchronizerBuilders.isEmpty()) {
554+
dataSystemBuilder.synchronizers(synchronizerBuilders.toArray(new DataSourceBuilder[0]));
567555
}
568556
}
569557

570-
// Configure FDv1 fallback synchronizer
558+
// Configure FDv1 fallback synchronizer (pick first polling, else first synchronizer)
571559
SdkConfigSynchronizerParams fallbackSynchronizer =
572-
selectFallbackSynchronizer(params.dataSystem);
560+
selectFallbackSynchronizer(params.dataSystem.synchronizers);
573561
if (fallbackSynchronizer != null) {
574562
// Set global polling endpoints if the fallback synchronizer has polling with custom base URI
575563
if (fallbackSynchronizer.polling != null &&
@@ -624,32 +612,21 @@ private DataSourceBuilder<Synchronizer> createSynchronizer(
624612

625613
/**
626614
* Selects the best synchronizer configuration to use for FDv1 fallback.
627-
* Prefers polling synchronizers, falls back to primary synchronizer.
615+
* Prefers the first polling synchronizer in the list, otherwise the first synchronizer.
628616
*/
629617
private static SdkConfigSynchronizerParams selectFallbackSynchronizer(
630-
SdkConfigDataSystemParams dataSystemParams) {
631-
632-
// Prefer secondary polling synchronizer
633-
if (dataSystemParams.synchronizers != null &&
634-
dataSystemParams.synchronizers.secondary != null &&
635-
dataSystemParams.synchronizers.secondary.polling != null) {
636-
return dataSystemParams.synchronizers.secondary;
637-
}
638-
639-
// Fall back to primary polling synchronizer
640-
if (dataSystemParams.synchronizers != null &&
641-
dataSystemParams.synchronizers.primary != null &&
642-
dataSystemParams.synchronizers.primary.polling != null) {
643-
return dataSystemParams.synchronizers.primary;
618+
SdkConfigSynchronizerParams[] synchronizers) {
619+
if (synchronizers == null || synchronizers.length == 0) {
620+
return null;
644621
}
645-
646-
// Fall back to primary synchronizer (even if streaming)
647-
if (dataSystemParams.synchronizers != null &&
648-
dataSystemParams.synchronizers.primary != null) {
649-
return dataSystemParams.synchronizers.primary;
622+
// Prefer first polling synchronizer (FDv1 fallback is polling-based)
623+
for (SdkConfigSynchronizerParams sync : synchronizers) {
624+
if (sync.polling != null) {
625+
return sync;
626+
}
650627
}
651-
652-
return null;
628+
// Otherwise use first synchronizer (streaming; FDv1 will use default polling config)
629+
return synchronizers[0];
653630
}
654631

655632
/**

0 commit comments

Comments
 (0)