Skip to content

Commit 5a3fe0a

Browse files
ryanmorandwillist
andauthored
Uses occam.Source to allow integration specs to run in parallel (#26)
occam.Source duplicates the source code directory and makes it unique by adding a file with unique random content. Co-authored-by: Daniel Thornton <dthornton@pivotal.io>
1 parent 0e8689b commit 5a3fe0a

3 files changed

Lines changed: 28 additions & 12 deletions

File tree

integration/init_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ func TestIntegration(t *testing.T) {
3434
Expect(err).NotTo(HaveOccurred())
3535

3636
bundleInstallURI, err = dagger.PackageBuildpack(bpDir)
37-
Expect(err).ToNot(HaveOccurred())
37+
Expect(err).NotTo(HaveOccurred())
3838

3939
// HACK: we need to fix dagger and the package.sh scripts so that this isn't required
4040
bundleInstallURI = fmt.Sprintf("%s.tgz", bundleInstallURI)
4141

4242
bundlerURI, err = dagger.GetLatestCommunityBuildpack("cloudfoundry", "bundler-cnb")
43-
Expect(err).ToNot(HaveOccurred())
43+
Expect(err).NotTo(HaveOccurred())
4444

4545
mriURI, err = dagger.GetLatestCommunityBuildpack("cloudfoundry", "mri-cnb")
46-
Expect(err).ToNot(HaveOccurred())
46+
Expect(err).NotTo(HaveOccurred())
4747

4848
buildPlanURI, err = dagger.GetLatestCommunityBuildpack("ForestEckhardt", "build-plan")
49-
Expect(err).ToNot(HaveOccurred())
49+
Expect(err).NotTo(HaveOccurred())
5050

5151
defer func() {
5252
dagger.DeleteBuildpack(bundleInstallURI)
@@ -57,7 +57,7 @@ func TestIntegration(t *testing.T) {
5757

5858
SetDefaultEventuallyTimeout(10 * time.Second)
5959

60-
suite := spec.New("Integration", spec.Parallel(), spec.Report(report.Terminal{}))
60+
suite := spec.New("Integration", spec.Report(report.Terminal{}), spec.Parallel())
6161
suite("SimpleApp", testSimpleApp)
6262
suite("Logging", testLogging)
6363

integration/logging_test.go

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

33
import (
44
"fmt"
5+
"os"
56
"path/filepath"
67
"testing"
78

@@ -27,7 +28,9 @@ func testLogging(t *testing.T, context spec.G, it spec.S) {
2728
context("when the buildpack is run with pack build", func() {
2829
var (
2930
image occam.Image
30-
name string
31+
32+
name string
33+
source string
3134
)
3235

3336
it.Before(func() {
@@ -39,19 +42,23 @@ func testLogging(t *testing.T, context spec.G, it spec.S) {
3942
it.After(func() {
4043
Expect(docker.Image.Remove.Execute(image.ID)).To(Succeed())
4144
Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed())
45+
Expect(os.RemoveAll(source)).To(Succeed())
4246
})
4347

4448
it("logs useful information for the user", func() {
4549
var err error
50+
source, err = occam.Source(filepath.Join("testdata", "simple_app"))
51+
Expect(err).NotTo(HaveOccurred())
52+
4653
var logs fmt.Stringer
4754
image, logs, err = pack.WithNoColor().Build.
4855
WithNoPull().
4956
WithBuildpacks(mriURI, bundlerURI, bundleInstallURI, buildPlanURI).
50-
Execute(name, filepath.Join("testdata", "simple_app"))
51-
Expect(err).ToNot(HaveOccurred(), logs.String)
57+
Execute(name, source)
58+
Expect(err).NotTo(HaveOccurred(), logs.String)
5259

5360
buildpackVersion, err := GetGitVersion()
54-
Expect(err).ToNot(HaveOccurred())
61+
Expect(err).NotTo(HaveOccurred())
5562

5663
Expect(logs).To(ContainLines(
5764
fmt.Sprintf("Bundle Install Buildpack %s", buildpackVersion),

integration/simple_app_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"io/ioutil"
66
"net/http"
7+
"os"
78
"path/filepath"
89
"testing"
910

@@ -33,7 +34,8 @@ func testSimpleApp(t *testing.T, context spec.G, it spec.S) {
3334
image occam.Image
3435
container occam.Container
3536

36-
name string
37+
name string
38+
source string
3739
)
3840

3941
it.Before(func() {
@@ -46,14 +48,18 @@ func testSimpleApp(t *testing.T, context spec.G, it spec.S) {
4648
Expect(docker.Container.Remove.Execute(container.ID)).To(Succeed())
4749
Expect(docker.Image.Remove.Execute(image.ID)).To(Succeed())
4850
Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed())
51+
Expect(os.RemoveAll(source)).To(Succeed())
4952
})
5053

5154
it("creates a working OCI image", func() {
5255
var err error
56+
source, err = occam.Source(filepath.Join("testdata", "simple_app"))
57+
Expect(err).NotTo(HaveOccurred())
58+
5359
image, _, err = pack.WithVerbose().Build.
5460
WithBuildpacks(mriURI, bundlerURI, bundleInstallURI, buildPlanURI).
5561
WithNoPull().
56-
Execute(name, filepath.Join("testdata", "simple_app"))
62+
Execute(name, source)
5763
Expect(err).NotTo(HaveOccurred())
5864

5965
container, err = docker.Container.Run.
@@ -78,10 +84,13 @@ func testSimpleApp(t *testing.T, context spec.G, it spec.S) {
7884
context("the version of bundler in the Gemfile.lock is 1.17.x", func() {
7985
it("creates a working OCI image", func() {
8086
var err error
87+
source, err = occam.Source(filepath.Join("testdata", "bundler_version_1_17"))
88+
Expect(err).NotTo(HaveOccurred())
89+
8190
image, _, err = pack.WithVerbose().Build.
8291
WithBuildpacks(mriURI, bundlerURI, bundleInstallURI, buildPlanURI).
8392
WithNoPull().
84-
Execute(name, filepath.Join("testdata", "bundler_version_1_17"))
93+
Execute(name, source)
8594
Expect(err).NotTo(HaveOccurred())
8695

8796
container, err = docker.Container.Run.

0 commit comments

Comments
 (0)