Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-1.26] test: enable cloudprovider_azure metrics print #1504

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1316,10 +1316,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 @@ -66,10 +66,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() {
Expand Down Expand Up @@ -181,10 +182,11 @@ var _ = ginkgo.AfterSuite(func() {
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 @@ -231,7 +233,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
Loading