Skip to content

Commit b21c769

Browse files
authored
Merge pull request #2790 from lizardruss/ENG-2328
SSH test improvements
2 parents 26edf30 + 544036b commit b21c769

3 files changed

Lines changed: 42 additions & 10 deletions

File tree

e2e/tests/ssh/ssh.go

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var _ = DevSpaceDescribe("ssh", func() {
4545

4646
// create a new dev command and start it
4747
done := make(chan error)
48-
cancelCtx, cancel := context.WithCancel(context.Background())
48+
cancelCtx, cancel := context.WithCancel(ctx)
4949
ginkgo.DeferCleanup(cancel)
5050

5151
go func() {
@@ -63,23 +63,31 @@ var _ = DevSpaceDescribe("ssh", func() {
6363
done <- devCmd.RunDefault(f)
6464
}()
6565

66+
// Wait for the dev session to start
67+
gomega.Eventually(func(g gomega.Gomega) {
68+
_, err := os.ReadFile("started")
69+
g.Expect(err).NotTo(gomega.HaveOccurred())
70+
}).
71+
WithPolling(time.Second).
72+
WithTimeout(time.Second * 60).
73+
Should(gomega.Succeed())
74+
6675
// connect to the SSH server
6776
gomega.Eventually(func(g gomega.Gomega) {
6877
cmd := exec.Command("ssh", "test.ssh-simple.devspace", "ls")
6978
err := cmd.Run()
7079
g.Expect(err).NotTo(gomega.HaveOccurred())
71-
72-
cancel()
7380
}).
7481
WithPolling(time.Second).
7582
WithTimeout(time.Second * 60).
7683
Should(gomega.Succeed())
7784

85+
cancel()
7886
err = <-done
7987
framework.ExpectNoError(err)
8088
})
8189

82-
ginkgo.It("devspace dev should NOT start an SSH service when disabled with a variable", ginkgo.FlakeAttempts(3), func(ctx context.Context) {
90+
ginkgo.It("devspace dev should NOT start an SSH service when disabled with a variable", func(ctx context.Context) {
8391
tempDir, err := framework.CopyToTempDir("tests/ssh/testdata/ssh-variable")
8492
framework.ExpectNoError(err)
8593
ginkgo.DeferCleanup(framework.CleanupTempDir, initialDir, tempDir)
@@ -90,7 +98,7 @@ var _ = DevSpaceDescribe("ssh", func() {
9098

9199
// create a new dev command and start it
92100
done := make(chan error)
93-
cancelCtx, cancel := context.WithCancel(context.Background())
101+
cancelCtx, cancel := context.WithCancel(ctx)
94102
ginkgo.DeferCleanup(cancel)
95103

96104
go func() {
@@ -110,6 +118,15 @@ var _ = DevSpaceDescribe("ssh", func() {
110118
done <- devCmd.RunDefault(f)
111119
}()
112120

121+
// Wait for the dev session to start
122+
gomega.Eventually(func(g gomega.Gomega) {
123+
_, err := os.ReadFile("started")
124+
g.Expect(err).NotTo(gomega.HaveOccurred())
125+
}).
126+
WithPolling(time.Second).
127+
WithTimeout(time.Second * 60).
128+
Should(gomega.Succeed())
129+
113130
gomega.Eventually(func(g gomega.Gomega) {
114131
cmd := exec.Command("ssh", "test.ssh-variable.devspace", "ls")
115132
out, err := cmd.CombinedOutput()
@@ -121,13 +138,12 @@ var _ = DevSpaceDescribe("ssh", func() {
121138
gomega.ContainSubstring("ssh: connect to host localhost port 10023"),
122139
),
123140
)
124-
125-
cancel()
126141
}).
127142
WithPolling(time.Second).
128143
WithTimeout(time.Second * 60).
129144
Should(gomega.Succeed())
130145

146+
cancel()
131147
cmdErr := <-done
132148
framework.ExpectNoError(cmdErr)
133149
})
@@ -143,7 +159,7 @@ var _ = DevSpaceDescribe("ssh", func() {
143159

144160
// create a new dev command and start it
145161
done := make(chan error)
146-
cancelCtx, cancel := context.WithCancel(context.Background())
162+
cancelCtx, cancel := context.WithCancel(ctx)
147163
ginkgo.DeferCleanup(cancel)
148164

149165
go func() {
@@ -163,18 +179,26 @@ var _ = DevSpaceDescribe("ssh", func() {
163179
done <- devCmd.RunDefault(f)
164180
}()
165181

182+
// Wait for the dev session to start
183+
gomega.Eventually(func(g gomega.Gomega) {
184+
_, err := os.ReadFile("started")
185+
g.Expect(err).NotTo(gomega.HaveOccurred())
186+
}).
187+
WithPolling(time.Second).
188+
WithTimeout(time.Second * 60).
189+
Should(gomega.Succeed())
190+
166191
// connect to the SSH server
167192
gomega.Eventually(func(g gomega.Gomega) {
168193
cmd := exec.Command("ssh", "test.ssh-variable.devspace", "ls")
169194
err := cmd.Run()
170195
g.Expect(err).NotTo(gomega.HaveOccurred())
171-
172-
cancel()
173196
}).
174197
WithPolling(time.Second).
175198
WithTimeout(time.Second * 60).
176199
Should(gomega.Succeed())
177200

201+
cancel()
178202
cmdErr := <-done
179203
framework.ExpectNoError(cmdErr)
180204
})

e2e/tests/ssh/testdata/ssh-simple/devspace.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ deployments:
1313
- image: ${IMAGE}
1414
command: ["sleep"]
1515
args: ["999999999999"]
16+
pipelines:
17+
dev: |
18+
run_default_pipeline dev
19+
echo "started" > started
1620
dev:
1721
test:
1822
imageSelector: ${IMAGE}

e2e/tests/ssh/testdata/ssh-variable/devspace.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ deployments:
1515
- image: ${IMAGE}
1616
command: ["sleep"]
1717
args: ["999999999999"]
18+
pipelines:
19+
dev: |
20+
run_default_pipeline dev
21+
echo "started" > started
1822
dev:
1923
test:
2024
imageSelector: ${IMAGE}

0 commit comments

Comments
 (0)