Skip to content

Commit 84c5944

Browse files
author
sivakami
committed
Create pods for all scenarios.
1 parent f4fd6ba commit 84c5944

File tree

4 files changed

+423
-69
lines changed

4 files changed

+423
-69
lines changed

.pipelines/swiftv2-long-running/template/long-running-pipeline-template.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,14 @@ stages:
179179
echo "==> Downloading Go dependencies"
180180
go mod download
181181
182+
echo "==> Setting up kubeconfig for cluster aks-1"
183+
az aks get-credentials \
184+
--resource-group ${{ parameters.resourceGroupName }} \
185+
--name aks-1 \
186+
--file /tmp/aks-1.kubeconfig \
187+
--overwrite-existing \
188+
--admin
189+
182190
echo "==> Setting up kubeconfig for cluster aks-2"
183191
az aks get-credentials \
184192
--resource-group ${{ parameters.resourceGroupName }} \
@@ -187,7 +195,10 @@ stages:
187195
--overwrite-existing \
188196
--admin
189197
190-
echo "==> Verifying cluster connectivity"
198+
echo "==> Verifying cluster aks-1 connectivity"
199+
kubectl --kubeconfig /tmp/aks-1.kubeconfig get nodes
200+
201+
echo "==> Verifying cluster aks-2 connectivity"
191202
kubectl --kubeconfig /tmp/aks-2.kubeconfig get nodes
192203
193204
echo "==> Running datapath tests"

test/integration/swiftv2/helpers/az_helpers.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"os/exec"
66
"strings"
7+
"time"
78
)
89

910
func runAzCommand(cmd string, args ...string) (string, error) {
@@ -113,3 +114,24 @@ func DeleteNamespace(kubeconfig, namespace string) error {
113114
}
114115
return nil
115116
}
117+
118+
// WaitForPodRunning waits for a pod to reach Running state with retries
119+
func WaitForPodRunning(kubeconfig, namespace, podName string, maxRetries, sleepSeconds int) error {
120+
for attempt := 1; attempt <= maxRetries; attempt++ {
121+
cmd := exec.Command("kubectl", "--kubeconfig", kubeconfig, "get", "pod", podName, "-n", namespace, "-o", "jsonpath={.status.phase}")
122+
out, err := cmd.CombinedOutput()
123+
124+
if err == nil && strings.TrimSpace(string(out)) == "Running" {
125+
fmt.Printf("Pod %s is now Running\n", podName)
126+
return nil
127+
}
128+
129+
if attempt < maxRetries {
130+
fmt.Printf("Pod %s not running yet (attempt %d/%d), status: %s. Waiting %d seconds...\n",
131+
podName, attempt, maxRetries, strings.TrimSpace(string(out)), sleepSeconds)
132+
time.Sleep(time.Duration(sleepSeconds) * time.Second)
133+
}
134+
}
135+
136+
return fmt.Errorf("pod %s did not reach Running state after %d attempts", podName, maxRetries)
137+
}

0 commit comments

Comments
 (0)