@@ -534,7 +534,7 @@ func TestSingleNodeAirgapUpgradeUbuntuJammy(t *testing.T) {
534
534
wg := sync.WaitGroup {}
535
535
wg .Add (2 )
536
536
go func () {
537
- downloadAirgapBundle (t , fmt .Sprintf ("appver-%s" , os .Getenv ("SHORT_SHA" )), airgapInstallBundlePath , os .Getenv ("AIRGAP_LICENSE_ID" ))
537
+ downloadAirgapBundle (t , fmt .Sprintf ("appver-%s-previous-k0s " , os .Getenv ("SHORT_SHA" )), airgapInstallBundlePath , os .Getenv ("AIRGAP_LICENSE_ID" ))
538
538
wg .Done ()
539
539
}()
540
540
go func () {
@@ -586,7 +586,7 @@ func TestSingleNodeAirgapUpgradeUbuntuJammy(t *testing.T) {
586
586
}
587
587
588
588
t .Logf ("%s: checking installation state after app deployment" , time .Now ().Format (time .RFC3339 ))
589
- line = []string {"check-airgap-installation-state.sh" , os .Getenv ("SHORT_SHA" )}
589
+ line = []string {"check-airgap-installation-state.sh" , fmt . Sprintf ( "%s-previous-k0s" , os .Getenv ("SHORT_SHA" ) )}
590
590
if _ , _ , err := RunCommandOnNode (t , tc , 0 , line ); err != nil {
591
591
t .Fatalf ("fail to check installation state: %v" , err )
592
592
}
@@ -615,7 +615,7 @@ func TestSingleNodeAirgapUpgradeUbuntuJammy(t *testing.T) {
615
615
t .Logf ("%s: test complete" , time .Now ().Format (time .RFC3339 ))
616
616
}
617
617
618
- func TestMultiNodeAirgapUpgradeUbuntuJammy (t * testing.T ) {
618
+ func TestMultiNodeAirgapUpgradeSameK0s (t * testing.T ) {
619
619
t .Parallel ()
620
620
621
621
t .Logf ("%s: downloading airgap files" , time .Now ().Format (time .RFC3339 ))
@@ -746,6 +746,150 @@ func TestMultiNodeAirgapUpgradeUbuntuJammy(t *testing.T) {
746
746
t .Fatalf ("fail to remove embedded-cluster-upgrade binary on node %s: %v" , tc .Nodes [0 ], err )
747
747
}
748
748
749
+ if _ , _ , err := runPlaywrightTest (t , tc , "deploy-airgap-upgrade" , "true" ); err != nil {
750
+ t .Fatalf ("fail to run playwright test deploy-airgap-upgrade: %v" , err )
751
+ }
752
+
753
+ t .Logf ("%s: checking installation state after upgrade" , time .Now ().Format (time .RFC3339 ))
754
+ line = []string {"check-postupgrade-state.sh" }
755
+ if _ , _ , err := RunCommandOnNode (t , tc , 0 , line ); err != nil {
756
+ t .Fatalf ("fail to check postupgrade state: %v" , err )
757
+ }
758
+
759
+ t .Logf ("%s: test complete" , time .Now ().Format (time .RFC3339 ))
760
+ }
761
+
762
+ func TestMultiNodeAirgapUpgradeUbuntuJammy (t * testing.T ) {
763
+ t .Parallel ()
764
+
765
+ t .Logf ("%s: downloading airgap files" , time .Now ().Format (time .RFC3339 ))
766
+ airgapInstallBundlePath := "/tmp/airgap-install-bundle.tar.gz"
767
+ airgapUpgradeBundlePath := "/tmp/airgap-upgrade-bundle.tar.gz"
768
+ wg := sync.WaitGroup {}
769
+ wg .Add (2 )
770
+ go func () {
771
+ downloadAirgapBundle (t , fmt .Sprintf ("appver-%s-previous-k0s" , os .Getenv ("SHORT_SHA" )), airgapInstallBundlePath , os .Getenv ("AIRGAP_LICENSE_ID" ))
772
+ wg .Done ()
773
+ }()
774
+ go func () {
775
+ downloadAirgapBundle (t , fmt .Sprintf ("appver-%s-upgrade" , os .Getenv ("SHORT_SHA" )), airgapUpgradeBundlePath , os .Getenv ("AIRGAP_LICENSE_ID" ))
776
+ wg .Done ()
777
+ }()
778
+ wg .Wait ()
779
+
780
+ tc := cluster .NewTestCluster (& cluster.Input {
781
+ T : t ,
782
+ Nodes : 2 ,
783
+ Image : "ubuntu/jammy" ,
784
+ WithProxy : true ,
785
+ AirgapInstallBundlePath : airgapInstallBundlePath ,
786
+ AirgapUpgradeBundlePath : airgapUpgradeBundlePath ,
787
+ })
788
+ defer cleanupCluster (t , tc )
789
+
790
+ // delete airgap bundles once they've been copied to the nodes
791
+ if err := os .Remove (airgapInstallBundlePath ); err != nil {
792
+ t .Logf ("failed to remove airgap install bundle: %v" , err )
793
+ }
794
+ if err := os .Remove (airgapUpgradeBundlePath ); err != nil {
795
+ t .Logf ("failed to remove airgap upgrade bundle: %v" , err )
796
+ }
797
+
798
+ // upgrade airgap bundle is only needed on the first node
799
+ line := []string {"rm" , "/tmp/ec-release-upgrade.tgz" }
800
+ if _ , _ , err := RunCommandOnNode (t , tc , 1 , line ); err != nil {
801
+ t .Fatalf ("fail to remove upgrade airgap bundle on node %s: %v" , tc .Nodes [1 ], err )
802
+ }
803
+
804
+ t .Logf ("%s: preparing embedded cluster airgap files on node 0" , time .Now ().Format (time .RFC3339 ))
805
+ line = []string {"airgap-prepare.sh" }
806
+ if _ , _ , err := RunCommandOnNode (t , tc , 0 , line ); err != nil {
807
+ t .Fatalf ("fail to prepare airgap files on node %s: %v" , tc .Nodes [0 ], err )
808
+ }
809
+
810
+ t .Logf ("%s: installing embedded-cluster on node 0" , time .Now ().Format (time .RFC3339 ))
811
+ line = []string {"single-node-airgap-install.sh" }
812
+ if _ , _ , err := RunCommandOnNode (t , tc , 0 , line ); err != nil {
813
+ t .Fatalf ("fail to install embedded-cluster on node %s: %v" , tc .Nodes [0 ], err )
814
+ }
815
+ // remove the airgap bundle and binary after installation
816
+ line = []string {"rm" , "/tmp/release.airgap" }
817
+ if _ , _ , err := RunCommandOnNode (t , tc , 0 , line ); err != nil {
818
+ t .Fatalf ("fail to remove airgap bundle on node %s: %v" , tc .Nodes [0 ], err )
819
+ }
820
+ line = []string {"rm" , "/usr/local/bin/embedded-cluster" }
821
+ if _ , _ , err := RunCommandOnNode (t , tc , 0 , line ); err != nil {
822
+ t .Fatalf ("fail to remove embedded-cluster binary on node %s: %v" , tc .Nodes [0 ], err )
823
+ }
824
+
825
+ if err := setupPlaywright (t , tc ); err != nil {
826
+ t .Fatalf ("fail to setup playwright: %v" , err )
827
+ }
828
+ if _ , _ , err := runPlaywrightTest (t , tc , "deploy-app" ); err != nil {
829
+ t .Fatalf ("fail to run playwright test deploy-app: %v" , err )
830
+ }
831
+
832
+ // generate worker node join command.
833
+ t .Logf ("%s: generating a new worker token command" , time .Now ().Format (time .RFC3339 ))
834
+ stdout , stderr , err := runPlaywrightTest (t , tc , "get-join-worker-command" )
835
+ if err != nil {
836
+ t .Fatalf ("fail to generate worker join token:\n stdout: %s\n stderr: %s" , stdout , stderr )
837
+ }
838
+ workerCommand , err := findJoinCommandInOutput (stdout )
839
+ if err != nil {
840
+ t .Fatalf ("fail to find the join command in the output: %v" , err )
841
+ }
842
+ t .Log ("worker join token command:" , workerCommand )
843
+
844
+ // join the worker node
845
+ t .Logf ("%s: preparing embedded cluster airgap files on worker node" , time .Now ().Format (time .RFC3339 ))
846
+ line = []string {"airgap-prepare.sh" }
847
+ if _ , _ , err := RunCommandOnNode (t , tc , 1 , line ); err != nil {
848
+ t .Fatalf ("fail to prepare airgap files on worker node: %v" , err )
849
+ }
850
+ t .Logf ("%s: joining worker node to the cluster" , time .Now ().Format (time .RFC3339 ))
851
+ if _ , _ , err := RunCommandOnNode (t , tc , 1 , strings .Split (workerCommand , " " )); err != nil {
852
+ t .Fatalf ("fail to join worker node to the cluster: %v" , err )
853
+ }
854
+ // remove the airgap bundle and binary after joining
855
+ line = []string {"rm" , "/tmp/release.airgap" }
856
+ if _ , _ , err := RunCommandOnNode (t , tc , 1 , line ); err != nil {
857
+ t .Fatalf ("fail to remove airgap bundle on worker node: %v" , err )
858
+ }
859
+ line = []string {"rm" , "/usr/local/bin/embedded-cluster" }
860
+ if _ , _ , err := RunCommandOnNode (t , tc , 1 , line ); err != nil {
861
+ t .Fatalf ("fail to remove embedded-cluster binary on worker node: %v" , err )
862
+ }
863
+
864
+ // wait for the nodes to report as ready.
865
+ t .Logf ("%s: all nodes joined, waiting for them to be ready" , time .Now ().Format (time .RFC3339 ))
866
+ stdout , _ , err = RunCommandOnNode (t , tc , 0 , []string {"wait-for-ready-nodes.sh" , "2" })
867
+ if err != nil {
868
+ t .Fatalf ("fail to wait for ready nodes: %v" , err )
869
+ }
870
+ t .Log (stdout )
871
+
872
+ t .Logf ("%s: checking installation state after app deployment" , time .Now ().Format (time .RFC3339 ))
873
+ line = []string {"check-airgap-installation-state.sh" , fmt .Sprintf ("%s-previous-k0s" , os .Getenv ("SHORT_SHA" ))}
874
+ if _ , _ , err := RunCommandOnNode (t , tc , 0 , line ); err != nil {
875
+ t .Fatalf ("fail to check installation state: %v" , err )
876
+ }
877
+
878
+ t .Logf ("%s: running airgap update" , time .Now ().Format (time .RFC3339 ))
879
+ line = []string {"airgap-update.sh" }
880
+ if _ , _ , err := RunCommandOnNode (t , tc , 0 , line ); err != nil {
881
+ t .Fatalf ("fail to run airgap update: %v" , err )
882
+ }
883
+ // remove the airgap bundle and binary after upgrade
884
+ line = []string {"rm" , "/tmp/upgrade/release.airgap" }
885
+ if _ , _ , err := RunCommandOnNode (t , tc , 0 , line ); err != nil {
886
+ t .Fatalf ("fail to remove airgap bundle on node %s: %v" , tc .Nodes [0 ], err )
887
+ }
888
+ line = []string {"rm" , "/usr/local/bin/embedded-cluster-upgrade" }
889
+ if _ , _ , err := RunCommandOnNode (t , tc , 0 , line ); err != nil {
890
+ t .Fatalf ("fail to remove embedded-cluster-upgrade binary on node %s: %v" , tc .Nodes [0 ], err )
891
+ }
892
+
749
893
if _ , _ , err := runPlaywrightTest (t , tc , "deploy-airgap-upgrade" ); err != nil {
750
894
t .Fatalf ("fail to run playwright test deploy-airgap-upgrade: %v" , err )
751
895
}
0 commit comments