metadata_persistence_v2.go ×2

Frontier kind: Code frontier

unlabeled · c_f855ae1f6ad0

6 tests · 4824 LOC · 194 files · introduces 0 tests · 113 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
2 ranges113 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
908 ranges4824 lines · 194 files · Browse complete extent
All tests (intent)
6 testsBrowse 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.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

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

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

go.temporal.io/server/common/persistence/persistence-tests/metadata_persistence_v2.go 113 introduced LOC · 2 ranges

Open complete file

2241 // TestRenameNamespaceSQL tests SQL RenameNamespace behavior
2242 // This test verifies the atomic transaction-based rename operation in SQL databases
2243 > func (m *MetadataPersistenceSuiteV2) TestRenameNamespaceSQL() { metadata_persistence_v2.go
2244 > // This test is for SQL databases
2245 > switch m.DefaultTestCluster.(type) {
2246 > case *sql.TestCluster:
2247 default:
2248 m.T().Skip()
2249 }
2250
2251 > id := uuid.NewString() metadata_persistence_v2.go
2252 > name := "sql-rename-test-name"
2253 > newName := "sql-rename-test-new-name"
2254 > state := enumspb.NAMESPACE_STATE_REGISTERED
2255 > description := "sql-rename-test-description"
2256 > owner := "sql-rename-test-owner"
2257 > data := map[string]string{"k1": "v1"}
2258 > retention := int32(10)
2259 > historyArchivalState := enumspb.ARCHIVAL_STATE_ENABLED
2260 > historyArchivalURI := "test://history/uri"
2261 > visibilityArchivalState := enumspb.ARCHIVAL_STATE_ENABLED
2262 > visibilityArchivalURI := "test://visibility/uri"
2263 >
2264 > clusterActive := "some random active cluster name"
2265 > clusterStandby := "some random standby cluster name"
2266 > configVersion := int64(10)
2267 > failoverVersion := int64(59)
2268 > isGlobalNamespace := true
2269 > clusters := []string{clusterActive, clusterStandby}
2270 >
2271 > // Create namespace
2272 > resp1, err1 := m.CreateNamespace(
2273 > &persistencespb.NamespaceInfo{
2274 > Id: id,
2275 > Name: name,
2276 > State: state,
2277 > Description: description,
2278 > Owner: owner,
2279 > Data: data,
2280 > },
2281 > &persistencespb.NamespaceConfig{
2282 > Retention: timestamp.DurationFromDays(retention),
2283 > HistoryArchivalState: historyArchivalState,
2284 > HistoryArchivalUri: historyArchivalURI,
2285 > VisibilityArchivalState: visibilityArchivalState,
2286 > VisibilityArchivalUri: visibilityArchivalURI,
2287 > },
2288 > &persistencespb.NamespaceReplicationConfig{
2289 > ActiveClusterName: clusterActive,
2290 > Clusters: clusters,
2291 > },
2292 > isGlobalNamespace,
2293 > configVersion,
2294 > failoverVersion,
2295 > )
2296 > m.NoError(err1)
2297 > m.EqualValues(id, resp1.ID)
2298 >
2299 > // Verify namespace exists with original name
2300 > resp2, err2 := m.GetNamespace(id, "")
2301 > m.NoError(err2)
2302 > m.Equal(name, resp2.Namespace.Info.Name)
2303 >
2304 > // Test 1: Rename to a new name
2305 > err3 := m.MetadataManager.RenameNamespace(m.ctx, &p.RenameNamespaceRequest{
2306 > PreviousName: name,
2307 > NewName: newName,
2308 > })
2309 > m.NoError(err3)
2310 >
2311 > // Verify namespace can be retrieved by new name
2312 > resp4, err4 := m.GetNamespace("", newName)
2313 > m.NoError(err4)
2314 > m.NotNil(resp4)
2315 > m.EqualValues(id, resp4.Namespace.Info.Id)
2316 > m.Equal(newName, resp4.Namespace.Info.Name)
2317 > m.Equal(description, resp4.Namespace.Info.Description)
2318 > m.Equal(owner, resp4.Namespace.Info.Owner)
2319 > m.Equal(data, resp4.Namespace.Info.Data)
2320 >
2321 > // Verify namespace can be retrieved by ID and has new name
2322 > resp5, err5 := m.GetNamespace(id, "")
2323 > m.NoError(err5)
2324 > m.Equal(newName, resp5.Namespace.Info.Name)
2325 >
2326 > // Verify old name no longer exists
2327 > _, err6 := m.GetNamespace("", name)
2328 > m.ErrorAs(err6, new(*serviceerror.NamespaceNotFound), "Old name should not exist after rename")
2329 >
2330 > // Fetch metadata version before renaming
2331 > metadataBeforeRename, err9 := m.MetadataManager.GetMetadata(m.ctx)
2332 > m.NoError(err9)
2333 >
2334 > // Test 2: Rename to the same name (idempotent operation)
2335 > err7 := m.MetadataManager.RenameNamespace(m.ctx, &p.RenameNamespaceRequest{
2336 > PreviousName: newName,
2337 > NewName: newName,
2338 > })
2339 > m.NoError(err7, "Renaming to the same name should succeed")
2340 >
2341 > // Verify namespace still exists with same name and data is unchanged
2342 > resp8, err8 := m.GetNamespace(id, "")
2343 > m.NoError(err8)
2344 > m.Equal(newName, resp8.Namespace.Info.Name)
2345 > m.Equal(description, resp8.Namespace.Info.Description)
2346 > m.Equal(owner, resp8.Namespace.Info.Owner)
2347 > m.Equal(data, resp8.Namespace.Info.Data)
2348 >
2349 > // Test 3: Verify atomicity - query by both ID and name should be consistent
2350 > resp9, err9 := m.GetNamespace("", newName)
2351 > m.NoError(err9)
2352 > m.Equal(resp9.Namespace.Info.Id, resp8.Namespace.Info.Id)
2353 > m.Equal(resp9.Namespace.Info.Name, resp8.Namespace.Info.Name)
2354 > m.Equal(resp9.Namespace.Info.Description, resp8.Namespace.Info.Description)
2355 >
2356 > // Test 4: Verify metadata version was incremented
2357 > metadataAfterRename, err11 := m.MetadataManager.GetMetadata(m.ctx)
2358 > m.NoError(err11)
2359 > m.Greater(metadataAfterRename.NotificationVersion, metadataBeforeRename.NotificationVersion, "Notification version should have been incremented")
2360 }