Skip to content

Commit

Permalink
WIP: test artifacts
Browse files Browse the repository at this point in the history
Signed-off-by: Or Shoval <[email protected]>
  • Loading branch information
oshoval committed Aug 13, 2024
1 parent 898db52 commit 8d9bbe9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,20 @@ jobs:
- name: Run e2e tests
run: make test-e2e

- name: Find and list the test file
run: |
echo "Searching for test file..."
find . -name "*.log"
- uses: actions/upload-artifact@v4 # upload test results
if: success() || failure() # run this step even if previous step failed
with:
name: test-e2e-results
path: .output/*.xml

- name: Upload logs as artifacts
uses: actions/upload-artifact@v4
if: failure()
with:
name: pod-logs
path: .output/*.log
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ test-e2e:
export PATH=$$(pwd)/.output/ovn-kubernetes/bin:$${PATH} && \
export REPORT_PATH=$$(pwd)/.output/ && \
cd test/e2e && \
go test -test.v --ginkgo.v --test.timeout=${E2E_TEST_TIMEOUT} ${E2E_TEST_ARGS} --ginkgo.junit-report=$${REPORT_PATH}/test-e2e.junit.xml
go test -test.v --failfast --ginkgo.v --test.timeout=${E2E_TEST_TIMEOUT} ${E2E_TEST_ARGS} --ginkgo.junit-report=$${REPORT_PATH}/test-e2e.junit.xml

.PHONY: lint
lint: golangci-lint ## Run golangci-lint linter & yamllint
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package e2e

import (
"fmt"
"os"
"testing"

. "github.com/onsi/ginkgo/v2"
Expand All @@ -36,6 +38,10 @@ var _ = BeforeSuite(func() {

// Run e2e tests using the Ginkgo runner.
func TestE2E(t *testing.T) {
if err := os.MkdirAll(".output", 0755); err != nil {
panic(fmt.Sprintf("Error creating directory: %v", err))
}

RegisterFailHandler(Fail)
RunSpecs(t, "kubevirt-ipam-controller e2e suite")
}
18 changes: 16 additions & 2 deletions test/e2e/persistentips_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,24 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

var failureCount int = 0

var _ = Describe("Persistent IPs", func() {
JustAfterEach(func() {
if CurrentGinkgoTestDescription().Failed {
if CurrentSpecReport().Failed() {
failureCount++
By("Test failed, collecting logs and artifacts")
podsStatus, stderr, err := kubectl("get", "pods", "-A")
fmt.Printf("kubectl get pods:\n%v\nerror:\n%v\n", podsStatus+stderr, err)
fileName := fmt.Sprintf(".output/try_%d.log", failureCount)
file, err := os.Create(fileName)
if err != nil {
fmt.Println("Error creating file:", err)
return
}
defer file.Close()

fmt.Fprintf(file, "kubectl get pods:\n%v\nerror:\n%v\n", podsStatus, stderr)
//fmt.Printf("kubectl get pods:\n%v\nerror:\n%v\n", podsStatus+stderr, err)
}
})

Expand Down Expand Up @@ -84,6 +96,8 @@ var _ = Describe("Persistent IPs", func() {
WithTimeout(5 * time.Minute).
Should(BeTrue())

Expect(1).To(Equal(2))

By("Wait for IPAMClaim to get created")
Eventually(testenv.IPAMClaimsFromNamespace(vm.Namespace)).
WithTimeout(time.Minute).
Expand Down

0 comments on commit 8d9bbe9

Please sign in to comment.