Skip to content

Commit 87afdbb

Browse files
authored
Merge pull request #523 from RainbowMango/pr_collect_e2e_logs
enable log collection for e2e testing
2 parents 82d3e69 + e167426 commit 87afdbb

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

.github/workflows/ci.yml

+8
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ jobs:
6565
name: e2e test
6666
needs: build
6767
runs-on: ubuntu-18.04
68+
env:
69+
ARTIFACTS_PATH: ${{ github.workspace }}/karmada-e2e-logs/
6870
steps:
6971
- name: checkout code
7072
uses: actions/checkout@v2
@@ -76,3 +78,9 @@ jobs:
7678
run: hack/karmada-bootstrap.sh
7779
- name: run e2e
7880
run: hack/run-e2e.sh
81+
- name: upload logs
82+
if: always()
83+
uses: actions/upload-artifact@v2
84+
with:
85+
name: karmada_e2e_log
86+
path: ${{ github.workspace }}/karmada-e2e-logs/

hack/run-e2e.sh

+26
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,38 @@ KUBECONFIG_PATH=${KUBECONFIG_PATH:-"${HOME}/.kube"}
1616
KARMADA_APISERVER_KUBECONFIG=${KARMADA_APISERVER_KUBECONFIG:-"$KUBECONFIG_PATH/karmada.config"}
1717
PULL_BASED_CLUSTERS=${PULL_BASED_CLUSTERS:-"member3:$KUBECONFIG_PATH/members.config"}
1818

19+
# KARMADA_RUNNING_ON_KIND indicates if current testing against on karmada that installed on a kind cluster.
20+
# Defaults to true.
21+
# For kind cluster, the kind related logs will be collected after the testing.
22+
KARMADA_RUNNING_ON_KIND=${KARMADA_RUNNING_ON_KIND:-true}
23+
24+
KARMADA_HOST_CLUSTER_NAME=${KARMADA_HOST_CLUSTER_NAME:-"karmada-host"}
25+
26+
ARTIFACTS_PATH=${ARTIFACTS_PATH:-"${HOME}/karmada-e2e-logs"}
27+
mkdir -p "$ARTIFACTS_PATH"
28+
1929
# Install ginkgo
2030
GO111MODULE=on go install github.com/onsi/ginkgo/ginkgo
2131

2232
# Run e2e
2333
export KUBECONFIG=${KARMADA_APISERVER_KUBECONFIG}
2434
export PULL_BASED_CLUSTERS=${PULL_BASED_CLUSTERS}
2535

36+
set +e
2637
ginkgo -v -race -failFast ./test/e2e/
38+
TESTING_RESULT=$?
39+
40+
# Collect logs
41+
echo "Collect logs to $ARTIFACTS_PATH..."
42+
cp "$KARMADA_APISERVER_KUBECONFIG" "$ARTIFACTS_PATH"
43+
44+
if [ "$KARMADA_RUNNING_ON_KIND" = true ]; then
45+
echo "Collecting $KARMADA_HOST_CLUSTER_NAME logs..."
46+
mkdir -p "$ARTIFACTS_PATH/$KARMADA_HOST_CLUSTER_NAME"
47+
kind export logs --name="$KARMADA_HOST_CLUSTER_NAME" "$ARTIFACTS_PATH/$KARMADA_HOST_CLUSTER_NAME"
48+
fi
49+
50+
echo "Collected logs at $ARTIFACTS_PATH:"
51+
ls -al "$ARTIFACTS_PATH"
2752

53+
exit $TESTING_RESULT

0 commit comments

Comments
 (0)