From cb16917e15cce3fa05cebe69604bb1386df405b3 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Tue, 14 May 2024 14:55:32 +0000 Subject: [PATCH 1/2] integration: check for test registry on start --- integration/integration_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/integration/integration_test.go b/integration/integration_test.go index 0d1e0480..2b872a1b 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -869,6 +869,7 @@ COPY %s .`, testImageAlpine, inclFile) // TestMain runs before all tests to build the envbuilder image. func TestMain(m *testing.M) { + checkTestRegistry() cleanOldEnvbuilders() ctx := context.Background() // Run the build script to create the envbuilder image. @@ -919,6 +920,22 @@ func createGitServer(t *testing.T, opts gitServerOptions) *httptest.Server { return httptest.NewServer(opts.authMW(gittest.NewServer(fs))) } +func checkTestRegistry() { + resp, err := http.Get("http://localhost:5000/v2/_catalog") + if err != nil { + _, _ = fmt.Printf("Check test registry: %s\n", err.Error()) + _, _ = fmt.Printf("Hint: Did you forget to run `make test-registry`?\n") + os.Exit(1) + } + defer resp.Body.Close() + v := make(map[string][]string) + if err := json.NewDecoder(resp.Body).Decode(&v); err != nil { + _, _ = fmt.Printf("Read test registry catalog: %s\n", err.Error()) + _, _ = fmt.Printf("Hint: Did you forget to run `make test-registry`?\n") + os.Exit(1) + } +} + // cleanOldEnvbuilders removes any old envbuilder containers. func cleanOldEnvbuilders() { ctx := context.Background() From 4f950fa310f966ea3f6e6ca9e91896ba0479ae82 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Tue, 14 May 2024 16:08:27 +0100 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Mathias Fredriksson --- integration/integration_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration/integration_test.go b/integration/integration_test.go index 2b872a1b..52abe783 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -924,14 +924,14 @@ func checkTestRegistry() { resp, err := http.Get("http://localhost:5000/v2/_catalog") if err != nil { _, _ = fmt.Printf("Check test registry: %s\n", err.Error()) - _, _ = fmt.Printf("Hint: Did you forget to run `make test-registry`?\n") + _, _ = fmt.Printf("Hint: Did you run `make test-registry`?\n") os.Exit(1) } defer resp.Body.Close() v := make(map[string][]string) if err := json.NewDecoder(resp.Body).Decode(&v); err != nil { _, _ = fmt.Printf("Read test registry catalog: %s\n", err.Error()) - _, _ = fmt.Printf("Hint: Did you forget to run `make test-registry`?\n") + _, _ = fmt.Printf("Hint: Did you run `make test-registry`?\n") os.Exit(1) } }