Skip to content

Commit

Permalink
fix: use of uninitialized global variable (#135)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
pendo324 authored Mar 26, 2024
1 parent e4f2260 commit 02a134d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion tests/compose_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ import (
func ComposeLogs(o *option.Option) {
services := []string{"svc1_compose_logs", "svc2_compose_logs"}
containerNames := []string{"container1_compose_logs", "container2_compose_logs"}
imageNames := []string{localImages[defaultImage], localImages[defaultImage]}

ginkgo.Describe("Compose logs command", func() {
var buildContext string
var composeFilePath string
var imageNames []string

ginkgo.BeforeEach(func() {
imageNames = []string{localImages[defaultImage], localImages[defaultImage]}
command.RemoveAll(o)
buildContext, composeFilePath = createComposeYmlForLogsCmd(services, imageNames, containerNames)
ginkgo.DeferCleanup(os.RemoveAll, buildContext)
Expand Down
4 changes: 3 additions & 1 deletion tests/compose_ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ import (
func ComposePs(o *option.Option) {
services := []string{"svc1_compose_ps", "svc2_compose_ps"}
containerNames := []string{"container1_compose_ps", "container2_compose_ps"}
imageNames := []string{localImages[defaultImage], localImages[defaultImage]}

ginkgo.Describe("Compose ps command", func() {
var composeContext string
var composeFilePath string
var imageNames []string

ginkgo.BeforeEach(func() {
imageNames = []string{localImages[defaultImage], localImages[defaultImage]}
command.RemoveAll(o)
composeContext, composeFilePath = createComposeYmlForPsCmd(services, imageNames, containerNames)
ginkgo.DeferCleanup(os.RemoveAll, composeContext)
Expand Down
4 changes: 3 additions & 1 deletion tests/compose_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ import (
// ComposePull tests functionality of `compose pull` command.
func ComposePull(o *option.Option) {
services := []string{"svc1_compose_pull", "svc2_compose_pull"}
imageNames := []string{localImages[defaultImage], localImages[olderAlpineImage]}
ginkgo.Describe("Compose pull command", func() {
var composeContext string
var composeFilePath string
var imageNames []string

ginkgo.BeforeEach(func() {
imageNames = []string{localImages[defaultImage], localImages[olderAlpineImage]}
command.RemoveAll(o)
composeContext, composeFilePath = createComposeYmlForPullCmd(services, imageNames)
ginkgo.DeferCleanup(os.RemoveAll, composeContext)
Expand Down
4 changes: 3 additions & 1 deletion tests/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ func SetupLocalRegistry(o *option.Option) {
// split image tag according to spec
// https://github.com/distribution/distribution/blob/d0deff9cd6c2b8c82c6f3d1c713af51df099d07b/reference/reference.go
_, name, _ := strings.Cut(ref, "/")
command.Run(o, "pull", ref)
// allow up to a minute for remote pulls to account for external network
// latency/throughput issues or throttling (default is 10 seconds)
command.New(o, "pull", ref).WithTimeoutInSeconds(60).Run()
localRef := fmt.Sprintf("localhost:%d/%s", hostPort, name)
command.Run(o, "tag", ref, localRef)
command.Run(o, "push", localRef)
Expand Down

0 comments on commit 02a134d

Please sign in to comment.