@@ -3,7 +3,6 @@ package template
33import (
44 "fmt"
55 "reflect"
6- "strings"
76 "testing"
87 "time"
98
@@ -449,118 +448,3 @@ func getKey(config *mcfgv1.ControllerConfig, t *testing.T) string {
449448 }
450449 return key
451450}
452-
453- func TestKubeletAutoNodeSizingEnabled (t * testing.T ) {
454- cc := newControllerConfig ("test-cluster" )
455- ps := []byte (`{"dummy": "dummy"}` )
456-
457- mcs , err := getMachineConfigsForControllerConfig (templateDir , cc , ps , nil )
458- if err != nil {
459- t .Fatal (err )
460- }
461-
462- // Find machine configs that should contain the auto-node-sizing file
463- // The file should be in all role-based machine configs (master, worker)
464- autoSizingFileFound := false
465- for _ , mc := range mcs {
466- ignCfg , err := ctrlcommon .ParseAndConvertConfig (mc .Spec .Config .Raw )
467- if err != nil {
468- t .Fatalf ("Failed to parse ignition config for %s: %v" , mc .Name , err )
469- }
470-
471- // Look for the auto-node-sizing file
472- for _ , file := range ignCfg .Storage .Files {
473- if file .Path == ctrlcommon .NodeSizingEnabledEnvPath {
474- autoSizingFileFound = true
475-
476- // Decode the file contents
477- contents , err := ctrlcommon .DecodeIgnitionFileContents (file .Contents .Source , file .Contents .Compression )
478- if err != nil {
479- t .Fatalf ("Failed to decode auto-node-sizing file contents: %v" , err )
480- }
481-
482- contentsStr := string (contents )
483-
484- // Verify NODE_SIZING_ENABLED=true is present
485- if ! strings .Contains (contentsStr , "NODE_SIZING_ENABLED=true" ) {
486- t .Errorf ("Expected NODE_SIZING_ENABLED=true in %s, got: %s" , mc .Name , contentsStr )
487- }
488-
489- // Verify other expected values
490- if ! strings .Contains (contentsStr , "SYSTEM_RESERVED_MEMORY=1Gi" ) {
491- t .Errorf ("Expected SYSTEM_RESERVED_MEMORY=1Gi in %s, got: %s" , mc .Name , contentsStr )
492- }
493-
494- if ! strings .Contains (contentsStr , "SYSTEM_RESERVED_CPU=500m" ) {
495- t .Errorf ("Expected SYSTEM_RESERVED_CPU=500m in %s, got: %s" , mc .Name , contentsStr )
496- }
497-
498- if ! strings .Contains (contentsStr , "SYSTEM_RESERVED_ES=1Gi" ) {
499- t .Errorf ("Expected SYSTEM_RESERVED_ES=1Gi in %s, got: %s" , mc .Name , contentsStr )
500- }
501- }
502- }
503- }
504-
505- if ! autoSizingFileFound {
506- t .Errorf ("Expected to find %s file in at least one machine config" , ctrlcommon .NodeSizingEnabledEnvPath )
507- }
508- }
509-
510- func TestKubeletAutoNodeSizingDisabledForHypershift (t * testing.T ) {
511- cc := newControllerConfig ("test-cluster" )
512- // Set ControlPlaneTopology to External to simulate Hypershift
513- cc .Spec .Infra .Status .ControlPlaneTopology = configv1 .ExternalTopologyMode
514- ps := []byte (`{"dummy": "dummy"}` )
515-
516- mcs , err := getMachineConfigsForControllerConfig (templateDir , cc , ps , nil )
517- if err != nil {
518- t .Fatal (err )
519- }
520-
521- // Find machine configs that should contain the auto-node-sizing file
522- autoSizingFileFound := false
523- for _ , mc := range mcs {
524- ignCfg , err := ctrlcommon .ParseAndConvertConfig (mc .Spec .Config .Raw )
525- if err != nil {
526- t .Fatalf ("Failed to parse ignition config for %s: %v" , mc .Name , err )
527- }
528-
529- // Look for the auto-node-sizing file
530- for _ , file := range ignCfg .Storage .Files {
531- if file .Path == ctrlcommon .NodeSizingEnabledEnvPath {
532- autoSizingFileFound = true
533-
534- // Decode the file contents
535- contents , err := ctrlcommon .DecodeIgnitionFileContents (file .Contents .Source , file .Contents .Compression )
536- if err != nil {
537- t .Fatalf ("Failed to decode auto-node-sizing file contents: %v" , err )
538- }
539-
540- contentsStr := string (contents )
541-
542- // Verify NODE_SIZING_ENABLED=false is present for Hypershift
543- if ! strings .Contains (contentsStr , "NODE_SIZING_ENABLED=false" ) {
544- t .Errorf ("Expected NODE_SIZING_ENABLED=false for Hypershift in %s, got: %s" , mc .Name , contentsStr )
545- }
546-
547- // Verify other expected values are still present
548- if ! strings .Contains (contentsStr , "SYSTEM_RESERVED_MEMORY=1Gi" ) {
549- t .Errorf ("Expected SYSTEM_RESERVED_MEMORY=1Gi in %s, got: %s" , mc .Name , contentsStr )
550- }
551-
552- if ! strings .Contains (contentsStr , "SYSTEM_RESERVED_CPU=500m" ) {
553- t .Errorf ("Expected SYSTEM_RESERVED_CPU=500m in %s, got: %s" , mc .Name , contentsStr )
554- }
555-
556- if ! strings .Contains (contentsStr , "SYSTEM_RESERVED_ES=1Gi" ) {
557- t .Errorf ("Expected SYSTEM_RESERVED_ES=1Gi in %s, got: %s" , mc .Name , contentsStr )
558- }
559- }
560- }
561- }
562-
563- if ! autoSizingFileFound {
564- t .Errorf ("Expected to find %s file in at least one machine config" , ctrlcommon .NodeSizingEnabledEnvPath )
565- }
566- }
0 commit comments