Repository navigation
fix(aws-keyspaces): GetTable ttl/clientSideTimestamps omission and rpc-v2-cbor route #1680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Satyam-Trivedi-ZS
merged 3 commits into
stackshy:development
from
Satyam-Trivedi-ZS:fix/aws-keyspaces-followups-1666
Oct 23, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
9bf8478
fix(aws-keyspaces): report ttl and clientSideTimestamps only once ena…
Satyam-Trivedi-ZS 19780b5
fix(aws-keyspaces): serve the rpc-v2-cbor protocol
Satyam-Trivedi-ZS 7391738
docs(aws-keyspaces): note the rpc-v2-cbor route in the SDK server docs
Satyam-Trivedi-ZS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| package keyspaces | ||
|
|
||
| import ( | ||
| "context" | ||
| "encoding/json" | ||
| "testing" | ||
|
|
||
| ksdriver "github.com/stackshy/cloudemu/v2/services/keyspaces/driver" | ||
| ) | ||
|
|
||
| // The ttl and clientSideTimestamps enums hold only ENABLED, so a table that | ||
| // never enabled them records "" (not set) and GetTable omits the members. An | ||
| // explicit DISABLED is the documented default and records "" too, and once | ||
| // enabled neither setting can be turned off. | ||
| func TestTTLAndClientSideTimestampsTrackSet(t *testing.T) { | ||
| ctx := context.Background() | ||
| m := newTestMock() | ||
| mustKeyspace(t, m, "app") | ||
|
|
||
| create := func(name, ttl, cst string) *ksdriver.Table { | ||
| t.Helper() | ||
|
|
||
| tbl, err := m.CreateTable(ctx, ksdriver.CreateTableConfig{ | ||
| KeyspaceName: "app", Name: name, SchemaDefinition: sampleSchema(), | ||
| TTLStatus: ttl, ClientSideTimestamps: cst, | ||
| }) | ||
| if err != nil { | ||
| t.Fatalf("CreateTable %s: %v", name, err) | ||
| } | ||
|
|
||
| return tbl | ||
| } | ||
|
|
||
| check := func(name, wantTTL, wantCST string) { | ||
| t.Helper() | ||
|
|
||
| got, err := m.GetTable(ctx, "app", name) | ||
| if err != nil { | ||
| t.Fatalf("GetTable %s: %v", name, err) | ||
| } | ||
|
|
||
| if got.TTLStatus != wantTTL || got.ClientSideTimestamps != wantCST { | ||
| t.Fatalf("%s: ttl=%q cst=%q, want ttl=%q cst=%q", name, got.TTLStatus, got.ClientSideTimestamps, wantTTL, wantCST) | ||
| } | ||
| } | ||
|
|
||
| create("unset", "", "") | ||
| check("unset", "", "") | ||
|
|
||
| create("disabled", "DISABLED", "DISABLED") | ||
| check("disabled", "", "") | ||
|
|
||
| create("enabled", "ENABLED", "ENABLED") | ||
| check("enabled", "ENABLED", "ENABLED") | ||
|
|
||
| // Enabling later records the setting. | ||
| if _, err := m.UpdateTable(ctx, ksdriver.UpdateTableConfig{ | ||
| KeyspaceName: "app", Name: "unset", TTLStatus: "ENABLED", ClientSideTimestamps: "ENABLED", | ||
| }); err != nil { | ||
| t.Fatalf("UpdateTable enable: %v", err) | ||
| } | ||
|
|
||
| check("unset", "ENABLED", "ENABLED") | ||
|
|
||
| // DISABLED never turns an enabled setting back off. | ||
| if _, err := m.UpdateTable(ctx, ksdriver.UpdateTableConfig{ | ||
| KeyspaceName: "app", Name: "enabled", TTLStatus: "DISABLED", ClientSideTimestamps: "DISABLED", | ||
| }); err != nil { | ||
| t.Fatalf("UpdateTable disable: %v", err) | ||
| } | ||
|
|
||
| check("enabled", "ENABLED", "ENABLED") | ||
| } | ||
|
|
||
| // A snapshot keeps whether each setting was set, and a snapshot from an older | ||
| // build, which stored DISABLED on every table, restores as not set. | ||
| func TestSnapshotTracksTTLAndClientSideTimestamps(t *testing.T) { | ||
| ctx := context.Background() | ||
| src := newTestMock() | ||
| mustKeyspace(t, src, "app") | ||
|
|
||
| for name, status := range map[string]string{"plain": "", "on": "ENABLED"} { | ||
| if _, err := src.CreateTable(ctx, ksdriver.CreateTableConfig{ | ||
| KeyspaceName: "app", Name: name, SchemaDefinition: sampleSchema(), | ||
| TTLStatus: status, ClientSideTimestamps: status, | ||
| }); err != nil { | ||
| t.Fatalf("CreateTable %s: %v", name, err) | ||
| } | ||
| } | ||
|
|
||
| raw, err := src.Snapshot(ctx, false) | ||
| if err != nil { | ||
| t.Fatalf("snapshot: %v", err) | ||
| } | ||
|
|
||
| legacy := legacyDisabledSnapshot(t, raw) | ||
|
|
||
| for label, data := range map[string]json.RawMessage{"current": raw, "legacy": legacy} { | ||
| dst := newTestMock() | ||
| if err := dst.Restore(ctx, data); err != nil { | ||
| t.Fatalf("%s restore: %v", label, err) | ||
| } | ||
|
|
||
| for name, want := range map[string]string{"plain": "", "on": "ENABLED"} { | ||
| got, err := dst.GetTable(ctx, "app", name) | ||
| if err != nil { | ||
| t.Fatalf("%s GetTable %s: %v", label, name, err) | ||
| } | ||
|
|
||
| if got.TTLStatus != want || got.ClientSideTimestamps != want { | ||
| t.Fatalf("%s %s: ttl=%q cst=%q, want %q", label, name, got.TTLStatus, got.ClientSideTimestamps, want) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // legacyDisabledSnapshot rewrites raw the way an older build stored it: every | ||
| // table that never set ttl or clientSideTimestamps carries DISABLED. | ||
| func legacyDisabledSnapshot(t *testing.T, raw json.RawMessage) json.RawMessage { | ||
| t.Helper() | ||
|
|
||
| var snap keyspacesSnapshot | ||
| if err := json.Unmarshal(raw, &snap); err != nil { | ||
| t.Fatalf("parse snapshot: %v", err) | ||
| } | ||
|
|
||
| var tables map[string]ksdriver.Table | ||
| if err := json.Unmarshal(snap.Tables, &tables); err != nil { | ||
| t.Fatalf("parse tables: %v", err) | ||
| } | ||
|
|
||
| for k, tbl := range tables { | ||
| tbl.TTLStatus = disabledIfEmpty(tbl.TTLStatus) | ||
| tbl.ClientSideTimestamps = disabledIfEmpty(tbl.ClientSideTimestamps) | ||
| tables[k] = tbl | ||
| } | ||
|
|
||
| b, err := json.Marshal(tables) | ||
| if err != nil { | ||
| t.Fatalf("encode tables: %v", err) | ||
| } | ||
|
|
||
| snap.Tables = b | ||
|
|
||
| out, err := json.Marshal(snap) | ||
| if err != nil { | ||
| t.Fatalf("encode snapshot: %v", err) | ||
| } | ||
|
|
||
| return out | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: both enums hold only
ENABLED, so real CreateTable/UpdateTable probably rejectDISABLEDwith a ValidationException rather than treating it as unset. Accepting it seems fine until that is confirmed against real AWS. Could you add it to #1666 so it isn't lost?