Skip to content

Commit

Permalink
Check from within ginkgo
Browse files Browse the repository at this point in the history
Signed-off-by: jose.vazquez <[email protected]>
  • Loading branch information
josvazg committed Sep 10, 2024
1 parent c7a4338 commit f4d700e
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 26 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/test-e2e-gov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ jobs:
cd test/e2e
ginkgo labels
echo 'Running: AKO_E2E_TEST=1 ginkgo --label-filter="atlas-gov" --timeout 120m --nodes=10 --flake-attempts=1 --randomize-all --race --cover --v --trace --show-nodes-events --output-interceptor-mode=none' && \
AKO_E2E_TEST=1 ginkgo --label-filter="atlas-gov" --timeout 120m --nodes=10 --flake-attempts=1 --randomize-all --race --cover --v --trace --show-node-events --output-interceptor-mode=none --coverpkg=github.com/mongodb/mongodb-atlas-kubernetes/v2/pkg/... | tee .e2e.log
if grep -q "0 Passed" < .e2e.log ; then
echo "No tests were run!"
exit 1
fi
AKO_E2E_TEST=1 ginkgo --label-filter="atlas-gov" --timeout 120m --nodes=10 --flake-attempts=1 --randomize-all --race --cover --v --trace --show-node-events --output-interceptor-mode=none --coverpkg=github.com/mongodb/mongodb-atlas-kubernetes/v2/pkg/...
- name: Upload operator logs
if: ${{ failure() }}
uses: actions/upload-artifact@v4
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,7 @@ jobs:
# no `long-run`, no `broken` tests. `Long-run` tests run as a separate job
[[ $TEST_NAME == 'long-run' ]] && filter='long-run && !broken' || filter="$TEST_NAME"' && !long-run && !broken' && \
echo 'Running: AKO_E2E_TEST=1 ginkgo --label-filter="${filter}" --timeout 120m --nodes=10 --race --cover --v' && \
AKO_E2E_TEST=1 ginkgo --output-interceptor-mode=none --label-filter="${filter}" --timeout 120m --nodes=10 --flake-attempts=1 --race --cover --v --coverpkg=github.com/mongodb/mongodb-atlas-kubernetes/v2/pkg/... | tee .e2e.log
if grep -q "0 Passed" < .e2e.log; then
echo "No tests were run!"
exit 1
fi
AKO_E2E_TEST=1 ginkgo --output-interceptor-mode=none --label-filter="${filter}" --timeout 120m --nodes=10 --flake-attempts=1 --race --cover --v --coverpkg=github.com/mongodb/mongodb-atlas-kubernetes/v2/pkg/...
- name: Upload operator logs
if: ${{ failure() }}
uses: actions/upload-artifact@v4
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/test-int.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,8 @@ jobs:
go install github.com/onsi/gomega/...

cd ${{ matrix.path }}
AKO_INT_TEST=1 ginkgo --label-filter="${TEST_NAME}" --timeout 90m --v --nodes="${PARALLEL_NODES}" --flake-attempts=1 --race --cover --coverpkg=github.com/mongodb/mongodb-atlas-kubernetes/v2/pkg/... | tee .int.log
if grep -q "0 Passed" < .int.log; then
echo "No tests were run!"
exit 1
fi
AKO_INT_TEST=1 ginkgo --label-filter="${TEST_NAME}" --timeout 90m --v --nodes="${PARALLEL_NODES}" --flake-attempts=1 --race --cover --coverpkg=github.com/mongodb/mongodb-atlas-kubernetes/v2/pkg/...

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
Expand Down
6 changes: 1 addition & 5 deletions scripts/e2e_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,4 @@ export MCLI_PUBLIC_API_KEY="${MCLI_PUBLIC_API_KEY:-$public_key}"
export MCLI_PRIVATE_API_KEY="${MCLI_PRIVATE_API_KEY:-$private_key}"
export MCLI_ORG_ID="${MCLI_ORG_ID:-$org_id}"
export IMAGE_URL="${image}" #for helm chart
AKO_E2E_TEST=1 ginkgo --race --label-filter="${focus_key}" --timeout 120m -vv test/e2e/ | tee .e2e.log
if grep -q "0 Passed" < .e2e.log; then
echo "No tests were run!"
exit 1
fi
AKO_E2E_TEST=1 ginkgo --race --label-filter="${focus_key}" --timeout 120m -vv test/e2e/
12 changes: 6 additions & 6 deletions scripts/int_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ if [ -z "${label+x}" ]; then
label=""
fi

cluster_wide_labels=("ClusterWide" "two" "potatoes" "bananas" "three" "apples")

int_test_folder=int
if [[ ${cluster_wide_labels[@]} =~ ${label} ]]; then
int_test_folder=int/clusterwide
fi
public_key=$(grep "ATLAS_PUBLIC_KEY" .actrc | cut -d "=" -f 2)
private_key=$(grep "ATLAS_PRIVATE_KEY" .actrc | cut -d "=" -f 2)
org_id=$(grep "ATLAS_ORG_ID" .actrc | cut -d "=" -f 2)
Expand All @@ -16,9 +21,4 @@ export MCLI_PUBLIC_API_KEY="${MCLI_PUBLIC_API_KEY:-$public_key}"
export MCLI_PRIVATE_API_KEY="${MCLI_PRIVATE_API_KEY:-$private_key}"
export MCLI_ORG_ID="${MCLI_ORG_ID:-$org_id}"

AKO_INT_TEST=1 ginkgo run --race --label-filter="${label}" --timeout 80m -v ./test/int ./test/int/clusterwide -coverprofile cover.out | tee .int.log
lines=$(grep -c "0 Passed" < .int.log)
if [ "$lines" -eq 2 ]; then
echo "No tests were run"
exit 1
fi
AKO_INT_TEST=1 ginkgo run --race --label-filter="${label}" --timeout 80m -v ./test/${int_test_folder} -coverprofile cover.out
4 changes: 4 additions & 0 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ var _ = BeforeSuite(func() {
GinkgoWriter.Write([]byte("========================End of Before==============================\n"))
})

var _ = ReportAfterSuite("Ensure test suite was not empty", func(r Report) {
Expect(r.PreRunStats.SpecsThatWillRun > 0).To(BeTrue(), "Suite must run at least 1 test")
})

// checkUpEnvironment initial check setup
func checkUpEnvironment() {
Expect(os.Getenv("MCLI_ORG_ID")).ShouldNot(BeEmpty(), "Please, setup MCLI_ORG_ID environment variable")
Expand Down
4 changes: 4 additions & 0 deletions test/int/clusterwide/integration_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,7 @@ var _ = AfterSuite(func() {
Expect(err).ToNot(HaveOccurred())
})
})

var _ = ReportAfterSuite("Ensure test suite was not empty", func(r Report) {
Expect(r.PreRunStats.SpecsThatWillRun > 0).To(BeTrue(), "Suite must run at least 1 test")
})
4 changes: 4 additions & 0 deletions test/int/integration_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ var _ = SynchronizedAfterSuite(func() {}, func() {
})
})

var _ = ReportAfterSuite("Ensure test suite was not empty", func(r Report) {
Expect(r.PreRunStats.SpecsThatWillRun > 0).To(BeTrue(), "Suite must run at least 1 test")
})

func defaultTimeouts() {
SetDefaultEventuallyTimeout(EventuallyTimeout)
SetDefaultEventuallyPollingInterval(PollingInterval)
Expand Down

0 comments on commit f4d700e

Please sign in to comment.