Skip to content

Commit

Permalink
Improve readability of results
Browse files Browse the repository at this point in the history
Signed-off-by: Kanha gupta <kanhag4163@gmail.com>
  • Loading branch information
kanha-gupta committed May 7, 2024
1 parent a2c4158 commit b123bed
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -741,8 +741,8 @@ jobs:
path: log.tar.gz
retention-days: 30

run-post-installation-checks:
name: Test connectivity using 'antctl check' command
run-installation-checks:
name: Test installation using 'antctl check' command
needs: [ build-antrea-coverage-image ]
runs-on: [ ubuntu-latest ]
steps:
Expand Down Expand Up @@ -772,12 +772,15 @@ jobs:
- name: Create Kind Cluster
run: |
./ci/kind/kind-setup.sh create kind --ip-family dual
- name: Deploy Antrea
run: |
kubectl apply -f build/yamls/antrea.yml
- name: Build antctl binary
run: |
make antctl-linux
- name: Run Pre checks
run: |
/bin/antctl-linux check cluster
- name: Deploy Antrea
run: |
kubectl apply -f build/yamls/antrea.yml
- name: Run antctl command
run: |
./bin/antctl-linux check installation
Expand Down
25 changes: 22 additions & 3 deletions pkg/antctl/raw/check/cluster/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"os"
"time"

"github.com/fatih/color"
"github.com/spf13/cobra"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -88,16 +89,22 @@ func Run(o *options) error {
if err := testContext.setup(ctx); err != nil {
return err
}
var numSuccess, numFailure int
for name, test := range testsRegistry {
testContext.Header("Running test: %s", name)
if err := test.Run(ctx, testContext); err != nil {
testContext.Header("Test %s failed: %s", name, err)
testContext.Fail("Test %s failed: %v", name, err)
numFailure++
} else {
testContext.Header("Test %s passed", name)
testContext.Success("Test %s passed", name)
numSuccess++
}
}
testContext.Log("Test finished")
testContext.Log("Test finished: %v tests succeeded, %v tests failed ", numSuccess, numFailure)
check.Teardown(ctx, testContext.client, testContext.clusterName, testContext.namespace)
if numFailure > 0 {
return fmt.Errorf("%v/%v tests failed", numFailure, len(testsRegistry))
}
return nil
}

Expand Down Expand Up @@ -184,6 +191,18 @@ func (t *testContext) Log(format string, a ...interface{}) {
fmt.Fprintf(os.Stdout, fmt.Sprintf("[%s] ", t.clusterName)+format+"\n", a...)
}

func (t *testContext) Success(format string, a ...interface{}) {
fmt.Fprintf(os.Stdout, fmt.Sprintf("[%s] ", t.clusterName)+color.GreenString(format, a...)+"\n")
}

func (t *testContext) Fail(format string, a ...interface{}) {
fmt.Fprintf(os.Stdout, fmt.Sprintf("[%s] ", t.clusterName)+color.RedString(format, a...)+"\n")
}

func (t *testContext) Warning(format string, a ...interface{}) {
fmt.Fprintf(os.Stdout, fmt.Sprintf("[%s] ", t.clusterName)+color.YellowString(format, a...)+"\n")
}

func (t *testContext) Header(format string, a ...interface{}) {
t.Log("-------------------------------------------------------------------------------------------")
t.Log(format, a...)
Expand Down

0 comments on commit b123bed

Please sign in to comment.