@@ -754,8 +754,14 @@ def configuration_exists(cls, name):
754754 return False
755755 return True
756756
757- def validate_cfs_config (self , config_name : str ):
757+ def validate_cfs_config (self , config_name : str , branch_expectations : List [ bool ] = None ):
758758 """Validate that a cfs configuration has been created on the system
759+
760+ Args:
761+ config_name: the name of the configuration to validate
762+ branch_expectations: Optional list of booleans indicating whether
763+ each layer is expected to have a 'branch' field. If None,
764+ no checks are done for the presence of 'branch' fields.
759765 """
760766 command = f'cray cfs { self .cfs_version } configurations describe { config_name } --format json'
761767
@@ -766,7 +772,8 @@ def validate_cfs_config(self, config_name: str):
766772
767773 self .assertIn ('layers' , configuration )
768774 self .assertGreater (len (configuration .get ('layers' )), 0 )
769- for layer in configuration .get ('layers' ):
775+ layers = configuration .get ('layers' )
776+ for idx , layer in enumerate (layers ):
770777 self .assertIn ('name' , layer )
771778 self .assertIn ('commit' , layer )
772779 if self .cfs_version == 'v3' :
@@ -775,6 +782,12 @@ def validate_cfs_config(self, config_name: str):
775782 else :
776783 self .assertIn ('cloneUrl' , layer )
777784
785+ if branch_expectations is not None and idx < len (branch_expectations ):
786+ if branch_expectations [idx ]:
787+ self .assertIn ('branch' , layer , f"Layer { idx } expected to have branch" )
788+ else :
789+ self .assertNotIn ('branch' , layer , f"Layer { idx } expected NOT to have branch" )
790+
778791 except subprocess .CalledProcessError as err :
779792 # Fail the test if the command to get the configuration fails
780793 self .fail (f'Failed to get cfs config { config_name } with error: { err .stderr .decode ()} ' )
@@ -1020,6 +1033,26 @@ def test_git_layers(self):
10201033 for config in report ['configurations' ]:
10211034 self .validate_cfs_config (config ['name' ])
10221035
1036+ @skip_test_if_csm_var_missing (['branch_name' ])
1037+ def test_no_resolve_branches (self ):
1038+ """Test that branch is present in the layer when --no-resolve-branches is used."""
1039+ result = self .run_bootprep ('resolve-branches-config.yaml' , '--format json --no-resolve-branches' )
1040+
1041+ report = json .loads (result .stdout .decode ())
1042+ self .assertEqual (1 , len (report ['configurations' ]))
1043+
1044+ self .validate_cfs_config (report ['configurations' ][0 ]['name' ], branch_expectations = [True ])
1045+
1046+ @skip_test_if_csm_var_missing (['branch_name' ])
1047+ def test_resolve_branches (self ):
1048+ """Test that branch is NOT present in the layer when --no-resolve-branches is NOT used."""
1049+ result = self .run_bootprep ('resolve-branches-config.yaml' , '--format json' )
1050+
1051+ report = json .loads (result .stdout .decode ())
1052+ self .assertEqual (1 , len (report ['configurations' ]))
1053+
1054+ self .validate_cfs_config (report ['configurations' ][0 ]['name' ], branch_expectations = [False ])
1055+
10231056 @skip_test_if_csm_var_missing (['branch_name' , 'version' ])
10241057 def test_special_parameters (self ):
10251058 """Test creating a CFS configuration with special parameters"""
0 commit comments