metadata_persistence_v2.go ×4

Frontier kind: Joint frontier

unlabeled · c_f3ec9102b4da

1 test · 5223 LOC · 205 files · introduces 1 test · 111 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
4 ranges111 lines · 1 files
Tests
1 test

Contains — complete concept membership

All code (extent)
994 ranges5223 lines · 205 files · Browse complete extent
All tests (intent)
1 testBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

1 test introduced at this concept.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 111 introduced LOC across 4 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/common/persistence/persistence-tests/metadata_persistence_v2.go 111 introduced LOC · 4 ranges

Open complete file

2117 // TestRenameNamespaceCassandra tests Cassandra-specific RenameNamespace behavior
2118 // This test verifies the two-step non-atomic rename operation in Cassandra
2119 > func (m *MetadataPersistenceSuiteV2) TestRenameNamespaceCassandra() { metadata_persistence_v2.go
2120 > // This test is for Cassandra
2121 > switch m.DefaultTestCluster.(type) {
2122 case *sql.TestCluster:
2123 m.T().Skip()
2124 > default: metadata_persistence_v2.go
2125 }
2126
2127 > id := uuid.NewString() metadata_persistence_v2.go
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,
2211
2212 // Fetch metadata version before renaming
2213 > metadataBeforeRename, err9 := m.MetadataManager.GetMetadata(m.ctx) metadata_persistence_v2.go
2214 > m.NoError(err9)
2215 >
2216 > // Test 2: Rename to the same name
2217 > // In Cassandra, this will fail because it tries to INSERT a row that already exists
2218 > // with IF NOT EXISTS, which is expected behavior for Cassandra's two-step process
2219 > err6 := m.MetadataManager.RenameNamespace(m.ctx, &p.RenameNamespaceRequest{
2220 > PreviousName: newName,
2221 > NewName: newName,
2222 > })
2223 > m.ErrorAs(err6, new(*serviceerror.Unavailable), "Renaming to the same name fails in Cassandra due to IF NOT EXISTS")
2224 >
2225 > // Test 3: Verify namespace still exists with same name (unchanged)
2226 > resp7, err7 := m.GetNamespace(id, "")
2227 > m.NoError(err7)
2228 > m.Equal(newName, resp7.Namespace.Info.Name)
2229 >
2230 > // Test 4: Verify namespace can still be fetched by ID
2231 > resp8, err8 := m.GetNamespace(id, "")
2232 > m.NoError(err8)
2233 > m.Equal(newName, resp8.Namespace.Info.Name)
2234 >
2235 > // Test 5: Verify metadata version was not incremented
2236 > metadataAfterRename, err10 := m.MetadataManager.GetMetadata(m.ctx)
2237 > m.NoError(err10)
2238 > m.Equal(metadataBeforeRename.NotificationVersion, metadataAfterRename.NotificationVersion, "Notification version should not have been incremented")
2239 }
2240