Repository navigation
fix(aws-keyspaces): tag existence and restrictions, name validation, missing-keyspace error, GetTable omissions #1645
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
NitinKumar004
merged 4 commits into
stackshy:development
from
Satyam-Trivedi-ZS:fix/aws-keyspaces-parity-1512
Oct 23, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7cedcbe
fix(aws-keyspaces): tag existence and restrictions, name validation, …
Satyam-Trivedi-ZS a8e8329
fix(aws): skip resources deleted mid-walk in tagged RGT discovery
Satyam-Trivedi-ZS d637012
fix(aws-keyspaces): copy tags under the lock in Snapshot, canonicalis…
Satyam-Trivedi-ZS 0be1e71
fix(aws-keyspaces): enforce the 60-item TagList bound in the provider
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| package keyspaces | ||
|
|
||
| import ( | ||
| "context" | ||
| "strings" | ||
| "testing" | ||
|
|
||
| cerrors "github.com/stackshy/cloudemu/v2/errors" | ||
| ksdriver "github.com/stackshy/cloudemu/v2/services/keyspaces/driver" | ||
| ) | ||
|
|
||
| // Keyspace/table names follow the documented KeyspaceName/TableName shape: | ||
| // length 1-48, pattern [a-zA-Z0-9][a-zA-Z0-9_]{0,47}. | ||
| func TestNameValidation(t *testing.T) { | ||
| m := newTestMock() | ||
| ctx := context.Background() | ||
|
|
||
| maxName := strings.Repeat("a", maxNameLen) | ||
| tooLong := strings.Repeat("a", maxNameLen+1) | ||
|
|
||
| valid := []string{"a", "A1", "1abc", "9", "my_keyspace", maxName} | ||
| for _, n := range valid { | ||
| if _, err := m.CreateKeyspace(ctx, ksdriver.CreateKeyspaceConfig{Name: n}); err != nil { | ||
| t.Fatalf("CreateKeyspace(%q): unexpected error %v", n, err) | ||
| } | ||
| } | ||
|
|
||
| invalid := []string{"", tooLong, "_lead", "has-dash", "has.dot", "has space", "a/b", "ünicode"} | ||
| for _, n := range invalid { | ||
| if _, err := m.CreateKeyspace(ctx, ksdriver.CreateKeyspaceConfig{Name: n}); !cerrors.IsInvalidArgument(err) { | ||
| t.Fatalf("CreateKeyspace(%q): got %v, want InvalidArgument", n, err) | ||
| } | ||
|
|
||
| if _, err := m.CreateTable(ctx, ksdriver.CreateTableConfig{ | ||
| KeyspaceName: "a", Name: n, SchemaDefinition: sampleSchema(), | ||
| }); !cerrors.IsInvalidArgument(err) { | ||
| t.Fatalf("CreateTable(%q): got %v, want InvalidArgument", n, err) | ||
| } | ||
| } | ||
|
|
||
| if _, err := m.CreateTable(ctx, ksdriver.CreateTableConfig{ | ||
| KeyspaceName: "a", Name: "1t", SchemaDefinition: sampleSchema(), | ||
| }); err != nil { | ||
| t.Fatalf("CreateTable leading digit: %v", err) | ||
| } | ||
|
|
||
| if _, err := m.CreateTable(ctx, ksdriver.CreateTableConfig{ | ||
| KeyspaceName: "a", Name: maxName, SchemaDefinition: sampleSchema(), | ||
| }); err != nil { | ||
| t.Fatalf("CreateTable 48-char name: %v", err) | ||
| } | ||
|
|
||
| if _, err := m.RestoreTable(ctx, ksdriver.RestoreTableConfig{ | ||
| SourceKeyspace: "a", SourceTable: "1t", TargetKeyspace: "a", TargetTable: tooLong, | ||
| RestoreTimestamp: m.opts.Clock.Now().Add(-1), | ||
| }); !cerrors.IsInvalidArgument(err) { | ||
| t.Fatalf("RestoreTable too-long target: got %v, want InvalidArgument", err) | ||
| } | ||
|
|
||
| fields := []ksdriver.FieldDefinition{{Name: "f", Type: "text"}} | ||
| if _, err := m.CreateType(ctx, "a", tooLong, fields); !cerrors.IsInvalidArgument(err) { | ||
| t.Fatalf("CreateType too long: got %v, want InvalidArgument", err) | ||
| } | ||
|
|
||
| if _, err := m.CreateType(ctx, "a", maxName, fields); err != nil { | ||
| t.Fatalf("CreateType 48-char name: %v", err) | ||
| } | ||
| } | ||
|
|
||
| // A well-formed request naming a parent keyspace that doesn't exist is | ||
| // ResourceNotFound for CreateTable, CreateType, and RestoreTable's target. | ||
| func TestMissingParentKeyspaceIsNotFound(t *testing.T) { | ||
| m := newTestMock() | ||
| ctx := context.Background() | ||
| mustKeyspace(t, m, "app") | ||
|
|
||
| if _, err := m.CreateTable(ctx, ksdriver.CreateTableConfig{ | ||
| KeyspaceName: "ghost", Name: "t", SchemaDefinition: sampleSchema(), | ||
| }); !cerrors.IsNotFound(err) { | ||
| t.Fatalf("CreateTable: got %v, want NotFound", err) | ||
| } | ||
|
|
||
| if _, err := m.CreateType(ctx, "ghost", "addr", []ksdriver.FieldDefinition{{Name: "f", Type: "text"}}); !cerrors.IsNotFound(err) { | ||
| t.Fatalf("CreateType: got %v, want NotFound", err) | ||
| } | ||
|
|
||
| if _, err := m.CreateTable(ctx, ksdriver.CreateTableConfig{ | ||
| KeyspaceName: "app", Name: "src", SchemaDefinition: sampleSchema(), | ||
| }); err != nil { | ||
| t.Fatalf("CreateTable: %v", err) | ||
| } | ||
|
|
||
| if _, err := m.RestoreTable(ctx, ksdriver.RestoreTableConfig{ | ||
| SourceKeyspace: "app", SourceTable: "src", TargetKeyspace: "ghost", TargetTable: "dst", | ||
| RestoreTimestamp: m.opts.Clock.Now(), | ||
| }); !cerrors.IsNotFound(err) { | ||
| t.Fatalf("RestoreTable: got %v, want NotFound", err) | ||
| } | ||
| } | ||
|
|
||
| // All four documented system keyspaces exist and none can be deleted. | ||
| func TestSystemKeyspaces(t *testing.T) { | ||
| m := newTestMock() | ||
| ctx := context.Background() | ||
|
|
||
| for _, name := range []string{"system", "system_schema", "system_schema_mcs", "system_multiregion_info"} { | ||
| if _, err := m.GetKeyspace(ctx, name); err != nil { | ||
| t.Fatalf("GetKeyspace(%s): %v", name, err) | ||
| } | ||
|
|
||
| if err := m.DeleteKeyspace(ctx, name); !cerrors.IsInvalidArgument(err) { | ||
| t.Fatalf("DeleteKeyspace(%s): got %v, want InvalidArgument", name, err) | ||
| } | ||
| } | ||
| } |
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, and the same on the base: RGT GetResources with
--resource-type-filters cassandralists all four system keyspaces with no tags. Real RGT doesn't show AWS-owned system keyspaces. A follow-up could skipisSystemKeyspacenames indiscoverKeyspaces.