@@ -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 })
0 commit comments