2117
// TestRenameNamespaceCassandra tests Cassandra-specific RenameNamespace behavior
2118
// This test verifies the two-step non-atomic rename operation in Cassandra
2120
>
// This test is for Cassandra
2121
>
switch m.DefaultTestCluster.(type) {
2122
case *sql.TestCluster:
2123
m.T().Skip()
2125
}
2126
2128
>
name := "cassandra-rename-test-name"
2129
>
newName := "cassandra-rename-test-new-name"
2130
>
state := enumspb.NAMESPACE_STATE_REGISTERED
2131
>
description := "cassandra-rename-test-description"
2132
>
owner := "cassandra-rename-test-owner"
2133
>
data := map[string]string{"k1": "v1"}
2134
>
retention := int32(10)
2135
>
historyArchivalState := enumspb.ARCHIVAL_STATE_ENABLED
2136
>
historyArchivalURI := "test://history/uri"
2137
>
visibilityArchivalState := enumspb.ARCHIVAL_STATE_ENABLED
2138
>
visibilityArchivalURI := "test://visibility/uri"
2139
>
2140
>
clusterActive := "some random active cluster name"
2141
>
clusterStandby := "some random standby cluster name"
2142
>
configVersion := int64(10)
2143
>
failoverVersion := int64(59)
2144
>
isGlobalNamespace := true
2145
>
clusters := []string{clusterActive, clusterStandby}
2146
>
2147
>
// Create namespace
2148
>
resp1, err1 := m.CreateNamespace(
2149
>
&persistencespb.NamespaceInfo{
2150
>
Id: id,
2151
>
Name: name,
2152
>
State: state,
2153
>
Description: description,
2154
>
Owner: owner,
2155
>
Data: data,
2156
>
},
2157
>
&persistencespb.NamespaceConfig{
2158
>
Retention: timestamp.DurationFromDays(retention),
2159
>
HistoryArchivalState: historyArchivalState,
2160
>
HistoryArchivalUri: historyArchivalURI,
2161
>
VisibilityArchivalState: visibilityArchivalState,
2162
>
VisibilityArchivalUri: visibilityArchivalURI,
2163
>
},
2164
>
&persistencespb.NamespaceReplicationConfig{
2165
>
ActiveClusterName: clusterActive,
2166
>
Clusters: clusters,
2167
>
},
2168
>
isGlobalNamespace,
2169
>
configVersion,
2170
>
failoverVersion,
2171
>
)
2172
>
m.NoError(err1)
2173
>
m.EqualValues(id, resp1.ID)
2174
>
2175
>
// Verify namespace exists with original name
2176
>
resp2, err2 := m.GetNamespace(id, "")
2177
>
m.NoError(err2)
2178
>
m.Equal(name, resp2.Namespace.Info.Name)
2179
>
2180
>
// Test 1: Rename to a new name
2181
>
err3 := m.MetadataManager.RenameNamespace(m.ctx, &p.RenameNamespaceRequest{
2182
>
PreviousName: name,
2183
>
NewName: newName,
2184
>
})
2185
>
m.NoError(err3)
2186
>
2187
>
// Verify namespace can be retrieved by new name
2188
>
resp4, err4 := m.GetNamespace("", newName)
2189
>
m.NoError(err4)
2190
>
m.NotNil(resp4)
2191
>
m.EqualValues(id, resp4.Namespace.Info.Id)
2192
>
m.Equal(newName, resp4.Namespace.Info.Name)
2193
>
m.Equal(description, resp4.Namespace.Info.Description)
2194
>
m.Equal(owner, resp4.Namespace.Info.Owner)
2195
>
m.Equal(data, resp4.Namespace.Info.Data)
2196
>
2197
>
// Verify namespace can be retrieved by ID and has new name
2198
>
resp5, err5 := m.GetNamespace(id, "")
2199
>
m.NoError(err5)
2200
>
m.Equal(newName, resp5.Namespace.Info.Name)
2201
>
2202
>
// Verify old name no longer exists (may need eventual consistency check for Cassandra)
2203
>
m.Eventually(
2204
>
func() bool {
2205
>
_, err := m.GetNamespace("", name)
2206
>
return errors.As(err, new(*serviceerror.NamespaceNotFound))
2207
>
},
2208
10*time.Second,
2209
100*time.Millisecond,