@@ -1053,3 +1053,76 @@ func TestSSHKeyAndPasswordForOSBuilder(t *testing.T) {
1053
1053
t .Logf ("Deleted MachineConfig %s" , testConfig .Name )
1054
1054
})
1055
1055
}
1056
+
1057
+ func TestExtensionsForOSBuilder (t * testing.T ) {
1058
+ t .Helper ()
1059
+
1060
+ cs := framework .NewClientSet ("" )
1061
+
1062
+ // label random node from pool, get the node
1063
+ unlabelFunc := helpers .LabelRandomNodeFromPool (t , cs , "worker" , "node-role.kubernetes.io/layered" )
1064
+
1065
+ // prepare for on cluster build test
1066
+ prepareForOnClusterLayeringTest (t , cs , onClusterLayeringTestOpts {
1067
+ poolName : layeredMCPName ,
1068
+ customDockerfiles : map [string ]string {},
1069
+ useEtcPkiEntitlement : true ,
1070
+ })
1071
+
1072
+ testConfig := & mcfgv1.MachineConfig {
1073
+ ObjectMeta : metav1.ObjectMeta {
1074
+ Name : "99-extensions" ,
1075
+ Labels : helpers .MCLabelForRole (layeredMCPName ),
1076
+ },
1077
+ Spec : mcfgv1.MachineConfigSpec {
1078
+ Config : runtime.RawExtension {
1079
+ Raw : helpers .MarshalOrDie (ctrlcommon .NewIgnConfig ()),
1080
+ },
1081
+ Extensions : []string {"usbguard" , "kerberos" },
1082
+ },
1083
+ }
1084
+
1085
+ helpers .SetMetadataOnObject (t , testConfig )
1086
+
1087
+ // Create the MachineConfig and wait for the configuration to be applied
1088
+ _ , err := cs .MachineConfigs ().Create (context .TODO (), testConfig , metav1.CreateOptions {})
1089
+ require .Nil (t , err , "failed to create MC" )
1090
+ t .Logf ("Created MC %s" , testConfig .Name )
1091
+
1092
+ // wait for rendered config to finish creating
1093
+ renderedConfig , err := helpers .WaitForRenderedConfig (t , cs , layeredMCPName , testConfig .Name )
1094
+ require .Nil (t , err )
1095
+ t .Logf ("Finished rendering config %s" , renderedConfig )
1096
+
1097
+ // wait for mcp to complete updating
1098
+ err = helpers .WaitForPoolComplete (t , cs , layeredMCPName , renderedConfig )
1099
+ require .Nil (t , err )
1100
+ t .Logf ("Pool %s completed updating" , layeredMCPName )
1101
+
1102
+ // Validate the extensions are installed
1103
+ osNode := helpers .GetSingleNodeByRole (t , cs , layeredMCPName ) // Re-fetch node with updated configurations
1104
+
1105
+ foundPkg := helpers .ExecCmdOnNode (t , cs , osNode , "rpm" , "-q" , "usbguard" )
1106
+ if strings .Contains (foundPkg , "package usbguard is not installed" ) {
1107
+ t .Fatalf ("usbguard extensions not found, got %s" , foundPkg )
1108
+ }
1109
+ t .Logf ("usbguard extension installed, got %s" , foundPkg )
1110
+
1111
+ foundPkg = helpers .ExecCmdOnNode (t , cs , osNode , "rpm" , "-q" , "kerberos" )
1112
+ if strings .Contains (foundPkg , "package kerberos is not installed" ) {
1113
+ t .Fatalf ("kerberos extensions not found, got %s" , foundPkg )
1114
+ }
1115
+ t .Logf ("kerberos extension installed, got %s" , foundPkg )
1116
+
1117
+ t .Logf ("Node %s has both usbguard and kerberos extensions installed" , osNode .Name )
1118
+
1119
+ // Clean-up: Delete the applied MachineConfig and ensure configurations are rolled back
1120
+
1121
+ t .Cleanup (func () {
1122
+ unlabelFunc ()
1123
+ if err := cs .MachineConfigs ().Delete (context .TODO (), testConfig .Name , metav1.DeleteOptions {}); err != nil {
1124
+ t .Error (err )
1125
+ }
1126
+ t .Logf ("Deleted MachineConfig %s" , testConfig .Name )
1127
+ })
1128
+ }
0 commit comments