Fix dev integration tests not finishing (#5705)

This commit is contained in:
Philippe Martin
2022-04-29 16:03:59 +02:00
committed by GitHub
parent ec56d9d383
commit b09324692d
2 changed files with 10 additions and 17 deletions

View File

@@ -5,6 +5,7 @@ import (
"time"
"github.com/onsi/gomega"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
)
@@ -169,6 +170,12 @@ func (o DevSession) WaitSync() ([]byte, []byte, error) {
return outContents, errContents, nil
}
func (o DevSession) CheckNotSynced(timeout time.Duration) {
Consistently(func() string {
return string(o.session.Out.Contents())
}, timeout).ShouldNot(ContainSubstring("Pushing files..."))
}
// RunDevMode runs a dev session and executes the `inside` code when the dev mode is completely started
// The inside handler is passed the internal session pointer, the contents of the standard and error outputs,
// and a slice of strings - ports - giving the redirections in the form localhost:<port_number> to access ports opened by component

View File

@@ -624,27 +624,13 @@ var _ = Describe("odo dev command tests", func() {
checkSyncedFiles(podName)
})
waitTerminates := func(timeout time.Duration) bool {
done := make(chan bool)
go func() {
_, _, _ = session.WaitSync()
done <- true
}()
select {
case <-time.Tick(timeout):
return false
case <-done:
return true
}
}
When("modifying /testdir/baz.txt file", func() {
BeforeEach(func() {
helper.ReplaceString(newFilePath3, "hello world", "hello world!!!")
})
It("should synchronize it only", func() {
Expect(waitTerminates(20 * time.Second)).To(BeTrue())
_, _, _ = session.WaitSync()
podName = commonVar.CliRunner.GetRunningPodNameByComponent(devfileCmpName, commonVar.Project)
checkSyncedFiles(podName)
})
@@ -656,7 +642,7 @@ var _ = Describe("odo dev command tests", func() {
})
It("should not synchronize it", func() {
Expect(waitTerminates(20 * time.Second)).To(BeFalse())
session.CheckNotSynced(10 * time.Second)
})
})
@@ -666,7 +652,7 @@ var _ = Describe("odo dev command tests", func() {
})
It("should not synchronize it", func() {
Expect(waitTerminates(20 * time.Second)).To(BeFalse())
session.CheckNotSynced(10 * time.Second)
})
})
})