Skip to content

Commit

Permalink
Merge pull request #1491 from kubernetes-sigs/adjust-log-print
Browse files Browse the repository at this point in the history
test: enable cloudprovider_azure metrics print
  • Loading branch information
andyzhangx committed Oct 16, 2023
2 parents e267e63 + 33b8953 commit 902f01b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 20 deletions.
1 change: 1 addition & 0 deletions .trivyignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
CVE-2023-39325
CVE-2023-44487
6 changes: 3 additions & 3 deletions hack/verify-examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ rollout_and_wait() {

APPNAME=$(kubectl apply -f $1 | grep -E "^(:?daemonset|deployment|statefulset|pod)" | awk '{printf $1}')
if [[ -n $(expr "${APPNAME}" : "\(daemonset\|deployment\|statefulset\)" || true) ]]; then
kubectl rollout status $APPNAME --watch --timeout=5m
kubectl rollout status $APPNAME --watch --timeout=10m
else
kubectl wait "${APPNAME}" --for condition=ready --timeout=5m
kubectl wait "${APPNAME}" --for condition=ready --timeout=10m
fi
}

Expand Down Expand Up @@ -63,4 +63,4 @@ for EXAMPLE in "${EXAMPLES[@]}"; do
rollout_and_wait $EXAMPLE
done

echo "deployment examples running completed."
echo "deployment examples running completed."
9 changes: 5 additions & 4 deletions test/e2e/dynamic_provisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1356,10 +1356,11 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() {

// print azure file driver logs before driver restart
azurefileLog := testCmd{
command: "bash",
args: []string{"test/utils/azurefile_log.sh"},
startLog: "===================azurefile log (before restart)===================",
endLog: "====================================================================",
command: "bash",
args: []string{"test/utils/azurefile_log.sh"},
startLog: "===================azurefile log (before restart)===================",
endLog: "====================================================================",
ignoreError: true,
}
execTestCmd([]testCmd{azurefileLog})

Expand Down
25 changes: 16 additions & 9 deletions test/e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ var (
)

type testCmd struct {
command string
args []string
startLog string
endLog string
command string
args []string
startLog string
endLog string
ignoreError bool
}

var _ = ginkgo.BeforeSuite(func(ctx ginkgo.SpecContext) {
Expand Down Expand Up @@ -190,10 +191,11 @@ var _ = ginkgo.AfterSuite(func(ctx ginkgo.SpecContext) {
execTestCmd([]testCmd{createExampleDeployment})

azurefileLog := testCmd{
command: "bash",
args: []string{"test/utils/azurefile_log.sh"},
startLog: "===================azurefile log===================",
endLog: "===================================================",
command: "bash",
args: []string{"test/utils/azurefile_log.sh"},
startLog: "===================azurefile log===================",
endLog: "===================================================",
ignoreError: true,
}
e2eTeardown := testCmd{
command: "make",
Expand Down Expand Up @@ -267,7 +269,12 @@ func execTestCmd(cmds []testCmd) {
cmdSh.Stdout = os.Stdout
cmdSh.Stderr = os.Stderr
err = cmdSh.Run()
gomega.Expect(err).NotTo(gomega.HaveOccurred())
if err != nil {
log.Println(err)
if !cmd.ignoreError {
gomega.Expect(err).NotTo(gomega.HaveOccurred())
}
}
log.Println(cmd.endLog)
}
}
Expand Down
20 changes: 16 additions & 4 deletions test/utils/azurefile_log.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ if [[ "$#" -gt 0 ]]; then
DRIVER=$1
fi

cleanup() {
echo "hit unexpected error during log print, exit 0"
exit 0
}

trap cleanup ERR

echo "print out all nodes status ..."
kubectl get nodes -o wide
echo "======================================================================================"
Expand Down Expand Up @@ -63,7 +70,12 @@ kubectl get pods -n${NS} -l${LABEL} \
| awk 'NR>1 {print $1}' \
| xargs -I {} bash -c "echo 'dumping logs for ${NS}/{}/${DRIVER}' && kubectl logs {} -c${CONTAINER} -n${NS}"

#echo "print out cloudprovider_azure metrics ..."
#echo "======================================================================================"
#ip=`kubectl get svc csi-${DRIVER}-controller -n kube-system | awk '{print $4}'`
#curl http://$ip:29614/metrics
echo "======================================================================================"
ip=`kubectl get svc csi-${DRIVER}-controller -n kube-system | awk '{print $4}'`
if echo "$ip" | grep -q "\."; then
echo "print out cloudprovider_azure metrics ..."
curl http://$ip:29614/metrics
else
echo "csi-$DRIVER-controller service ip is empty"
kubectl get svc csi-$DRIVER-controller -n kube-system
fi

0 comments on commit 902f01b

Please sign in to comment.