Skip to content

Commit a7d0871

Browse files
authored
Add CI check for tests against staging (#123)
* Skip the right set of offline tests Signed-off-by: John Collier <[email protected]> * Add CI check for tests against staging Signed-off-by: John Collier <[email protected]>
1 parent 786ddd9 commit a7d0871

File tree

2 files changed

+71
-47
lines changed

2 files changed

+71
-47
lines changed

.github/workflows/ci.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,20 @@ jobs:
6767
start args: '--addons=ingress'
6868
- name: Run the devfile registry integration tests
6969
run: .ci/run_tests_minikube_linux.sh
70+
71+
test_staging:
72+
name: Test Staging Devfile Registry
73+
runs-on: ubuntu-latest
74+
steps:
75+
- name: Checkout
76+
uses: actions/checkout@v1
77+
- name: Setup Go environment
78+
uses: actions/setup-go@v2
79+
with:
80+
go-version: 1.17
81+
- name: Run the devfile registry integration tests
82+
run: |
83+
# Run the integration tests
84+
cd tests/integration
85+
./docker-build.sh
86+
docker run --env REGISTRY=https://registry.stage.devfile.io --env IS_TEST_REGISTRY=false devfile-registry-integration

tests/integration/pkg/tests/indexserver_tests.go

Lines changed: 54 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -322,54 +322,68 @@ var _ = ginkgo.Describe("[Verify index server is working properly]", func() {
322322
})
323323

324324
ginkgo.It("/devfiles/<devfile>/starter-projects/<starterProject> endpoint should return an offline zip archive for devfile starter project", func() {
325-
resp, err := http.Get(config.Registry + "/devfiles/go/starter-projects/go-starter-offline")
326-
var bytes []byte
325+
if config.IsTestRegistry {
326+
resp, err := http.Get(config.Registry + "/devfiles/go/starter-projects/go-starter-offline")
327+
var bytes []byte
327328

328-
gomega.Expect(err).NotTo(gomega.HaveOccurred())
329-
defer resp.Body.Close()
329+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
330+
defer resp.Body.Close()
330331

331-
bytes, err = ioutil.ReadAll(resp.Body)
332+
bytes, err = ioutil.ReadAll(resp.Body)
332333

333-
gomega.Expect(err).NotTo(gomega.HaveOccurred())
334-
gomega.Expect(resp.StatusCode).To(gomega.Equal(http.StatusAccepted))
335-
gomega.Expect(bytes).ToNot(gomega.BeEmpty())
336-
gomega.Expect(bytes).To(gomega.Satisfy(func(file []byte) bool {
337-
return http.DetectContentType(file) == "application/zip"
338-
}))
334+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
335+
gomega.Expect(resp.StatusCode).To(gomega.Equal(http.StatusAccepted))
336+
gomega.Expect(bytes).ToNot(gomega.BeEmpty())
337+
gomega.Expect(bytes).To(gomega.Satisfy(func(file []byte) bool {
338+
return http.DetectContentType(file) == "application/zip"
339+
}))
340+
} else {
341+
ginkgo.Skip("cannot guarantee test outside of test registry, skipping test")
342+
}
339343
})
340344

341345
ginkgo.It("/devfiles/<devfile>/<version>/starter-projects/<starterProject> endpoint should return an offline zip archive for devfile starter project", func() {
342-
resp, err := http.Get(config.Registry + "/devfiles/go/1.2.0/starter-projects/go-starter-offline")
343-
var bytes []byte
346+
if config.IsTestRegistry {
344347

345-
gomega.Expect(err).NotTo(gomega.HaveOccurred())
346-
defer resp.Body.Close()
348+
resp, err := http.Get(config.Registry + "/devfiles/go/1.2.0/starter-projects/go-starter-offline")
349+
var bytes []byte
347350

348-
bytes, err = ioutil.ReadAll(resp.Body)
351+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
352+
defer resp.Body.Close()
349353

350-
gomega.Expect(err).NotTo(gomega.HaveOccurred())
351-
gomega.Expect(resp.StatusCode).To(gomega.Equal(http.StatusAccepted))
352-
gomega.Expect(bytes).ToNot(gomega.BeEmpty())
353-
gomega.Expect(bytes).To(gomega.Satisfy(func(file []byte) bool {
354-
return http.DetectContentType(file) == "application/zip"
355-
}))
354+
bytes, err = ioutil.ReadAll(resp.Body)
355+
356+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
357+
gomega.Expect(resp.StatusCode).To(gomega.Equal(http.StatusAccepted))
358+
gomega.Expect(bytes).ToNot(gomega.BeEmpty())
359+
gomega.Expect(bytes).To(gomega.Satisfy(func(file []byte) bool {
360+
return http.DetectContentType(file) == "application/zip"
361+
}))
362+
} else {
363+
ginkgo.Skip("cannot guarantee test outside of test registry, skipping test")
364+
}
356365
})
357366

358367
ginkgo.It("/devfiles/<devfile>/starter-projects/<starterProject> endpoint should return an offline zip archive of a subdir for devfile starter project", func() {
359-
resp, err := http.Get(config.Registry + "/devfiles/java-quarkus/starter-projects/community-offline")
360-
var bytes []byte
368+
if config.IsTestRegistry {
361369

362-
gomega.Expect(err).NotTo(gomega.HaveOccurred())
363-
defer resp.Body.Close()
370+
resp, err := http.Get(config.Registry + "/devfiles/java-quarkus/starter-projects/community-offline")
371+
var bytes []byte
364372

365-
bytes, err = ioutil.ReadAll(resp.Body)
373+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
374+
defer resp.Body.Close()
366375

367-
gomega.Expect(err).NotTo(gomega.HaveOccurred())
368-
gomega.Expect(resp.StatusCode).To(gomega.Equal(http.StatusAccepted))
369-
gomega.Expect(bytes).ToNot(gomega.BeEmpty())
370-
gomega.Expect(bytes).To(gomega.Satisfy(func(file []byte) bool {
371-
return http.DetectContentType(file) == "application/zip"
372-
}))
376+
bytes, err = ioutil.ReadAll(resp.Body)
377+
378+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
379+
gomega.Expect(resp.StatusCode).To(gomega.Equal(http.StatusAccepted))
380+
gomega.Expect(bytes).ToNot(gomega.BeEmpty())
381+
gomega.Expect(bytes).To(gomega.Satisfy(func(file []byte) bool {
382+
return http.DetectContentType(file) == "application/zip"
383+
}))
384+
} else {
385+
ginkgo.Skip("cannot guarantee test outside of test registry, skipping test")
386+
}
373387
})
374388

375389
ginkgo.It("/devfiles/<devfile>/starter-projects/<starterProject> endpoint should return an error for an offline starter project file location that doesn't exist", func() {
@@ -384,25 +398,18 @@ var _ = ginkgo.Describe("[Verify index server is working properly]", func() {
384398
})
385399

386400
ginkgo.It("/devfiles/<devfile>/starter-projects/<starterProject> endpoint should return an error for a devfile that doesn't exist", func() {
387-
if config.IsTestRegistry {
388-
resp, err := http.Get(config.Registry + "/devfiles/fake-stack/starter-projects/springbootproject")
401+
resp, err := http.Get(config.Registry + "/devfiles/fake-stack/starter-projects/springbootproject")
389402

390-
gomega.Expect(err).NotTo(gomega.HaveOccurred())
391-
gomega.Expect(resp.StatusCode).To(gomega.Equal(http.StatusNotFound))
392-
} else {
393-
ginkgo.Skip("cannot guarantee test outside of test registry, skipping test")
394-
}
403+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
404+
gomega.Expect(resp.StatusCode).To(gomega.Equal(http.StatusNotFound))
395405

396406
})
397407

398408
ginkgo.It("/devfiles/<devfile>/starter-projects/<starterProject> endpoint should return an error for a starter project that doesn't exist", func() {
399-
if config.IsTestRegistry {
400-
resp, err := http.Get(config.Registry + "/devfiles/java-maven/starter-projects/fake-project")
401409

402-
gomega.Expect(err).NotTo(gomega.HaveOccurred())
403-
gomega.Expect(resp.StatusCode).To(gomega.Equal(http.StatusNotFound))
404-
} else {
405-
ginkgo.Skip("cannot guarantee test outside of test registry, skipping test")
406-
}
410+
resp, err := http.Get(config.Registry + "/devfiles/java-maven/starter-projects/fake-project")
411+
412+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
413+
gomega.Expect(resp.StatusCode).To(gomega.Equal(http.StatusNotFound))
407414
})
408415
})

0 commit comments

Comments
 (0)