Skip to content

Commit 4043814

Browse files
committed
wip of running e2e tests locally 5
1 parent a78cc4e commit 4043814

File tree

2 files changed

+76
-9
lines changed

2 files changed

+76
-9
lines changed

test/e2e/azure_apiserver_ilb.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ import (
8888
"bytes"
8989
"context"
9090
"fmt"
91+
"io"
9192
"os"
9293
"os/exec"
9394
"strings"
@@ -465,8 +466,6 @@ func AzureAPIServerILBSpec(ctx context.Context, inputGetter func() AzureAPIServe
465466
}
466467

467468
func PeerVnets(ctx context.Context, inputGetter func() AzureAPIServerILBSpecInput) {
468-
// TODO: shall I have this shell commands in this func instead ?
469-
Logf("In PeerVnets func")
470469
var (
471470
specName = "azure-apiserver-ilb"
472471
input AzureAPIServerILBSpecInput
@@ -483,15 +482,24 @@ func PeerVnets(ctx context.Context, inputGetter func() AzureAPIServerILBSpecInpu
483482
peer_command := "CLUSTER_NAME=" + input.ClusterName + " source " + peer_vnets_script + " && peer_vnets"
484483
cmd := exec.Command("sh", "-c", peer_command)
485484
Logf("cmd to be run %v", cmd)
486-
output, err := cmd.Output()
487485

486+
// ------------------------ //
487+
// output, err := cmd.Output()
488+
// if err != nil {
489+
// Logf("Error running peer-vnets.sh: %v", err)
490+
// }
491+
// Logf("Output of peer-vnets.sh: %v", string(output))
492+
493+
/*
494+
// Replace the below block with the above block when debugging the peering VNets script
495+
// The below code suppresses the StdOut and StdErr
496+
*/
497+
498+
cmd.Stdout = io.Discard
499+
cmd.Stderr = io.Discard
500+
err := cmd.Run()
488501
if err != nil {
489502
Logf("Error running peer-vnets.sh: %v", err)
490-
Logf("Output: %v", string(output))
491-
Logf("Error: %v", err)
492503
}
493-
Expect(err).NotTo(HaveOccurred())
494-
495-
fmt.Println(string(output))
496-
504+
// ------------------------ //
497505
}

test/e2e/azure_test.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,5 +1265,64 @@ var _ = Describe("Workload cluster creation", func() {
12651265
})
12661266
})
12671267

1268+
Context("Local test: Creating a self-managed VM based cluster using API Server ILB feature gate and fully spec-ed out APIServer ILB template [OPTIONAL][API-Server-ILB][LOCAL]", func() {
1269+
It("with three controlplane node and three worker nodes", func() {
1270+
clusterName = getClusterName(clusterNamePrefix, "apiserver-ilb")
1271+
1272+
// Set the environment variables required for the API Server ILB feature gate
1273+
Expect(os.Setenv("EXP_APISERVER_ILB", "true")).To(Succeed())
1274+
Expect(os.Setenv("AZURE_INTERNAL_LB_PRIVATE_IP", "40.0.0.100")).To(Succeed())
1275+
Expect(os.Setenv("AZURE_VNET_CIDR", "40.0.0.0/8")).To(Succeed())
1276+
Expect(os.Setenv("AZURE_CP_SUBNET_CIDR", "40.0.0.0/16")).To(Succeed())
1277+
Expect(os.Setenv("AZURE_NODE_SUBNET_CIDR", "40.1.0.0/16")).To(Succeed())
1278+
1279+
clusterctl.ApplyClusterTemplateAndWait(ctx, createApplyClusterTemplateInput(
1280+
specName,
1281+
withFlavor("apiserver-ilb"),
1282+
withNamespace(namespace.Name),
1283+
withClusterName(clusterName),
1284+
withControlPlaneMachineCount(3),
1285+
withWorkerMachineCount(2),
1286+
withControlPlaneInterval(specName, "wait-control-plane-ha"),
1287+
withControlPlaneWaiters(clusterctl.ControlPlaneWaiters{
1288+
WaitForControlPlaneInitialized: EnsureControlPlaneInitializedNoAddons,
1289+
}),
1290+
withPostMachinesProvisioned(func() {
1291+
PeerVnets(ctx, func() AzureAPIServerILBSpecInput {
1292+
return AzureAPIServerILBSpecInput{
1293+
BootstrapClusterProxy: bootstrapClusterProxy,
1294+
Cluster: result.Cluster,
1295+
Namespace: namespace,
1296+
ClusterName: clusterName,
1297+
WaitIntervals: e2eConfig.GetIntervals(specName, "wait-worker-nodes"),
1298+
TemplateHasPrivateIPCustomDNSResolution: true,
1299+
}
1300+
})
1301+
}),
1302+
// withPreWaitForCluster(func() {
1303+
// // TODO: only invoke this in local runs
1304+
// // Peer VNets of the mgmt cluster and workload cluster
1305+
//
1306+
// }),
1307+
), result)
1308+
1309+
By("Probing workload cluster with APIServerILB feature gate", func() {
1310+
AzureAPIServerILBSpec(ctx, func() AzureAPIServerILBSpecInput {
1311+
return AzureAPIServerILBSpecInput{
1312+
BootstrapClusterProxy: bootstrapClusterProxy,
1313+
Cluster: result.Cluster,
1314+
Namespace: namespace,
1315+
ClusterName: clusterName,
1316+
ExpectedWorkerNodes: result.ExpectedWorkerNodes(),
1317+
WaitIntervals: e2eConfig.GetIntervals(specName, "wait-worker-nodes"),
1318+
TemplateHasPrivateIPCustomDNSResolution: true,
1319+
}
1320+
})
1321+
})
1322+
1323+
By("PASSED!")
1324+
})
1325+
})
1326+
12681327
// TODO: add a same test as above for a windows cluster
12691328
})

0 commit comments

Comments
 (0)