@@ -1564,111 +1564,129 @@ func TestMultiNodeAirgapHAInstallation(t *testing.T) {
1564
1564
1565
1565
RequireEnvVars (t , []string {"SHORT_SHA" })
1566
1566
1567
- tc := cmx .NewCluster (& cmx.ClusterInput {
1568
- T : t ,
1569
- Nodes : 4 ,
1570
- Distribution : "ubuntu" ,
1571
- Version : "22.04" ,
1572
- InstanceType : "r1.medium" ,
1573
- SupportBundleNodeIndex : 2 ,
1574
- })
1575
- defer tc .Cleanup ()
1576
-
1577
- t .Logf ("%s: downloading airgap files on nodes" , time .Now ().Format (time .RFC3339 ))
1578
- initialVersion := fmt .Sprintf ("appver-%s" , os .Getenv ("SHORT_SHA" ))
1579
- upgradeVersion := fmt .Sprintf ("appver-%s-upgrade" , os .Getenv ("SHORT_SHA" ))
1567
+ t .Logf ("%s: downloading airgap files" , time .Now ().Format (time .RFC3339 ))
1568
+ airgapInstallBundlePath := "/tmp/airgap-install-bundle.tar.gz"
1569
+ airgapUpgradeBundlePath := "/tmp/airgap-upgrade-bundle.tar.gz"
1580
1570
runInParallel (t ,
1581
1571
func (t * testing.T ) error {
1582
- return downloadAirgapBundleOnNode (t , tc , 0 , initialVersion , AirgapInstallBundlePath , AirgapLicenseID )
1583
- },
1584
- func (t * testing.T ) error {
1585
- return downloadAirgapBundleOnNode (t , tc , 0 , upgradeVersion , AirgapUpgradeBundlePath , AirgapLicenseID )
1572
+ return downloadAirgapBundle (t , fmt .Sprintf ("appver-%s" , os .Getenv ("SHORT_SHA" )), airgapInstallBundlePath , AirgapLicenseID )
1573
+ }, func (t * testing.T ) error {
1574
+ return downloadAirgapBundle (t , fmt .Sprintf ("appver-%s-upgrade" , os .Getenv ("SHORT_SHA" )), airgapUpgradeBundlePath , AirgapLicenseID )
1586
1575
},
1587
1576
)
1588
1577
1589
- // install "expect" dependency on node 3 as that's where the HA join command will run.
1590
- t .Logf ("%s: installing expect package on node 3" , time .Now ().Format (time .RFC3339 ))
1591
- if stdout , stderr , err := tc .RunCommandOnNode (3 , []string {"apt-get" , "install" , "-y" , "expect" }); err != nil {
1592
- t .Fatalf ("fail to install expect package on node 3: %v: %s: %s" , err , stdout , stderr )
1593
- }
1578
+ tc := lxd .NewCluster (& lxd.ClusterInput {
1579
+ T : t ,
1580
+ Nodes : 4 ,
1581
+ Image : "debian/12" ,
1582
+ WithProxy : true ,
1583
+ AirgapInstallBundlePath : airgapInstallBundlePath ,
1584
+ AirgapUpgradeBundlePath : airgapUpgradeBundlePath ,
1585
+ SupportBundleNodeIndex : 2 ,
1586
+ })
1587
+ defer tc .Cleanup ()
1594
1588
1595
- t . Logf ( "%s: airgapping cluster" , time . Now (). Format ( time . RFC3339 ))
1596
- if err := tc . Airgap ( ); err != nil {
1597
- t .Fatalf ("failed to airgap cluster : %v" , err )
1589
+ // delete airgap bundles once they've been copied to the nodes
1590
+ if err := os . Remove ( airgapInstallBundlePath ); err != nil {
1591
+ t .Logf ("failed to remove airgap install bundle : %v" , err )
1598
1592
}
1599
1593
1594
+ // install "curl" dependency on node 0 for app version checks.
1595
+ tc .InstallTestDependenciesDebian (t , 0 , true )
1596
+
1597
+ // install "expect" dependency on node 3 as that's where the HA join command will run.
1598
+ tc .InstallTestDependenciesDebian (t , 3 , true )
1599
+
1600
1600
t .Logf ("%s: preparing embedded cluster airgap files on node 0" , time .Now ().Format (time .RFC3339 ))
1601
1601
line := []string {"airgap-prepare.sh" }
1602
- if stdout , stderr , err := tc .RunCommandOnNode (0 , line ); err != nil {
1603
- t .Fatalf ("fail to prepare airgap files on node 0: %v: % s: %s " , err , stdout , stderr )
1602
+ if _ , _ , err := tc .RunCommandOnNode (0 , line ); err != nil {
1603
+ t .Fatalf ("fail to prepare airgap files on node % s: %v " , tc . Nodes [ 0 ], err )
1604
1604
}
1605
1605
1606
- installSingleNodeWithOptions (t , tc , installOptions {
1607
- isAirgap : true ,
1608
- })
1606
+ t .Logf ("%s: installing embedded-cluster on node 0" , time .Now ().Format (time .RFC3339 ))
1607
+ line = []string {"single-node-airgap-install.sh" , os .Getenv ("SHORT_SHA" )}
1608
+ if _ , _ , err := tc .RunCommandOnNode (0 , line ); err != nil {
1609
+ t .Fatalf ("fail to install embedded-cluster on node %s: %v" , tc .Nodes [0 ], err )
1610
+ }
1609
1611
1610
1612
checkWorkerProfile (t , tc , 0 )
1611
1613
1612
- if stdout , stderr , err := tc .SetupPlaywrightAndRunTest ("deploy-app" ); err != nil {
1613
- t .Fatalf ("fail to run playwright test deploy-app: %v: %s: %s" , err , stdout , stderr )
1614
+ // remove artifacts after installation to save space
1615
+ line = []string {"rm" , "/assets/release.airgap" }
1616
+ if _ , _ , err := tc .RunCommandOnNode (0 , line ); err != nil {
1617
+ t .Fatalf ("fail to remove airgap bundle on node %s: %v" , tc .Nodes [0 ], err )
1618
+ }
1619
+ // do not remove the embedded-cluster binary as it is used for reset
1620
+
1621
+ if _ , _ , err := tc .SetupPlaywrightAndRunTest ("deploy-app" ); err != nil {
1622
+ t .Fatalf ("fail to run playwright test deploy-app: %v" , err )
1614
1623
}
1615
1624
1616
1625
t .Logf ("%s: checking installation state after app deployment" , time .Now ().Format (time .RFC3339 ))
1617
1626
line = []string {"check-airgap-installation-state.sh" , fmt .Sprintf ("appver-%s" , os .Getenv ("SHORT_SHA" )), k8sVersion ()}
1618
- if stdout , stderr , err := tc .RunCommandOnNode (0 , line ); err != nil {
1619
- t .Fatalf ("fail to check installation state: %v: %s: %s " , err , stdout , stderr )
1627
+ if _ , _ , err := tc .RunCommandOnNode (0 , line ); err != nil {
1628
+ t .Fatalf ("fail to check installation state: %v" , err )
1620
1629
}
1621
1630
1622
1631
// join a worker
1623
1632
joinWorkerNode (t , tc , 1 )
1624
1633
checkWorkerProfile (t , tc , 1 )
1625
-
1626
1634
// join a controller
1627
1635
joinControllerNode (t , tc , 2 )
1628
1636
checkWorkerProfile (t , tc , 2 )
1629
-
1630
1637
// join another controller in HA mode
1631
1638
joinControllerNodeWithOptions (t , tc , 3 , joinOptions {isHA : true })
1632
1639
checkWorkerProfile (t , tc , 3 )
1633
-
1634
1640
// wait for the nodes to report as ready.
1635
1641
waitForNodes (t , tc , 4 , nil )
1636
1642
1637
1643
t .Logf ("%s: checking installation state after enabling high availability" , time .Now ().Format (time .RFC3339 ))
1638
1644
line = []string {"check-airgap-post-ha-state.sh" , os .Getenv ("SHORT_SHA" ), k8sVersion ()}
1639
- if stdout , stderr , err := tc .RunCommandOnNode (0 , line ); err != nil {
1640
- t .Fatalf ("fail to check post ha state: %v: %s: %s " , err , stdout , stderr )
1645
+ if _ , _ , err := tc .RunCommandOnNode (0 , line ); err != nil {
1646
+ t .Fatalf ("fail to check post ha state: %v" , err )
1641
1647
}
1642
1648
1643
1649
t .Logf ("%s: running airgap update" , time .Now ().Format (time .RFC3339 ))
1644
1650
line = []string {"airgap-update.sh" }
1645
- if stdout , stderr , err := tc .RunCommandOnNode (0 , line ); err != nil {
1646
- t .Fatalf ("fail to run airgap update: %v: %s: %s" , err , stdout , stderr )
1651
+ if _ , _ , err := tc .RunCommandOnNode (0 , line ); err != nil {
1652
+ t .Fatalf ("fail to run airgap update: %v" , err )
1653
+ }
1654
+ // remove the airgap bundle and binary after upgrade
1655
+ line = []string {"rm" , "/assets/upgrade/release.airgap" }
1656
+ if _ , _ , err := tc .RunCommandOnNode (0 , line ); err != nil {
1657
+ t .Fatalf ("fail to remove airgap bundle on node %s: %v" , tc .Nodes [0 ], err )
1647
1658
}
1648
1659
1649
1660
appUpgradeVersion := fmt .Sprintf ("appver-%s-upgrade" , os .Getenv ("SHORT_SHA" ))
1650
1661
testArgs := []string {appUpgradeVersion }
1651
1662
1652
1663
t .Logf ("%s: upgrading cluster" , time .Now ().Format (time .RFC3339 ))
1653
- if stdout , stderr , err := tc .RunPlaywrightTest ("deploy-upgrade" , testArgs ... ); err != nil {
1654
- t .Fatalf ("fail to run playwright test deploy-app: %v: %s: %s " , err , stdout , stderr )
1664
+ if _ , _ , err := tc .RunPlaywrightTest ("deploy-upgrade" , testArgs ... ); err != nil {
1665
+ t .Fatalf ("fail to run playwright test deploy-app: %v" , err )
1655
1666
}
1656
1667
1657
- checkPostUpgradeState (t , tc )
1668
+ t .Logf ("%s: checking installation state after upgrade" , time .Now ().Format (time .RFC3339 ))
1669
+ line = []string {"check-postupgrade-state.sh" , k8sVersion (), ecUpgradeTargetVersion ()}
1670
+ if _ , _ , err := tc .RunCommandOnNode (0 , line ); err != nil {
1671
+ t .Fatalf ("fail to check postupgrade state: %v" , err )
1672
+ }
1658
1673
1659
- stdout , stderr , err := resetInstallationWithError (t , tc , 0 , resetInstallationOptions {})
1674
+ bin := "embedded-cluster"
1675
+ t .Logf ("%s: resetting controller node 0 with bin %q" , time .Now ().Format (time .RFC3339 ), bin )
1676
+ stdout , stderr , err := tc .RunCommandOnNode (0 , []string {bin , "reset" , "--yes" })
1660
1677
if err != nil {
1661
- t .Fatalf ("fail to reset the installation on node 0: %v: %s: %s" , err , stdout , stderr )
1678
+ t .Logf ("stdout: %s\n stderr: %s" , stdout , stderr )
1679
+ t .Fatalf ("fail to remove controller node 0 %s:" , err )
1662
1680
}
1663
1681
if ! strings .Contains (stdout , "High-availability is enabled and requires at least three controller-test nodes" ) {
1664
- t .Logf ("reset output does not contain the ha warning: stdout: %s\n stderr: %s" , stdout , stderr )
1682
+ t .Errorf ("reset output does not contain the ha warning" )
1683
+ t .Logf ("stdout: %s\n stderr: %s" , stdout , stderr )
1665
1684
}
1666
1685
1667
- stdout , stderr , err = tc .RunCommandOnNode (2 , []string {"check-nodes-removed.sh" , "3" })
1686
+ stdout , _ , err = tc .RunCommandOnNode (2 , []string {"check-nodes-removed.sh" , "3" })
1668
1687
if err != nil {
1669
1688
t .Fatalf ("fail to check nodes removed: %v: %s: %s" , err , stdout , stderr )
1670
1689
}
1671
-
1672
1690
t .Logf ("%s: checking nllb" , time .Now ().Format (time .RFC3339 ))
1673
1691
line = []string {"check-nllb.sh" }
1674
1692
if stdout , stderr , err := tc .RunCommandOnNode (2 , line ); err != nil {
0 commit comments