Skip to content

Commit 02a134d

Browse files
authored
fix: use of uninitialized global variable (#135)
Issue #, if available: https://github.com/runfinch/finch/actions/runs/8427176493/job/23080891806#step:10:2784 *Description of changes:* - Fixes issue where some tests were using an uninitialized global variable since the assignment statements were executed before ginkgo's `SynchronizedBeforeSuite`, which actually populates `localImages` - Somehow I didn't catch this when I did my local testing before the last release, but I have confirmed this change fixes it locally - Also added a trivial change to allow remote pulls in `SetupLocalRegistry` to take up to 60 seconds *Testing done:* - Local testing - [x] I've reviewed the guidance in CONTRIBUTING.md #### License Acceptance By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. Signed-off-by: Justin Alvarez <[email protected]>
1 parent e4f2260 commit 02a134d

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

tests/compose_logs.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ import (
1919
func ComposeLogs(o *option.Option) {
2020
services := []string{"svc1_compose_logs", "svc2_compose_logs"}
2121
containerNames := []string{"container1_compose_logs", "container2_compose_logs"}
22-
imageNames := []string{localImages[defaultImage], localImages[defaultImage]}
2322

2423
ginkgo.Describe("Compose logs command", func() {
2524
var buildContext string
2625
var composeFilePath string
26+
var imageNames []string
27+
2728
ginkgo.BeforeEach(func() {
29+
imageNames = []string{localImages[defaultImage], localImages[defaultImage]}
2830
command.RemoveAll(o)
2931
buildContext, composeFilePath = createComposeYmlForLogsCmd(services, imageNames, containerNames)
3032
ginkgo.DeferCleanup(os.RemoveAll, buildContext)

tests/compose_ps.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ import (
1919
func ComposePs(o *option.Option) {
2020
services := []string{"svc1_compose_ps", "svc2_compose_ps"}
2121
containerNames := []string{"container1_compose_ps", "container2_compose_ps"}
22-
imageNames := []string{localImages[defaultImage], localImages[defaultImage]}
2322

2423
ginkgo.Describe("Compose ps command", func() {
2524
var composeContext string
2625
var composeFilePath string
26+
var imageNames []string
27+
2728
ginkgo.BeforeEach(func() {
29+
imageNames = []string{localImages[defaultImage], localImages[defaultImage]}
2830
command.RemoveAll(o)
2931
composeContext, composeFilePath = createComposeYmlForPsCmd(services, imageNames, containerNames)
3032
ginkgo.DeferCleanup(os.RemoveAll, composeContext)

tests/compose_pull.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ import (
1818
// ComposePull tests functionality of `compose pull` command.
1919
func ComposePull(o *option.Option) {
2020
services := []string{"svc1_compose_pull", "svc2_compose_pull"}
21-
imageNames := []string{localImages[defaultImage], localImages[olderAlpineImage]}
2221
ginkgo.Describe("Compose pull command", func() {
2322
var composeContext string
2423
var composeFilePath string
24+
var imageNames []string
25+
2526
ginkgo.BeforeEach(func() {
27+
imageNames = []string{localImages[defaultImage], localImages[olderAlpineImage]}
2628
command.RemoveAll(o)
2729
composeContext, composeFilePath = createComposeYmlForPullCmd(services, imageNames)
2830
ginkgo.DeferCleanup(os.RemoveAll, composeContext)

tests/tests.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ func SetupLocalRegistry(o *option.Option) {
100100
// split image tag according to spec
101101
// https://github.com/distribution/distribution/blob/d0deff9cd6c2b8c82c6f3d1c713af51df099d07b/reference/reference.go
102102
_, name, _ := strings.Cut(ref, "/")
103-
command.Run(o, "pull", ref)
103+
// allow up to a minute for remote pulls to account for external network
104+
// latency/throughput issues or throttling (default is 10 seconds)
105+
command.New(o, "pull", ref).WithTimeoutInSeconds(60).Run()
104106
localRef := fmt.Sprintf("localhost:%d/%s", hostPort, name)
105107
command.Run(o, "tag", ref, localRef)
106108
command.Run(o, "push", localRef)

0 commit comments

Comments
 (0)