Skip to content

Commit a78cc4e

Browse files
committed
wip of running e2e tests locally 4
1 parent 03364a3 commit a78cc4e

File tree

4 files changed

+45
-26
lines changed

4 files changed

+45
-26
lines changed

scripts/peer-vnets.sh

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -74,41 +74,41 @@ peer_vnets() {
7474
# ------------------------------------------------------------------------------
7575

7676
echo "--------Peering VNETs--------"
77-
az network vnet wait --resource-group ${AKS_RESOURCE_GROUP} --name ${AKS_MGMT_VNET_NAME} --created --timeout 180
78-
export MGMT_VNET_ID=$(az network vnet show --resource-group ${AKS_RESOURCE_GROUP} --name ${AKS_MGMT_VNET_NAME} --query id --output tsv)
79-
echo " 1/8 ${AKS_MGMT_VNET_NAME} found "
77+
az network vnet wait --resource-group ${AKS_RESOURCE_GROUP:-''} --name ${AKS_MGMT_VNET_NAME:-''} --created --timeout 180
78+
export MGMT_VNET_ID=$(az network vnet show --resource-group ${AKS_RESOURCE_GROUP:-''} --name ${AKS_MGMT_VNET_NAME:-''} --query id --output tsv)
79+
echo " 1/8 ${AKS_MGMT_VNET_NAME:-''} found and ${MGMT_VNET_ID} found"
8080

8181
# wait for workload VNet to be created
82-
az network vnet wait --resource-group ${CLUSTER_NAME} --name ${CLUSTER_NAME}-vnet --created --timeout 180
83-
export WORKLOAD_VNET_ID=$(az network vnet show --resource-group ${CLUSTER_NAME} --name ${CLUSTER_NAME}-vnet --query id --output tsv)
84-
echo " 2/8 ${CLUSTER_NAME}-vnet found"
82+
az network vnet wait --resource-group ${CLUSTER_NAME:-''} --name ${CLUSTER_NAME:-''}-vnet --created --timeout 180
83+
export WORKLOAD_VNET_ID=$(az network vnet show --resource-group ${CLUSTER_NAME:-''} --name ${CLUSTER_NAME:-''}-vnet --query id --output tsv)
84+
echo " 2/8 ${CLUSTER_NAME:-''}-vnet found and ${WORKLOAD_VNET_ID} found"
8585

8686
# peer mgmt vnet
87-
az network vnet peering create --name mgmt-to-${CLUSTER_NAME} --resource-group ${AKS_RESOURCE_GROUP} --vnet-name ${AKS_MGMT_VNET_NAME} --remote-vnet \"${WORKLOAD_VNET_ID}\" --allow-vnet-access true --allow-forwarded-traffic true --only-show-errors --output none
88-
az network vnet peering wait --name mgmt-to-${CLUSTER_NAME} --resource-group ${AKS_RESOURCE_GROUP} --vnet-name ${AKS_MGMT_VNET_NAME} --created --timeout 300 --only-show-errors --output none
89-
echo " 3/8 mgmt-to-${CLUSTER_NAME} peering created in ${AKS_MGMT_VNET_NAME}"
87+
az network vnet peering create --name mgmt-to-${CLUSTER_NAME:-''} --resource-group ${AKS_RESOURCE_GROUP:-''} --vnet-name ${AKS_MGMT_VNET_NAME:-''} --remote-vnet ${WORKLOAD_VNET_ID} --allow-vnet-access true --allow-forwarded-traffic true --only-show-errors --output none
88+
az network vnet peering wait --name mgmt-to-${CLUSTER_NAME:-''} --resource-group ${AKS_RESOURCE_GROUP:-''} --vnet-name ${AKS_MGMT_VNET_NAME:-''} --created --timeout 300 --only-show-errors --output none
89+
echo " 3/8 mgmt-to-${CLUSTER_NAME:-''} peering created in ${AKS_MGMT_VNET_NAME:-''}"
9090

9191
# peer workload vnet
92-
az network vnet peering create --name ${CLUSTER_NAME}-to-mgmt --resource-group ${CLUSTER_NAME} --vnet-name ${CLUSTER_NAME}-vnet --remote-vnet \"${MGMT_VNET_ID}\" --allow-vnet-access true --allow-forwarded-traffic true --only-show-errors --output none
93-
az network vnet peering wait --name ${CLUSTER_NAME}-to-mgmt --resource-group ${CLUSTER_NAME} --vnet-name ${CLUSTER_NAME}-vnet --created --timeout 300 --only-show-errors --output none
94-
echo " 4/8 ${CLUSTER_NAME}-to-mgmt peering created in ${CLUSTER_NAME}-vnet"
92+
az network vnet peering create --name ${CLUSTER_NAME:-''}-to-mgmt --resource-group ${CLUSTER_NAME:-''} --vnet-name ${CLUSTER_NAME:-''}-vnet --remote-vnet ${MGMT_VNET_ID} --allow-vnet-access true --allow-forwarded-traffic true --only-show-errors --output none
93+
az network vnet peering wait --name ${CLUSTER_NAME:-''}-to-mgmt --resource-group ${CLUSTER_NAME:-''} --vnet-name ${CLUSTER_NAME:-''}-vnet --created --timeout 300 --only-show-errors --output none
94+
echo " 4/8 ${CLUSTER_NAME:-''}-to-mgmt peering created in ${CLUSTER_NAME:-''}-vnet"
9595

9696
# create private DNS zone
97-
az network private-dns zone create --resource-group ${CLUSTER_NAME} --name ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com --only-show-errors --output none
98-
az network private-dns zone wait --resource-group ${CLUSTER_NAME} --name ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com --created --timeout 300 --only-show-errors --output none
99-
echo " 5/8 ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com private DNS zone created in ${CLUSTER_NAME}"
97+
az network private-dns zone create --resource-group ${CLUSTER_NAME:-''} --name ${CLUSTER_NAME:-''}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com --only-show-errors --output none
98+
az network private-dns zone wait --resource-group ${CLUSTER_NAME:-''} --name ${CLUSTER_NAME:-''}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com --created --timeout 300 --only-show-errors --output none
99+
echo " 5/8 ${CLUSTER_NAME:-''}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com private DNS zone created in ${CLUSTER_NAME:-''}"
100100

101101
# link private DNS Zone to workload vnet
102-
az network private-dns link vnet create --resource-group ${CLUSTER_NAME} --zone-name ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com --name ${CLUSTER_NAME}-to-mgmt --virtual-network \"${WORKLOAD_VNET_ID}\" --registration-enabled false --only-show-errors --output none
103-
az network private-dns link vnet wait --resource-group ${CLUSTER_NAME} --zone-name ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com --name ${CLUSTER_NAME}-to-mgmt --created --timeout 300 --only-show-errors --output none
104-
echo " 6/8 workload cluster vnet ${CLUSTER_NAME}-vnet linked with private DNS zone"
102+
az network private-dns link vnet create --resource-group ${CLUSTER_NAME:-''} --zone-name ${CLUSTER_NAME:-''}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com --name ${CLUSTER_NAME:-''}-to-mgmt --virtual-network ${WORKLOAD_VNET_ID} --registration-enabled false --only-show-errors --output none
103+
az network private-dns link vnet wait --resource-group ${CLUSTER_NAME:-''} --zone-name ${CLUSTER_NAME:-''}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com --name ${CLUSTER_NAME:-''}-to-mgmt --created --timeout 300 --only-show-errors --output none
104+
echo " 6/8 workload cluster vnet ${CLUSTER_NAME:-''}-vnet linked with private DNS zone"
105105

106106
# link private DNS Zone to mgmt vnet
107-
az network private-dns link vnet create --resource-group ${CLUSTER_NAME} --zone-name ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com --name mgmt-to-${CLUSTER_NAME} --virtual-network \"${MGMT_VNET_ID}\" --registration-enabled false --only-show-errors --output none
108-
az network private-dns link vnet wait --resource-group ${CLUSTER_NAME} --zone-name ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com --name mgmt-to-${CLUSTER_NAME} --created --timeout 300 --only-show-errors --output none
109-
echo " 7/8 management cluster vnet ${AKS_MGMT_VNET_NAME} linked with private DNS zone"
107+
az network private-dns link vnet create --resource-group ${CLUSTER_NAME:-''} --zone-name ${CLUSTER_NAME:-''}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com --name mgmt-to-${CLUSTER_NAME:-''} --virtual-network ${MGMT_VNET_ID} --registration-enabled false --only-show-errors --output none
108+
az network private-dns link vnet wait --resource-group ${CLUSTER_NAME:-''} --zone-name ${CLUSTER_NAME:-''}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com --name mgmt-to-${CLUSTER_NAME:-''} --created --timeout 300 --only-show-errors --output none
109+
echo " 7/8 management cluster vnet ${AKS_MGMT_VNET_NAME:-''} linked with private DNS zone"
110110

111111
# create private DNS zone record
112-
az network private-dns record-set a add-record --resource-group ${CLUSTER_NAME} --zone-name ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com --record-set-name \"@\" --ipv4-address ${AZURE_INTERNAL_LB_PRIVATE_IP} --only-show-errors --output none
113-
echo " 8/8 \"@\" private DNS zone record created to point ${CLUSTER_NAME}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com to ${AZURE_INTERNAL_LB_PRIVATE_IP}"
112+
az network private-dns record-set a add-record --resource-group ${CLUSTER_NAME:-''} --zone-name ${CLUSTER_NAME:-''}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com --record-set-name @ --ipv4-address ${AZURE_INTERNAL_LB_PRIVATE_IP} --only-show-errors --output none
113+
echo " 8/8 \"@\" private DNS zone record created to point ${CLUSTER_NAME:-''}-${APISERVER_LB_DNS_SUFFIX}.${AZURE_LOCATION}.cloudapp.azure.com to ${AZURE_INTERNAL_LB_PRIVATE_IP}"
114114
}

test/e2e/azure_apiserver_ilb.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ import (
8989
"context"
9090
"fmt"
9191
"os"
92+
"os/exec"
9293
"strings"
9394
"time"
9495

@@ -466,14 +467,30 @@ func AzureAPIServerILBSpec(ctx context.Context, inputGetter func() AzureAPIServe
466467
func PeerVnets(ctx context.Context, inputGetter func() AzureAPIServerILBSpecInput) {
467468
// TODO: shall I have this shell commands in this func instead ?
468469
Logf("In PeerVnets func")
470+
var (
471+
specName = "azure-apiserver-ilb"
472+
input AzureAPIServerILBSpecInput
473+
)
474+
475+
input = inputGetter()
476+
Expect(input.ClusterName).NotTo(BeEmpty(), "Invalid argument. input.ClusterName can't be empty when calling %s spec", specName)
477+
478+
peer_vnets_script := e2eConfig.GetVariable(PeerVNetsScriptPath)
479+
Expect(peer_vnets_script).NotTo(BeEmpty(), "PEER_VNETS_SCRIPT_PATH env var is required")
480+
Expect(len(peer_vnets_script)).To(BeNumerically(">", 0), "PEER_VNETS_SCRIPT_PATH should have length greater than 0")
469481

470482
// shell commands
471-
cmd := exec.Command("bash", "-c", "source ./scripts/peer-vnets.sh && peer_vnets")
483+
peer_command := "CLUSTER_NAME=" + input.ClusterName + " source " + peer_vnets_script + " && peer_vnets"
484+
cmd := exec.Command("sh", "-c", peer_command)
485+
Logf("cmd to be run %v", cmd)
486+
output, err := cmd.Output()
472487

473-
output, err := cmd.CombinedOutput()
474488
if err != nil {
475-
return fmt.Errorf("failed to invoke shell function: %w\nOutput: %s", err, string(output))
489+
Logf("Error running peer-vnets.sh: %v", err)
490+
Logf("Output: %v", string(output))
491+
Logf("Error: %v", err)
476492
}
493+
Expect(err).NotTo(HaveOccurred())
477494

478495
fmt.Println(string(output))
479496

test/e2e/common.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ const (
9898
OldAddonProviderUpgradeVersion = "OLD_CAAPH_UPGRADE_VERSION"
9999
LatestAddonProviderUpgradeVersion = "LATEST_CAAPH_UPGRADE_VERSION"
100100
KubernetesVersionAPIUpgradeFrom = "KUBERNETES_VERSION_API_UPGRADE_FROM"
101+
PeerVNetsScriptPath = "PEER_VNETS_SCRIPT_PATH"
101102
)
102103

103104
func Byf(format string, a ...interface{}) {

test/e2e/config/azure-dev.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ variables:
243243
CI_RG: "${CI_RG:-capz-ci}"
244244
USER_IDENTITY: "${USER_IDENTITY:-cloud-provider-user-identity}"
245245
EXP_APISERVER_ILB: "true"
246+
PEER_VNETS_SCRIPT_PATH: "${PWD}/scripts/peer-vnets.sh"
246247

247248
intervals:
248249
default/wait-controllers: ["3m", "10s"]

0 commit comments

Comments
 (0)