1699
1700
// TestGetMetadataVersionIncrement tests that GetMetadata correctly increments the version after a namespace is created
1702
>
// Get initial metadata version
1703
>
metadata1, err1 := m.MetadataManager.GetMetadata(m.ctx)
1704
>
m.NoError(err1)
1705
>
initialVersion := metadata1.NotificationVersion
1706
>
1707
>
// Create a namespace
1708
>
id := uuid.NewString()
1709
>
name := "metadata-version-test-namespace"
1710
>
state := enumspb.NAMESPACE_STATE_REGISTERED
1711
>
description := "metadata-version-test-description"
1712
>
owner := "metadata-version-test-owner"
1713
>
data := map[string]string{"k1": "v1"}
1714
>
retention := int32(10)
1715
>
historyArchivalState := enumspb.ARCHIVAL_STATE_ENABLED
1716
>
historyArchivalURI := "test://history/uri"
1717
>
visibilityArchivalState := enumspb.ARCHIVAL_STATE_ENABLED
1718
>
visibilityArchivalURI := "test://visibility/uri"
1719
>
1720
>
clusterActive := "some random active cluster name"
1721
>
clusterStandby := "some random standby cluster name"
1722
>
configVersion := int64(10)
1723
>
failoverVersion := int64(59)
1724
>
isGlobalNamespace := true
1725
>
clusters := []string{clusterActive, clusterStandby}
1726
>
1727
>
resp1, err2 := m.CreateNamespace(
1728
>
&persistencespb.NamespaceInfo{
1729
>
Id: id,
1730
>
Name: name,
1731
>
State: state,
1732
>
Description: description,
1733
>
Owner: owner,
1734
>
Data: data,
1735
>
},
1736
>
&persistencespb.NamespaceConfig{
1737
>
Retention: timestamp.DurationFromDays(retention),
1738
>
HistoryArchivalState: historyArchivalState,
1739
>
HistoryArchivalUri: historyArchivalURI,
1740
>
VisibilityArchivalState: visibilityArchivalState,
1741
>
VisibilityArchivalUri: visibilityArchivalURI,
1742
>
},
1743
>
&persistencespb.NamespaceReplicationConfig{
1744
>
ActiveClusterName: clusterActive,
1745
>
Clusters: clusters,
1746
>
},
1747
>
isGlobalNamespace,
1748
>
configVersion,
1749
>
failoverVersion,
1750
>
)
1751
>
m.NoError(err2)
1752
>
m.NotNil(resp1)
1753
>
1754
>
// Get metadata version after creation
1755
>
metadata2, err3 := m.MetadataManager.GetMetadata(m.ctx)
1756
>
m.NoError(err3)
1757
>
afterCreationVersion := metadata2.NotificationVersion
1758
>
1759
>
// Verify that the version was incremented
1760
>
m.Equal(initialVersion+1, afterCreationVersion, "NotificationVersion should be incremented by exactly 1")
1761
>
}
1762
1763
// TestCreateNamespaceWithDuplicateName tests creating a namespace with a name that already exists