@@ -694,6 +694,95 @@ func TestSingleNodeAirgapUpgrade(t *testing.T) {
694694 t .Logf ("%s: test complete" , time .Now ().Format (time .RFC3339 ))
695695}
696696
697+ func TestSingleNodeAirgapUpgradeSelinux (t * testing.T ) {
698+ t .Parallel ()
699+
700+ RequireEnvVars (t , []string {"SHORT_SHA" })
701+
702+ tc := cmx .NewCluster (& cmx.ClusterInput {
703+ T : t ,
704+ Nodes : 1 ,
705+ Distribution : "almalinux" ,
706+ Version : "8" ,
707+ })
708+ defer tc .Cleanup ()
709+
710+ t .Logf ("%s: downloading airgap files on node 0" , time .Now ().Format (time .RFC3339 ))
711+ initialVersion := fmt .Sprintf ("appver-%s-previous-k0s" , os .Getenv ("SHORT_SHA" ))
712+ runInParallel (t ,
713+ func (t * testing.T ) error {
714+ return downloadAirgapBundleOnNode (t , tc , 0 , initialVersion , AirgapInstallBundlePath , AirgapLicenseID )
715+ }, func (t * testing.T ) error {
716+ return downloadAirgapBundleOnNode (t , tc , 0 , fmt .Sprintf ("appver-%s-upgrade" , os .Getenv ("SHORT_SHA" )), AirgapUpgradeBundlePath , AirgapLicenseID )
717+ },
718+ )
719+
720+ t .Logf ("%s: airgapping cluster" , time .Now ().Format (time .RFC3339 ))
721+ if err := tc .Airgap (); err != nil {
722+ t .Fatalf ("failed to airgap cluster: %v" , err )
723+ }
724+
725+ t .Logf ("%s: creating /.autorelabel file for SELinux relabeling" , time .Now ().Format (time .RFC3339 ))
726+ if stdout , stderr , err := tc .RunCommandOnNode (0 , []string {"touch" , "/.autorelabel" }); err != nil {
727+ t .Fatalf ("fail to create /.autorelabel file on node %s: %v: %s: %s" , tc .Nodes [0 ], err , stdout , stderr )
728+ }
729+
730+ t .Logf ("%s: rebooting VM for SELinux relabeling" , time .Now ().Format (time .RFC3339 ))
731+ if stdout , stderr , err := tc .RunCommandOnNode (0 , []string {"reboot" }); err != nil {
732+ t .Fatalf ("fail to reboot node %s: %v: %s: %s" , tc .Nodes [0 ], err , stdout , stderr )
733+ }
734+
735+ t .Logf ("%s: waiting for node to reboot" , time .Now ().Format (time .RFC3339 ))
736+ tc .WaitForReboot ()
737+
738+ t .Logf ("%s: setting selinux to Enforcing mode" , time .Now ().Format (time .RFC3339 ))
739+ if stdout , stderr , err := tc .RunCommandOnNode (0 , []string {"setenforce 1" }); err != nil {
740+ t .Fatalf ("fail to set selinux to Enforcing mode %s: %v: %s: %s" , tc .Nodes [0 ], err , stdout , stderr )
741+ }
742+
743+ t .Logf ("%s: preparing embedded cluster airgap files" , time .Now ().Format (time .RFC3339 ))
744+ line := []string {"/usr/local/bin/airgap-prepare.sh" }
745+ if stdout , stderr , err := tc .RunCommandOnNode (0 , line ); err != nil {
746+ t .Fatalf ("fail to prepare airgap files on node %s: %v: %s: %s" , tc .Nodes [0 ], err , stdout , stderr )
747+ }
748+
749+ installSingleNodeWithOptions (t , tc , installOptions {
750+ isAirgap : true ,
751+ version : initialVersion ,
752+ localArtifactMirrorPort : "50001" , // choose an alternate lam port
753+ })
754+
755+ if stdout , stderr , err := tc .SetupPlaywrightAndRunTest ("deploy-app" ); err != nil {
756+ t .Fatalf ("fail to run playwright test deploy-app: %v: %s: %s" , err , stdout , stderr )
757+ }
758+
759+ t .Logf ("%s: checking installation state after app deployment" , time .Now ().Format (time .RFC3339 ))
760+ line = []string {"/usr/local/bin/check-airgap-installation-state.sh" , initialVersion , k8sVersionPrevious ()}
761+ if _ , _ , err := tc .RunCommandOnNode (0 , line ); err != nil {
762+ t .Fatalf ("fail to check installation state: %v" , err )
763+ }
764+
765+ checkNodeJoinCommand (t , tc , 0 )
766+
767+ t .Logf ("%s: running airgap update" , time .Now ().Format (time .RFC3339 ))
768+ line = []string {"/usr/local/bin/airgap-update.sh" }
769+ if _ , _ , err := tc .RunCommandOnNode (0 , line ); err != nil {
770+ t .Fatalf ("fail to run airgap update: %v" , err )
771+ }
772+
773+ appUpgradeVersion := fmt .Sprintf ("appver-%s-upgrade" , os .Getenv ("SHORT_SHA" ))
774+ testArgs := []string {appUpgradeVersion }
775+
776+ t .Logf ("%s: upgrading cluster" , time .Now ().Format (time .RFC3339 ))
777+ if stdout , stderr , err := tc .RunPlaywrightTest ("deploy-upgrade" , testArgs ... ); err != nil {
778+ t .Fatalf ("fail to run playwright test deploy-upgrade: %v: %s: %s" , err , stdout , stderr )
779+ }
780+
781+ checkPostUpgradeState (t , tc )
782+
783+ t .Logf ("%s: test complete" , time .Now ().Format (time .RFC3339 ))
784+ }
785+
697786func TestSingleNodeAirgapUpgradeCustomCIDR (t * testing.T ) {
698787 t .Parallel ()
699788
0 commit comments