@@ -2,6 +2,9 @@ package clusters
22
33import (
44 "fmt"
5+ "github.com/databricks/databricks-sdk-go/experimental/mocks"
6+ "github.com/databricks/databricks-sdk-go/listing"
7+ "github.com/stretchr/testify/mock"
58 "strings"
69 "testing"
710
@@ -1908,3 +1911,174 @@ func TestResourceClusterUpdate_LocalSsdCount(t *testing.T) {
19081911
19091912 assert .NoError (t , err )
19101913}
1914+
1915+ func TestResourceClusterAliasDedicatedNoDrift_DataSecurityMode (t * testing.T ) {
1916+ d , err := qa.ResourceFixture {
1917+ MockWorkspaceClientFunc : func (a * mocks.MockWorkspaceClient ) {
1918+ api := a .GetMockClustersAPI ().EXPECT ()
1919+ api .List (mock .Anything , compute.ListClustersRequest {
1920+ FilterBy : & compute.ListClustersFilterBy {
1921+ IsPinned : true ,
1922+ },
1923+ PageSize : 100 ,
1924+ }).Return (& listing.SliceIterator [compute.ClusterDetails ]{})
1925+ api .GetByClusterId (mock .Anything , "abc" ).Return (
1926+ & compute.ClusterDetails {
1927+ ClusterId : "abc" ,
1928+ NumWorkers : 100 ,
1929+ ClusterName : "Dedicated Cluster" ,
1930+ DataSecurityMode : compute .DataSecurityModeSingleUser ,
1931+ SparkVersion : "7.1-scala12" ,
1932+ NodeTypeId : "i3.xlarge" ,
1933+ AutoterminationMinutes : 15 ,
1934+ State : compute .StateTerminated ,
1935+ GcpAttributes : & compute.GcpAttributes {
1936+ LocalSsdCount : 2 ,
1937+ },
1938+ }, nil ,
1939+ )
1940+ },
1941+ ID : "abc" ,
1942+ Read : true ,
1943+ Resource : ResourceCluster (),
1944+ InstanceState : map [string ]string {
1945+ "autotermination_minutes" : "15" ,
1946+ "cluster_name" : "Dedicated Cluster" ,
1947+ "data_security_mode" : "SINGLE_USER" ,
1948+ "spark_version" : "7.1-scala12" ,
1949+ "node_type_id" : "i3.xlarge" ,
1950+ "num_workers" : "100" ,
1951+ "gcp_attributes" : `"{
1952+ local_ssd_count = 2
1953+ }"` ,
1954+ },
1955+ HCL : `
1956+ autotermination_minutes = 15,
1957+ cluster_name = "Dedicated Cluster"
1958+ data_security_mode = "DATA_SECURITY_MODE_DEDICATED"
1959+ spark_version = "7.1-scala12"
1960+ node_type_id = "i3.xlarge"
1961+ num_workers = 100
1962+ gcp_attributes = {
1963+ local_ssd_count = 0
1964+ },
1965+ ` ,
1966+ }.Apply (t )
1967+
1968+ assert .NoError (t , err )
1969+ assert .False (t , d .HasChanges ("data_security_mode" ))
1970+ }
1971+
1972+ func TestResourceClusterAliasStandardNoDrift_DataSecurityMode (t * testing.T ) {
1973+ d , err := qa.ResourceFixture {
1974+ MockWorkspaceClientFunc : func (a * mocks.MockWorkspaceClient ) {
1975+ api := a .GetMockClustersAPI ().EXPECT ()
1976+ api .List (mock .Anything , compute.ListClustersRequest {
1977+ FilterBy : & compute.ListClustersFilterBy {
1978+ IsPinned : true ,
1979+ },
1980+ PageSize : 100 ,
1981+ }).Return (& listing.SliceIterator [compute.ClusterDetails ]{})
1982+ api .GetByClusterId (mock .Anything , "abc" ).Return (
1983+ & compute.ClusterDetails {
1984+ ClusterId : "abc" ,
1985+ NumWorkers : 100 ,
1986+ ClusterName : "Standard Cluster" ,
1987+ DataSecurityMode : compute .DataSecurityModeUserIsolation ,
1988+ SparkVersion : "7.1-scala12" ,
1989+ NodeTypeId : "i3.xlarge" ,
1990+ AutoterminationMinutes : 15 ,
1991+ State : compute .StateTerminated ,
1992+ GcpAttributes : & compute.GcpAttributes {
1993+ LocalSsdCount : 2 ,
1994+ },
1995+ }, nil ,
1996+ )
1997+ },
1998+ ID : "abc" ,
1999+ Read : true ,
2000+ Resource : ResourceCluster (),
2001+ InstanceState : map [string ]string {
2002+ "autotermination_minutes" : "15" ,
2003+ "cluster_name" : "Standard Cluster" ,
2004+ "data_security_mode" : "USER_ISOLATION" ,
2005+ "spark_version" : "7.1-scala12" ,
2006+ "node_type_id" : "i3.xlarge" ,
2007+ "num_workers" : "100" ,
2008+ "gcp_attributes" : `"{
2009+ local_ssd_count = 2
2010+ }"` ,
2011+ },
2012+ HCL : `
2013+ autotermination_minutes = 15,
2014+ cluster_name = "Standard Cluster"
2015+ data_security_mode = "DATA_SECURITY_MODE_STANDARD"
2016+ spark_version = "7.1-scala12"
2017+ node_type_id = "i3.xlarge"
2018+ num_workers = 100
2019+ gcp_attributes = {
2020+ local_ssd_count = 0
2021+ },
2022+ ` ,
2023+ }.Apply (t )
2024+
2025+ assert .NoError (t , err )
2026+ assert .False (t , d .HasChanges ("data_security_mode" ))
2027+ }
2028+
2029+ func TestResourceClusterAliasAutoNoDrift_DataSecurityMode (t * testing.T ) {
2030+ d , err := qa.ResourceFixture {
2031+ MockWorkspaceClientFunc : func (a * mocks.MockWorkspaceClient ) {
2032+ api := a .GetMockClustersAPI ().EXPECT ()
2033+ api .List (mock .Anything , compute.ListClustersRequest {
2034+ FilterBy : & compute.ListClustersFilterBy {
2035+ IsPinned : true ,
2036+ },
2037+ PageSize : 100 ,
2038+ }).Return (& listing.SliceIterator [compute.ClusterDetails ]{})
2039+ api .GetByClusterId (mock .Anything , "abc" ).Return (
2040+ & compute.ClusterDetails {
2041+ ClusterId : "abc" ,
2042+ NumWorkers : 100 ,
2043+ ClusterName : "Auto Cluster" ,
2044+ DataSecurityMode : compute .DataSecurityModeUserIsolation ,
2045+ SparkVersion : "7.1-scala12" ,
2046+ NodeTypeId : "i3.xlarge" ,
2047+ AutoterminationMinutes : 15 ,
2048+ State : compute .StateTerminated ,
2049+ GcpAttributes : & compute.GcpAttributes {
2050+ LocalSsdCount : 2 ,
2051+ },
2052+ }, nil ,
2053+ )
2054+ },
2055+ ID : "abc" ,
2056+ Read : true ,
2057+ Resource : ResourceCluster (),
2058+ InstanceState : map [string ]string {
2059+ "autotermination_minutes" : "15" ,
2060+ "cluster_name" : "Auto Cluster" ,
2061+ "data_security_mode" : "USER_ISOLATION" ,
2062+ "spark_version" : "7.1-scala12" ,
2063+ "node_type_id" : "i3.xlarge" ,
2064+ "num_workers" : "100" ,
2065+ "gcp_attributes" : `"{
2066+ local_ssd_count = 2
2067+ }"` ,
2068+ },
2069+ HCL : `
2070+ autotermination_minutes = 15,
2071+ cluster_name = "Auto Cluster"
2072+ data_security_mode = "DATA_SECURITY_MODE_AUTO"
2073+ spark_version = "7.1-scala12"
2074+ node_type_id = "i3.xlarge"
2075+ num_workers = 100
2076+ gcp_attributes = {
2077+ local_ssd_count = 0
2078+ },
2079+ ` ,
2080+ }.Apply (t )
2081+
2082+ assert .NoError (t , err )
2083+ assert .False (t , d .HasChanges ("data_security_mode" ))
2084+ }
0 commit comments