Skip to content

Commit 8d4e39c

Browse files
fix: correct TTL field name mismatch in persistent cache config
The Go test harness sends cache TTL as 'ttl' (in seconds), but the C++ data model expected 'ttlMs' (in milliseconds). This meant the TTL value was never deserialized, and the default 5-minute cache TTL was always used regardless of what the test requested. - Rename ConfigPersistentCache::ttlMs to ttl to match JSON field name - Change CacheRefresh from milliseconds to seconds to match harness units Co-Authored-By: rlamb@launchdarkly.com <kingdewman@gmail.com>
1 parent bdcb385 commit 8d4e39c

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

contract-tests/data-model/include/data_model/data_model.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,12 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(ConfigWrapper, name, version);
152152

153153
struct ConfigPersistentCache {
154154
std::string mode; // "off", "ttl", "infinite"
155-
std::optional<int> ttlMs;
155+
std::optional<int> ttl; // TTL in seconds (sent by test harness as "ttl")
156156
};
157157

158158
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(ConfigPersistentCache,
159159
mode,
160-
ttlMs);
160+
ttl);
161161

162162
struct ConfigPersistentStore {
163163
std::string type; // "redis", "consul", "dynamodb"

contract-tests/server-contract-tests/src/entity_manager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,14 @@ std::optional<std::string> EntityManager::create(ConfigParams const& in) {
181181
// Configure cache mode
182182
// Default is 5 minutes, but contract tests may specify:
183183
// - "off": disable caching (fetch from DB every time)
184-
// - "ttl": custom TTL in milliseconds
184+
// - "ttl": custom TTL in seconds (test harness sends seconds)
185185
// - "infinite": never expire cached items
186186
if (in.persistentDataStore->cache.mode == "off") {
187187
lazy_load.CacheRefresh(std::chrono::seconds(0));
188188
} else if (in.persistentDataStore->cache.mode == "ttl") {
189-
if (in.persistentDataStore->cache.ttlMs) {
190-
lazy_load.CacheRefresh(std::chrono::milliseconds(
191-
*in.persistentDataStore->cache.ttlMs));
189+
if (in.persistentDataStore->cache.ttl) {
190+
lazy_load.CacheRefresh(std::chrono::seconds(
191+
*in.persistentDataStore->cache.ttl));
192192
}
193193
} else if (in.persistentDataStore->cache.mode == "infinite") {
194194
// Use a very large TTL to effectively never expire

0 commit comments

Comments
 (0)