fix flaky e2e

This commit is contained in:
Boshi Lian 2022-10-26 06:08:48 +00:00
parent 630a01fbb6
commit 61fce7bcd9
3 changed files with 17 additions and 12 deletions

View file

@ -25,7 +25,7 @@ jobs:
run: kind create cluster -n sshpipertest
- name: E2E
run: docker-compose up --build --abort-on-container-exit
run: docker-compose up --build --abort-on-container-exit --exit-code-from testrunner
working-directory: e2e
env:
COMPOSE_DOCKER_CLI_BUILD: "1"

View file

@ -41,19 +41,20 @@ services:
- bash
- -c
- |
# kind delete cluster -n sshpipertest &&
(kind get kubeconfig -q -n sshpipertest || kind create cluster -n sshpipertest) &&
docker network connect kind $$(hostname) && # self contain
# kind delete cluster -n sshpipertest
(kind get kubeconfig -q -n sshpipertest || kind create cluster -n sshpipertest)
docker network connect kind $$(hostname) # self contain
docker network connect e2e_default sshpipertest-control-plane
kind export kubeconfig -n sshpipertest --internal
kind load docker-image -n sshpipertest e2e_piper-imageonly &&
kubectl wait --for=condition=ready pod -A --all --timeout=2m &&
kubectl apply -f /kubernetes/crd.yaml &&
kubectl apply -f /kubernetes/workload.yaml &&
#kubectl set image deployment/sshpiper-deployment sshpiper=e2e_piper-imageonly &&
kubectl delete pod -l app=sshpiper &&
#kubectl delete po -l k8s-app=kube-dns -A
kind load docker-image -n sshpipertest e2e_piper-imageonly
kubectl wait --for=condition=ready pod -A --all --timeout=2m
kubectl apply -f /kubernetes/crd.yaml
kubectl apply -f /kubernetes/workload.yaml
#kubectl set image deployment/sshpiper-deployment sshpiper=e2e_piper-imageonly
kubectl wait deployment --all --for condition=Available=True
kubectl port-forward service/sshpiper --pod-running-timeout=2m --address 0.0.0.0 2222:2222
kubectl port-forward service/sshpiper --pod-running-timeout=2m --address 0.0.0.0 2222:2222 &
kubectl logs -f deployment/sshpiper-deployment
privileged: true
depends_on:
- host-publickey

View file

@ -84,7 +84,9 @@ func waitForEndpointReadyWithTimeout(addr string, timeout time.Duration) {
}
func runCmd(cmd string, args ...string) (*exec.Cmd, io.Writer, io.Reader, error) {
c := exec.Command(cmd, args...)
newargs := append([]string{cmd}, args...)
newargs = append([]string{"-i0", "-o0", "-e0"}, newargs...)
c := exec.Command("stdbuf", newargs...)
c.SysProcAttr = &syscall.SysProcAttr{Pdeathsig: syscall.SIGTERM}
f, err := pty.Start(c)
if err != nil {
@ -128,6 +130,8 @@ func enterPassword(stdin io.Writer, stdout io.Reader, password string) {
log.Panic("timeout waiting for password prompt")
return
}
time.Sleep(time.Second) // stdout has no data yet
}
}