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 11d9637 commit 12ac56f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,10 @@ jobs:
with:
name: test-e2e-results
path: .output/*.xml

- name: Upload logs as artifacts
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-logs
path: ./test/e2e/.output/*.log
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")
}
20 changes: 17 additions & 3 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 {
By("Test failed, collecting logs and artifacts")
if CurrentSpecReport().Failed() {
failureCount++
By(fmt.Sprintf("Test failed, collecting logs and artifacts, failure count %d", failureCount))
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 12ac56f

Please sign in to comment.