@@ -2183,12 +2183,31 @@ describe('cluster', () => {
21832183 instanceType : new ec2 . InstanceType ( 'inf1.2xlarge' ) ,
21842184 minCapacity : 1 ,
21852185 } ) ;
2186- const fileContents = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin.yaml' ) , 'utf8' ) ;
2187- const sanitized = YAML . parse ( fileContents ) ;
2186+
2187+ const daemonSetFileContents = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin.yaml' ) , 'utf8' ) ;
2188+ const sanitizedDaemonSet = YAML . parse ( daemonSetFileContents ) ;
2189+
2190+ const clusterRoleFileContent = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin-rbac-cluster-role.yaml' ) , 'utf8' ) ;
2191+ const sanitizedClusterRole = YAML . parse ( clusterRoleFileContent ) ;
2192+
2193+ const clusterRoleBindingFileContents = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin-rbac-cluster-role-binding.yaml' ) , 'utf8' ) ;
2194+ const sanitizedClusterRoleBinding = YAML . parse ( clusterRoleBindingFileContents ) ;
2195+
2196+ const serviceAccountFileContents = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin-rbac-service-account.yaml' ) , 'utf8' ) ;
2197+ const sanitizedServiceAccount = YAML . parse ( serviceAccountFileContents ) ;
21882198
21892199 // THEN
21902200 Template . fromStack ( stack ) . hasResourceProperties ( eks . KubernetesManifest . RESOURCE_TYPE , {
2191- Manifest : JSON . stringify ( [ sanitized ] ) ,
2201+ Manifest : JSON . stringify ( [ sanitizedDaemonSet ] ) ,
2202+ } ) ;
2203+ Template . fromStack ( stack ) . hasResourceProperties ( eks . KubernetesManifest . RESOURCE_TYPE , {
2204+ Manifest : JSON . stringify ( [ sanitizedClusterRole ] ) ,
2205+ } ) ;
2206+ Template . fromStack ( stack ) . hasResourceProperties ( eks . KubernetesManifest . RESOURCE_TYPE , {
2207+ Manifest : JSON . stringify ( [ sanitizedClusterRoleBinding ] ) ,
2208+ } ) ;
2209+ Template . fromStack ( stack ) . hasResourceProperties ( eks . KubernetesManifest . RESOURCE_TYPE , {
2210+ Manifest : JSON . stringify ( [ sanitizedServiceAccount ] ) ,
21922211 } ) ;
21932212 } ) ;
21942213 test ( 'inf2 instances are supported' , ( ) => {
@@ -2201,12 +2220,31 @@ describe('cluster', () => {
22012220 instanceType : new ec2 . InstanceType ( 'inf2.xlarge' ) ,
22022221 minCapacity : 1 ,
22032222 } ) ;
2204- const fileContents = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin.yaml' ) , 'utf8' ) ;
2205- const sanitized = YAML . parse ( fileContents ) ;
2223+
2224+ const daemonSetFileContents = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin.yaml' ) , 'utf8' ) ;
2225+ const sanitizedDaemonSet = YAML . parse ( daemonSetFileContents ) ;
2226+
2227+ const clusterRoleFileContent = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin-rbac-cluster-role.yaml' ) , 'utf8' ) ;
2228+ const sanitizedClusterRole = YAML . parse ( clusterRoleFileContent ) ;
2229+
2230+ const clusterRoleBindingFileContents = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin-rbac-cluster-role-binding.yaml' ) , 'utf8' ) ;
2231+ const sanitizedClusterRoleBinding = YAML . parse ( clusterRoleBindingFileContents ) ;
2232+
2233+ const serviceAccountFileContents = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin-rbac-service-account.yaml' ) , 'utf8' ) ;
2234+ const sanitizedServiceAccount = YAML . parse ( serviceAccountFileContents ) ;
22062235
22072236 // THEN
22082237 Template . fromStack ( stack ) . hasResourceProperties ( eks . KubernetesManifest . RESOURCE_TYPE , {
2209- Manifest : JSON . stringify ( [ sanitized ] ) ,
2238+ Manifest : JSON . stringify ( [ sanitizedDaemonSet ] ) ,
2239+ } ) ;
2240+ Template . fromStack ( stack ) . hasResourceProperties ( eks . KubernetesManifest . RESOURCE_TYPE , {
2241+ Manifest : JSON . stringify ( [ sanitizedClusterRole ] ) ,
2242+ } ) ;
2243+ Template . fromStack ( stack ) . hasResourceProperties ( eks . KubernetesManifest . RESOURCE_TYPE , {
2244+ Manifest : JSON . stringify ( [ sanitizedClusterRoleBinding ] ) ,
2245+ } ) ;
2246+ Template . fromStack ( stack ) . hasResourceProperties ( eks . KubernetesManifest . RESOURCE_TYPE , {
2247+ Manifest : JSON . stringify ( [ sanitizedServiceAccount ] ) ,
22102248 } ) ;
22112249 } ) ;
22122250 test ( 'trn1 instances are supported' , ( ) => {
@@ -2219,12 +2257,31 @@ describe('cluster', () => {
22192257 instanceType : new ec2 . InstanceType ( 'trn1.2xlarge' ) ,
22202258 minCapacity : 1 ,
22212259 } ) ;
2222- const fileContents = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin.yaml' ) , 'utf8' ) ;
2223- const sanitized = YAML . parse ( fileContents ) ;
2260+
2261+ const daemonSetFileContents = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin.yaml' ) , 'utf8' ) ;
2262+ const sanitizedDaemonSet = YAML . parse ( daemonSetFileContents ) ;
2263+
2264+ const clusterRoleFileContent = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin-rbac-cluster-role.yaml' ) , 'utf8' ) ;
2265+ const sanitizedClusterRole = YAML . parse ( clusterRoleFileContent ) ;
2266+
2267+ const clusterRoleBindingFileContents = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin-rbac-cluster-role-binding.yaml' ) , 'utf8' ) ;
2268+ const sanitizedClusterRoleBinding = YAML . parse ( clusterRoleBindingFileContents ) ;
2269+
2270+ const serviceAccountFileContents = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin-rbac-service-account.yaml' ) , 'utf8' ) ;
2271+ const sanitizedServiceAccount = YAML . parse ( serviceAccountFileContents ) ;
22242272
22252273 // THEN
22262274 Template . fromStack ( stack ) . hasResourceProperties ( eks . KubernetesManifest . RESOURCE_TYPE , {
2227- Manifest : JSON . stringify ( [ sanitized ] ) ,
2275+ Manifest : JSON . stringify ( [ sanitizedDaemonSet ] ) ,
2276+ } ) ;
2277+ Template . fromStack ( stack ) . hasResourceProperties ( eks . KubernetesManifest . RESOURCE_TYPE , {
2278+ Manifest : JSON . stringify ( [ sanitizedClusterRole ] ) ,
2279+ } ) ;
2280+ Template . fromStack ( stack ) . hasResourceProperties ( eks . KubernetesManifest . RESOURCE_TYPE , {
2281+ Manifest : JSON . stringify ( [ sanitizedClusterRoleBinding ] ) ,
2282+ } ) ;
2283+ Template . fromStack ( stack ) . hasResourceProperties ( eks . KubernetesManifest . RESOURCE_TYPE , {
2284+ Manifest : JSON . stringify ( [ sanitizedServiceAccount ] ) ,
22282285 } ) ;
22292286 } ) ;
22302287 test ( 'trn1n instances are supported' , ( ) => {
@@ -2237,12 +2294,31 @@ describe('cluster', () => {
22372294 instanceType : new ec2 . InstanceType ( 'trn1n.2xlarge' ) ,
22382295 minCapacity : 1 ,
22392296 } ) ;
2240- const fileContents = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin.yaml' ) , 'utf8' ) ;
2241- const sanitized = YAML . parse ( fileContents ) ;
2297+
2298+ const daemonSetFileContents = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin.yaml' ) , 'utf8' ) ;
2299+ const sanitizedDaemonSet = YAML . parse ( daemonSetFileContents ) ;
2300+
2301+ const clusterRoleFileContent = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin-rbac-cluster-role.yaml' ) , 'utf8' ) ;
2302+ const sanitizedClusterRole = YAML . parse ( clusterRoleFileContent ) ;
2303+
2304+ const clusterRoleBindingFileContents = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin-rbac-cluster-role-binding.yaml' ) , 'utf8' ) ;
2305+ const sanitizedClusterRoleBinding = YAML . parse ( clusterRoleBindingFileContents ) ;
2306+
2307+ const serviceAccountFileContents = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin-rbac-service-account.yaml' ) , 'utf8' ) ;
2308+ const sanitizedServiceAccount = YAML . parse ( serviceAccountFileContents ) ;
22422309
22432310 // THEN
22442311 Template . fromStack ( stack ) . hasResourceProperties ( eks . KubernetesManifest . RESOURCE_TYPE , {
2245- Manifest : JSON . stringify ( [ sanitized ] ) ,
2312+ Manifest : JSON . stringify ( [ sanitizedDaemonSet ] ) ,
2313+ } ) ;
2314+ Template . fromStack ( stack ) . hasResourceProperties ( eks . KubernetesManifest . RESOURCE_TYPE , {
2315+ Manifest : JSON . stringify ( [ sanitizedClusterRole ] ) ,
2316+ } ) ;
2317+ Template . fromStack ( stack ) . hasResourceProperties ( eks . KubernetesManifest . RESOURCE_TYPE , {
2318+ Manifest : JSON . stringify ( [ sanitizedClusterRoleBinding ] ) ,
2319+ } ) ;
2320+ Template . fromStack ( stack ) . hasResourceProperties ( eks . KubernetesManifest . RESOURCE_TYPE , {
2321+ Manifest : JSON . stringify ( [ sanitizedServiceAccount ] ) ,
22462322 } ) ;
22472323 } ) ;
22482324
@@ -2255,12 +2331,31 @@ describe('cluster', () => {
22552331 cluster . addNodegroupCapacity ( 'InferenceInstances' , {
22562332 instanceTypes : [ new ec2 . InstanceType ( 'inf1.2xlarge' ) ] ,
22572333 } ) ;
2258- const fileContents = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin.yaml' ) , 'utf8' ) ;
2259- const sanitized = YAML . parse ( fileContents ) ;
2334+
2335+ const daemonSetFileContents = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin.yaml' ) , 'utf8' ) ;
2336+ const sanitizedDaemonSet = YAML . parse ( daemonSetFileContents ) ;
2337+
2338+ const clusterRoleFileContent = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin-rbac-cluster-role.yaml' ) , 'utf8' ) ;
2339+ const sanitizedClusterRole = YAML . parse ( clusterRoleFileContent ) ;
2340+
2341+ const clusterRoleBindingFileContents = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin-rbac-cluster-role-binding.yaml' ) , 'utf8' ) ;
2342+ const sanitizedClusterRoleBinding = YAML . parse ( clusterRoleBindingFileContents ) ;
2343+
2344+ const serviceAccountFileContents = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin-rbac-service-account.yaml' ) , 'utf8' ) ;
2345+ const sanitizedServiceAccount = YAML . parse ( serviceAccountFileContents ) ;
22602346
22612347 // THEN
22622348 Template . fromStack ( stack ) . hasResourceProperties ( eks . KubernetesManifest . RESOURCE_TYPE , {
2263- Manifest : JSON . stringify ( [ sanitized ] ) ,
2349+ Manifest : JSON . stringify ( [ sanitizedDaemonSet ] ) ,
2350+ } ) ;
2351+ Template . fromStack ( stack ) . hasResourceProperties ( eks . KubernetesManifest . RESOURCE_TYPE , {
2352+ Manifest : JSON . stringify ( [ sanitizedClusterRole ] ) ,
2353+ } ) ;
2354+ Template . fromStack ( stack ) . hasResourceProperties ( eks . KubernetesManifest . RESOURCE_TYPE , {
2355+ Manifest : JSON . stringify ( [ sanitizedClusterRoleBinding ] ) ,
2356+ } ) ;
2357+ Template . fromStack ( stack ) . hasResourceProperties ( eks . KubernetesManifest . RESOURCE_TYPE , {
2358+ Manifest : JSON . stringify ( [ sanitizedServiceAccount ] ) ,
22642359 } ) ;
22652360 } ) ;
22662361 test ( 'inf2 instances are supported in addNodegroupCapacity' , ( ) => {
@@ -2272,12 +2367,31 @@ describe('cluster', () => {
22722367 cluster . addNodegroupCapacity ( 'InferenceInstances' , {
22732368 instanceTypes : [ new ec2 . InstanceType ( 'inf2.xlarge' ) ] ,
22742369 } ) ;
2275- const fileContents = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin.yaml' ) , 'utf8' ) ;
2276- const sanitized = YAML . parse ( fileContents ) ;
2370+
2371+ const daemonSetFileContents = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin.yaml' ) , 'utf8' ) ;
2372+ const sanitizedDaemonSet = YAML . parse ( daemonSetFileContents ) ;
2373+
2374+ const clusterRoleFileContent = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin-rbac-cluster-role.yaml' ) , 'utf8' ) ;
2375+ const sanitizedClusterRole = YAML . parse ( clusterRoleFileContent ) ;
2376+
2377+ const clusterRoleBindingFileContents = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin-rbac-cluster-role-binding.yaml' ) , 'utf8' ) ;
2378+ const sanitizedClusterRoleBinding = YAML . parse ( clusterRoleBindingFileContents ) ;
2379+
2380+ const serviceAccountFileContents = fs . readFileSync ( path . join ( __dirname , '..' , 'lib' , 'addons' , 'neuron-device-plugin-rbac-service-account.yaml' ) , 'utf8' ) ;
2381+ const sanitizedServiceAccount = YAML . parse ( serviceAccountFileContents ) ;
22772382
22782383 // THEN
22792384 Template . fromStack ( stack ) . hasResourceProperties ( eks . KubernetesManifest . RESOURCE_TYPE , {
2280- Manifest : JSON . stringify ( [ sanitized ] ) ,
2385+ Manifest : JSON . stringify ( [ sanitizedDaemonSet ] ) ,
2386+ } ) ;
2387+ Template . fromStack ( stack ) . hasResourceProperties ( eks . KubernetesManifest . RESOURCE_TYPE , {
2388+ Manifest : JSON . stringify ( [ sanitizedClusterRole ] ) ,
2389+ } ) ;
2390+ Template . fromStack ( stack ) . hasResourceProperties ( eks . KubernetesManifest . RESOURCE_TYPE , {
2391+ Manifest : JSON . stringify ( [ sanitizedClusterRoleBinding ] ) ,
2392+ } ) ;
2393+ Template . fromStack ( stack ) . hasResourceProperties ( eks . KubernetesManifest . RESOURCE_TYPE , {
2394+ Manifest : JSON . stringify ( [ sanitizedServiceAccount ] ) ,
22812395 } ) ;
22822396 } ) ;
22832397
0 commit comments