Skip to content

Commit

Permalink
add flag to provide docker test image as tarball
Browse files Browse the repository at this point in the history
some teams would like to use `kiln test` from concourse. That concourse
could be shared, like runway // tpe concourse instances. These, even
using authentication, are getting rate limited against dockerhub.

Effectively to run kiln test, we'd first need to preload the images
required to build the test image ( every FROM arg used in the Dockerfile)
avoid the pull ibeing executed implicitly when docker build is run by `kiln test`

To avoid having to actually build an image ( which would either require
to preload the images for the Dockerfile or being able to pull from dockerhub)
we could use this flag to run `docker load -i $IMAGE_PATH` instead of building.

this way, the test image can be `acquired` via docker proxy registries..
  • Loading branch information
nouseforaname committed Jun 5, 2024
1 parent ff8d61a commit 757c9ec
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
15 changes: 8 additions & 7 deletions internal/commands/test_tile.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ type TileTestFunction func(ctx context.Context, w io.Writer, configuration test.

type TileTest struct {
Options struct {
TilePath string ` long:"tile-path" default:"." description:"Path to the Tile directory (e.g., ~/workspace/tas/ist)."`
Verbose bool `short:"v" long:"verbose" default:"true" description:"Print info lines. This doesn't affect Ginkgo output."`
Silent bool `short:"s" long:"silent" default:"false" description:"Hide info lines. This doesn't affect Ginkgo output."`
Manifest bool ` long:"manifest" default:"false" description:"Focus the Manifest tests."`
Migrations bool ` long:"migrations" default:"false" description:"Focus the Migration tests."`
Stability bool ` long:"stability" default:"false" description:"Focus the Stability tests."`

TilePath string ` long:"tile-path" default:"." description:"Path to the Tile directory (e.g., ~/workspace/tas/ist)."`
Verbose bool `short:"v" long:"verbose" default:"true" description:"Print info lines. This doesn't affect Ginkgo output."`
Silent bool `short:"s" long:"silent" default:"false" description:"Hide info lines. This doesn't affect Ginkgo output."`
Manifest bool ` long:"manifest" default:"false" description:"Focus the Manifest tests."`
Migrations bool ` long:"migrations" default:"false" description:"Focus the Migration tests."`
Stability bool ` long:"stability" default:"false" description:"Focus the Stability tests."`
ImagePath string " long:\"image-path\" "
EnvironmentVars []string `short:"e" long:"environment-variable" description:"Pass environment variable to the test suites. For example --stability -e 'PRODUCT=srt'."`
GingkoFlags string ` long:"ginkgo-flags" default:"-r -p -slowSpecThreshold 15" description:"Flags to pass to the Ginkgo Manifest and Stability test suites."`
}
Expand Down Expand Up @@ -70,6 +70,7 @@ func (cmd TileTest) configuration() (test.Configuration, error) {
RunManifest: cmd.Options.Manifest,
RunMetadata: cmd.Options.Stability,
RunMigrations: cmd.Options.Migrations,
ImagePath: cmd.Options.ImagePath,

GinkgoFlags: cmd.Options.GingkoFlags,
Environment: cmd.Options.EnvironmentVars,
Expand Down
21 changes: 21 additions & 0 deletions internal/commands/test_tile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,27 @@ var _ = Describe("kiln test", func() {
})
})

When("when the a test image is provided via --image-path", func() {
It("it sets the path to be loaded in the configuration", func() {
args := []string{"--image-path", "/tmp/test.file"}

fakeTestFunc := fakes.TestTileFunction{}
fakeTestFunc.Returns(nil)

err := commands.NewTileTestWithCollaborators(&output, fakeTestFunc.Spy).Execute(args)
Expect(err).NotTo(HaveOccurred())

Expect(fakeTestFunc.CallCount()).To(Equal(1))

ctx, w, configuration := fakeTestFunc.ArgsForCall(0)
Expect(ctx).NotTo(BeNil())
Expect(w).NotTo(BeNil())
Expect(configuration.ImagePath).To(Equal("/tmp/test.file"))
Expect(configuration.RunManifest).To(BeFalse())
Expect(configuration.RunMetadata).To(BeFalse())
Expect(configuration.RunMigrations).To(BeFalse())
})
})
When("when the stability test is enabled", func() {
It("it sets the metadata configuration flag", func() {
args := []string{"--stability"}
Expand Down
1 change: 1 addition & 0 deletions internal/test/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ type Configuration struct {
RunMigrations,
RunManifest,
RunMetadata bool
ImagePath string

GinkgoFlags string
Environment []string
Expand Down

0 comments on commit 757c9ec

Please sign in to comment.