Skip to content

Commit a1027aa

Browse files
committed
stembuild: timeout values are more forgiving
- cleanup convert_vmdk_command_test.go
1 parent 5a55a32 commit a1027aa

File tree

2 files changed

+39
-46
lines changed

2 files changed

+39
-46
lines changed

stembuild/integration/convert_vmdk_command_test.go

Lines changed: 36 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -16,53 +16,60 @@ import (
1616
)
1717

1818
var _ = Describe("Convert VMDK", func() {
19-
20-
Context("when valid vmdk file", func() {
19+
Context("with valid vmdk file", func() {
20+
var osVersion string
21+
var stembuildVersion string
2122
var stemcellFilename string
2223
var inputVmdk string
2324

24-
Context("stembuild when executed with invalid", func() {
25-
var version string
25+
BeforeEach(func() {
26+
inputVmdk = filepath.Join("..", "test", "data", "expected.vmdk")
27+
})
2628

27-
Context("OS value", func() {
28-
It("of 1709 returns an error", func() {
29-
version = "1709.0"
30-
expectedOSVersionInNameANdManifest := "2016"
31-
var err error
32-
stembuildExecutable, err = helpers.BuildStembuild("9999.1.0")
33-
Expect(err).ToNot(HaveOccurred())
29+
Context("when stembuild is built with an invalid version", func() {
30+
BeforeEach(func() {
31+
osVersion = "9999"
32+
stembuildVersion = "9999.0"
33+
})
3434

35-
stemcellFilename = fmt.Sprintf("bosh-stemcell-%s-vsphere-esxi-windows%s-go_agent.tgz", version, expectedOSVersionInNameANdManifest)
36-
inputVmdk = filepath.Join("..", "test", "data", "expected.vmdk")
35+
It("it returns an error", func() {
36+
stembuildExecutable, err := helpers.BuildStembuild(stembuildVersion)
37+
Expect(err).ToNot(HaveOccurred())
3738

38-
session := helpers.Stembuild(stembuildExecutable, "package", "--vmdk", inputVmdk)
39-
Eventually(session).WithTimeout(20).Should(Exit(1))
40-
Eventually(session.Err).Should(Say(`versioning error; parsed os version is: 9999`))
41-
})
4239

40+
session := helpers.Stembuild(stembuildExecutable, "package", "--vmdk", inputVmdk)
41+
Eventually(session).WithTimeout(60*time.Second).Should(Exit(1))
42+
Eventually(session.Err).Should(Say(fmt.Sprintf(`versioning error; parsed os version is: %s`, osVersion)))
4343
})
4444
})
4545

46-
Context("stembuild when executed", func() {
47-
var osVersion string
48-
var version string
46+
Context("stembuild is built with an valid version", func() {
47+
BeforeEach(func() {
48+
osVersion = "2019"
49+
stembuildVersion = "2019.0"
50+
})
4951

5052
AfterEach(func() {
5153
Expect(os.Remove(stemcellFilename)).To(Succeed())
5254
})
5355

5456
It("creates a valid 2019 stemcell", func() {
55-
56-
var err error
57-
stembuildExecutable, err = helpers.BuildStembuild("2019.0.0")
57+
stembuildExecutable, err := helpers.BuildStembuild(stembuildVersion)
5858
Expect(err).ToNot(HaveOccurred())
5959

60-
osVersion = "2019"
61-
version = "2019.0"
62-
stemcellFilename = fmt.Sprintf("bosh-stemcell-%s-vsphere-esxi-windows%s-go_agent.tgz", version, osVersion)
63-
inputVmdk = filepath.Join("..", "test", "data", "expected.vmdk")
64-
65-
session := expectStembuildToSucceed("package", "--vmdk", inputVmdk, "--outputDir", ".")
60+
stemcellFilename = fmt.Sprintf("bosh-stemcell-%s-vsphere-esxi-windows%s-go_agent.tgz", stembuildVersion, osVersion)
61+
62+
args := []string{"package", "--vmdk", inputVmdk, "--outputDir", "."}
63+
session := helpers.Stembuild(stembuildExecutable, args...)
64+
Eventually(session).WithTimeout(60*time.Second).Should(Exit(0),
65+
fmt.Sprintf(
66+
"Expected %s %s to exit with code 0, exited with code %d\nout: %s\nerr: %s",
67+
stembuildExecutable,
68+
strings.Join(args, " "),
69+
session.ExitCode(),
70+
string(session.Out.Contents()),
71+
string(session.Err.Contents()),
72+
))
6673
Eventually(session).Should(Say(`created stemcell: .*\.tgz`))
6774
Expect(stemcellFilename).To(BeAnExistingFile())
6875

@@ -90,18 +97,3 @@ var _ = Describe("Convert VMDK", func() {
9097
})
9198
})
9299
})
93-
94-
func expectStembuildToSucceed(arguments ...string) *Session {
95-
session := helpers.Stembuild(stembuildExecutable, arguments...)
96-
Eventually(session).WithTimeout(60*time.Second).Should(Exit(0),
97-
fmt.Sprintf(
98-
"Expected %s %s to exit with code 0, exited with code %d\nout: %s\nerr: %s",
99-
stembuildExecutable,
100-
strings.Join(arguments, " "),
101-
session.ExitCode(),
102-
string(session.Out.Contents()),
103-
string(session.Err.Contents()),
104-
))
105-
106-
return session
107-
}

stembuild/integration/version_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package integration_test
22

33
import (
44
"fmt"
5+
"time"
56

67
"github.com/cloudfoundry/bosh-windows-stemcell-builder/stembuild/test/helpers"
78

@@ -26,14 +27,14 @@ var _ = Describe("Version flag", func() {
2627
It("prints version information", func() {
2728
session := helpers.Stembuild(stembuildExecutable, "--version")
2829

29-
Eventually(session).WithTimeout(20).Should(Exit(0))
30+
Eventually(session).WithTimeout(60 * time.Second).Should(Exit(0))
3031
Eventually(session).Should(Say(expectedVersion))
3132
})
3233

3334
It("with command, prints version information and does not run command", func() {
3435
session := helpers.Stembuild(stembuildExecutable, "--version", "package")
3536

36-
Eventually(session).WithTimeout(20).Should(Exit(0))
37+
Eventually(session).WithTimeout(60 * time.Second).Should(Exit(0))
3738
Eventually(session).Should(Say(expectedVersion))
3839
})
3940
})

0 commit comments

Comments
 (0)