Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
abbc191
feat: wire FDv2 dataSystem into server contract tests
beekld Jun 4, 2026
0469d55
test: add v3 contract test harness suppression file
beekld Jun 4, 2026
3e465ab
ci: add v3 contract test harness job for FDv2
beekld Jun 4, 2026
6074215
ci: add curl-backend variant of v3 contract test harness job
beekld Jun 4, 2026
a6ffcae
feat: derive FDv1 fallback synchronizer from harness synchronizers
beekld Jun 4, 2026
07d752d
merge: bring in FDv1 fallback TTL changes from #545
beekld Jun 8, 2026
3ff8d63
merge: pick up retry_after removal from #545
beekld Jun 9, 2026
2d7fe90
merge: pick up FDv1 status translation from #540
beekld Jun 9, 2026
fe0cd3d
merge: pick up OpenSSL bump from #545
beekld Jun 11, 2026
ecb1e0f
merge: pick up #539 squash from #545
beekld Jun 11, 2026
af98d9f
merge: pick up FDv1 source lifecycle fix from #545
beekld Jun 11, 2026
7bc416b
merge: pick up FDv1 adapter status sink fix from #545
beekld Jun 11, 2026
f7b69c6
merge: pick up shared_ptr/init-error fixes from #545
beekld Jun 12, 2026
04e5f6a
merge: pick up #550 from #545
beekld Jun 12, 2026
7575233
merge: pick up intentCode none fix from #545
beekld Jun 12, 2026
83fe01b
merge: pick up main after #540 squash from #545
beekld Jun 15, 2026
d908a20
merge: pick up main after #555 squash from #545
beekld Jun 16, 2026
c3588e8
merge: pick up DisableFDv1Fallback doc fix from #545
beekld Jun 16, 2026
4566c7c
merge: pick up #552 from #545
beekld Jun 16, 2026
f2cb722
merge: pick up FDv2Builder::Custom() refactor from #545
beekld Jun 16, 2026
440ee68
test: suppress FDv1 fallback directive halt scenario (tracks SDK-2527)
beekld Jun 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,27 @@ jobs:
test_service_port: ${{ env.TEST_SERVICE_PORT }}
token: ${{ secrets.GITHUB_TOKEN }}

contract-tests-fdv2:
runs-on: ubuntu-22.04
env:
TEST_SERVICE_PORT: 8123
TEST_SERVICE_BINARY: ./build/contract-tests/server-contract-tests/server-tests
SUPPRESSION_FILE: contract-tests/server-contract-tests/test-suppressions-fdv2.txt
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955
- uses: ./.github/actions/ci
with:
cmake_target: server-tests
run_tests: false
- name: 'Launch test service as background task'
run: $TEST_SERVICE_BINARY $TEST_SERVICE_PORT 2>&1 &
- name: 'Run v3 SDK test harness'
run: |
curl -s https://raw.githubusercontent.com/launchdarkly/sdk-test-harness/v3.0.0-alpha.3/downloader/run.sh \
| VERSION=v3.0.0-alpha.3 \
PARAMS="-url http://localhost:$TEST_SERVICE_PORT -debug -stop-service-at-end -skip-from=$SUPPRESSION_FILE" \
sh

contract-tests-curl:
runs-on: ubuntu-22.04
env:
Expand All @@ -59,6 +80,28 @@ jobs:
test_service_port: ${{ env.TEST_SERVICE_PORT }}
token: ${{ secrets.GITHUB_TOKEN }}

contract-tests-fdv2-curl:
runs-on: ubuntu-22.04
env:
TEST_SERVICE_PORT: 8123
TEST_SERVICE_BINARY: ./build/contract-tests/server-contract-tests/server-tests
SUPPRESSION_FILE: contract-tests/server-contract-tests/test-suppressions-fdv2.txt
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955
- uses: ./.github/actions/ci
with:
cmake_target: server-tests
run_tests: false
use_curl: true
- name: 'Launch test service as background task'
run: $TEST_SERVICE_BINARY $TEST_SERVICE_PORT 2>&1 &
- name: 'Run v3 SDK test harness'
run: |
curl -s https://raw.githubusercontent.com/launchdarkly/sdk-test-harness/v3.0.0-alpha.3/downloader/run.sh \
| VERSION=v3.0.0-alpha.3 \
PARAMS="-url http://localhost:$TEST_SERVICE_PORT -debug -stop-service-at-end -skip-from=$SUPPRESSION_FILE" \
sh

build-test-server:
runs-on: ubuntu-22.04
steps:
Expand Down
42 changes: 36 additions & 6 deletions contract-tests/data-model/include/data_model/data_model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(ConfigTags,
applicationId,
applicationVersion);

enum class HookStage {
BeforeEvaluation,
AfterEvaluation,
AfterTrack
};
enum class HookStage { BeforeEvaluation, AfterEvaluation, AfterTrack };

NLOHMANN_JSON_SERIALIZE_ENUM(HookStage,
{{HookStage::BeforeEvaluation, "beforeEvaluation"},
Expand All @@ -127,7 +123,10 @@ NLOHMANN_JSON_SERIALIZE_ENUM(HookStage,
struct ConfigHookInstance {
std::string name;
std::string callbackUri;
std::optional<std::unordered_map<std::string, std::unordered_map<std::string, nlohmann::json>>> data;
std::optional<
std::unordered_map<std::string,
std::unordered_map<std::string, nlohmann::json>>>
data;
std::optional<std::unordered_map<std::string, std::string>> errors;
};

Expand All @@ -150,12 +149,42 @@ struct ConfigWrapper {

NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(ConfigWrapper, name, version);

struct ConfigDataSynchronizerParams {
std::optional<ConfigStreamingParams> streaming;
std::optional<ConfigPollingParams> polling;
};

NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(ConfigDataSynchronizerParams,
streaming,
polling);

struct ConfigDataInitializerParams {
std::optional<ConfigPollingParams> polling;
};

NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(ConfigDataInitializerParams,
polling);

struct ConfigDataSystemParams {
std::optional<std::vector<ConfigDataInitializerParams>> initializers;
std::optional<std::vector<ConfigDataSynchronizerParams>> synchronizers;
std::optional<ConfigPollingParams> fdv1Fallback;
std::optional<std::string> payloadFilter;
};

NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(ConfigDataSystemParams,
initializers,
synchronizers,
fdv1Fallback,
payloadFilter);

struct ConfigParams {
std::string credential;
std::optional<uint32_t> startWaitTimeMs;
std::optional<bool> initCanFail;
std::optional<ConfigStreamingParams> streaming;
std::optional<ConfigPollingParams> polling;
std::optional<ConfigDataSystemParams> dataSystem;
std::optional<ConfigEventParams> events;
std::optional<ConfigServiceEndpointsParams> serviceEndpoints;
std::optional<ConfigClientSideParams> clientSide;
Expand All @@ -172,6 +201,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(ConfigParams,
initCanFail,
streaming,
polling,
dataSystem,
events,
serviceEndpoints,
clientSide,
Expand Down
187 changes: 152 additions & 35 deletions contract-tests/server-contract-tests/src/entity_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,116 @@
using launchdarkly::LogLevel;
using namespace launchdarkly::server_side;

EntityManager::EntityManager(boost::asio::any_io_executor executor,
launchdarkly::Logger& logger)
: counter_{0}, executor_{std::move(executor)}, logger_{logger} {}

std::optional<std::string> EntityManager::create(ConfigParams const& in) {
std::string id = std::to_string(counter_++);

auto config_builder = ConfigBuilder(in.credential);

// The contract test service sets endpoints in a way that is disallowed
// for users. Specifically, it may set just 1 of the 3 endpoints, whereas
// we require all 3 to be set.
//
// To avoid that error being detected, we must configure the Endpoints
// builder with the 3 default URLs, which we can fetch by just calling Build
// on a new builder. That way when the contract tests set just 1 URL,
// the others have already been "set" so no error occurs.
auto const default_endpoints =
*config::builders::EndpointsBuilder().Build();
namespace {

config::builders::DataSystemBuilder::FDv2 BuildFDv2(
ConfigDataSystemParams const& cfg,
config::builders::EndpointsBuilder* endpoints) {
auto fdv2 = config::builders::DataSystemBuilder::FDv2::Custom();

if (cfg.synchronizers) {
for (auto const& sync : *cfg.synchronizers) {
if (sync.streaming) {
auto s = decltype(fdv2)::Streaming();
if (sync.streaming->baseUri) {
s.BaseUrl(*sync.streaming->baseUri);
}
if (sync.streaming->initialRetryDelayMs) {
s.InitialReconnectDelay(std::chrono::milliseconds(
*sync.streaming->initialRetryDelayMs));
}
if (cfg.payloadFilter) {
s.Filter(*cfg.payloadFilter);
}
fdv2.Synchronizer(std::move(s));
} else if (sync.polling) {
auto p = decltype(fdv2)::Polling();
if (sync.polling->baseUri) {
p.BaseUrl(*sync.polling->baseUri);
}
if (sync.polling->pollIntervalMs) {
p.PollInterval(
std::chrono::duration_cast<std::chrono::seconds>(
std::chrono::milliseconds(
*sync.polling->pollIntervalMs)));
}
if (cfg.payloadFilter) {
p.Filter(*cfg.payloadFilter);
}
fdv2.Synchronizer(std::move(p));
}
}
}

auto& endpoints =
config_builder.ServiceEndpoints()
.EventsBaseUrl(default_endpoints.EventsBaseUrl())
.PollingBaseUrl(default_endpoints.PollingBaseUrl())
.StreamingBaseUrl(default_endpoints.StreamingBaseUrl());
if (cfg.initializers) {
for (auto const& init : *cfg.initializers) {
if (init.polling) {
auto p = decltype(fdv2)::Polling();
if (init.polling->baseUri) {
p.BaseUrl(*init.polling->baseUri);
}
if (cfg.payloadFilter) {
p.Filter(*cfg.payloadFilter);
}
fdv2.Initializer(std::move(p));
}
}
}

if (in.serviceEndpoints) {
if (in.serviceEndpoints->streaming) {
endpoints.StreamingBaseUrl(*in.serviceEndpoints->streaming);
using FDv2Builder = config::builders::DataSystemBuilder::FDv2;
if (cfg.fdv1Fallback) {
if (cfg.fdv1Fallback->baseUri) {
endpoints->PollingBaseUrl(*cfg.fdv1Fallback->baseUri);
}
if (in.serviceEndpoints->polling) {
endpoints.PollingBaseUrl(*in.serviceEndpoints->polling);
FDv2Builder::FDv1Polling p;
if (cfg.fdv1Fallback->pollIntervalMs) {
p.PollInterval(std::chrono::duration_cast<std::chrono::seconds>(
std::chrono::milliseconds(*cfg.fdv1Fallback->pollIntervalMs)));
}
if (in.serviceEndpoints->events) {
endpoints.EventsBaseUrl(*in.serviceEndpoints->events);
fdv2.FDv1Fallback(std::move(p));
} else if (cfg.synchronizers && !cfg.synchronizers->empty()) {
// Derive an FDv1 fallback from the synchronizers list: prefer the
// first polling sync, otherwise reuse the first synchronizer's
// baseUri. The fallback is always polling. The fallback reads its
// URL from the global ServiceEndpoints, so set the polling endpoint
// to the selected baseUri.
ConfigDataSynchronizerParams const* selected = nullptr;
for (auto const& sync : *cfg.synchronizers) {
if (sync.polling) {
selected = &sync;
break;
}
}
if (!selected) {
selected = &cfg.synchronizers->front();
}
FDv2Builder::FDv1Polling p;
if (selected->polling) {
if (selected->polling->baseUri) {
endpoints->PollingBaseUrl(*selected->polling->baseUri);
}
if (selected->polling->pollIntervalMs) {
p.PollInterval(std::chrono::duration_cast<std::chrono::seconds>(
std::chrono::milliseconds(
*selected->polling->pollIntervalMs)));
}
} else if (selected->streaming && selected->streaming->baseUri) {
endpoints->PollingBaseUrl(*selected->streaming->baseUri);
}
fdv2.FDv1Fallback(std::move(p));
}

return fdv2;
}

config::builders::DataSystemBuilder::BackgroundSync BuildBackgroundSync(
ConfigParams const& in,
config::builders::EndpointsBuilder* endpoints) {
auto datasystem = config::builders::DataSystemBuilder::BackgroundSync();

if (in.streaming) {
if (in.streaming->baseUri) {
endpoints.StreamingBaseUrl(*in.streaming->baseUri);
endpoints->StreamingBaseUrl(*in.streaming->baseUri);
}
auto streaming = decltype(datasystem)::Streaming();
if (in.streaming->initialRetryDelayMs) {
Expand All @@ -66,7 +134,7 @@ std::optional<std::string> EntityManager::create(ConfigParams const& in) {

if (in.polling) {
if (in.polling->baseUri) {
endpoints.PollingBaseUrl(*in.polling->baseUri);
endpoints->PollingBaseUrl(*in.polling->baseUri);
}
if (!in.streaming) {
auto method = decltype(datasystem)::Polling();
Expand All @@ -83,7 +151,55 @@ std::optional<std::string> EntityManager::create(ConfigParams const& in) {
}
}

config_builder.DataSystem().Method(std::move(datasystem));
return datasystem;
}

} // namespace

EntityManager::EntityManager(boost::asio::any_io_executor executor,
launchdarkly::Logger& logger)
: counter_{0}, executor_{std::move(executor)}, logger_{logger} {}

std::optional<std::string> EntityManager::create(ConfigParams const& in) {
std::string id = std::to_string(counter_++);

auto config_builder = ConfigBuilder(in.credential);

// The contract test service sets endpoints in a way that is disallowed
// for users. Specifically, it may set just 1 of the 3 endpoints, whereas
// we require all 3 to be set.
//
// To avoid that error being detected, we must configure the Endpoints
// builder with the 3 default URLs, which we can fetch by just calling Build
// on a new builder. That way when the contract tests set just 1 URL,
// the others have already been "set" so no error occurs.
auto const default_endpoints =
*config::builders::EndpointsBuilder().Build();

auto& endpoints =
config_builder.ServiceEndpoints()
.EventsBaseUrl(default_endpoints.EventsBaseUrl())
.PollingBaseUrl(default_endpoints.PollingBaseUrl())
.StreamingBaseUrl(default_endpoints.StreamingBaseUrl());

if (in.serviceEndpoints) {
if (in.serviceEndpoints->streaming) {
endpoints.StreamingBaseUrl(*in.serviceEndpoints->streaming);
}
if (in.serviceEndpoints->polling) {
endpoints.PollingBaseUrl(*in.serviceEndpoints->polling);
}
if (in.serviceEndpoints->events) {
endpoints.EventsBaseUrl(*in.serviceEndpoints->events);
}
}

if (in.dataSystem) {
config_builder.DataSystem().Method(
BuildFDv2(*in.dataSystem, &endpoints));
} else {
config_builder.DataSystem().Method(BuildBackgroundSync(in, &endpoints));
}

auto& event_config = config_builder.Events();

Expand Down Expand Up @@ -140,7 +256,8 @@ std::optional<std::string> EntityManager::create(ConfigParams const& in) {

if (in.hooks) {
for (auto const& hook_config : in.hooks->hooks) {
auto hook = std::make_shared<ContractTestHook>(executor_, hook_config);
auto hook =
std::make_shared<ContractTestHook>(executor_, hook_config);
config_builder.Hooks(hook);
}
}
Expand Down
1 change: 1 addition & 0 deletions contract-tests/server-contract-tests/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ int main(int argc, char* argv[]) {
srv.add_capability("track-hooks");
srv.add_capability("wrapper");
srv.add_capability("instance-id");
srv.add_capability("fdv1-fallback");

net::signal_set signals{ioc, SIGINT, SIGTERM};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# C++ implements TTL-based FDv1 fallback; this scenario tests the older terminal semantics. Tracked in SDK-2527.
streaming/fdv2/FDv1 fallback directive/directive without FDv1 fallback configured halts the data system
Loading