Skip to content

Commit

Permalink
Merge pull request #523 from RainbowMango/pr_collect_e2e_logs
Browse files Browse the repository at this point in the history
enable log collection for e2e testing
  • Loading branch information
karmada-bot authored Jul 12, 2021
2 parents 82d3e69 + e167426 commit 87afdbb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ jobs:
name: e2e test
needs: build
runs-on: ubuntu-18.04
env:
ARTIFACTS_PATH: ${{ github.workspace }}/karmada-e2e-logs/
steps:
- name: checkout code
uses: actions/checkout@v2
Expand All @@ -76,3 +78,9 @@ jobs:
run: hack/karmada-bootstrap.sh
- name: run e2e
run: hack/run-e2e.sh
- name: upload logs
if: always()
uses: actions/upload-artifact@v2
with:
name: karmada_e2e_log
path: ${{ github.workspace }}/karmada-e2e-logs/
26 changes: 26 additions & 0 deletions hack/run-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,38 @@ KUBECONFIG_PATH=${KUBECONFIG_PATH:-"${HOME}/.kube"}
KARMADA_APISERVER_KUBECONFIG=${KARMADA_APISERVER_KUBECONFIG:-"$KUBECONFIG_PATH/karmada.config"}
PULL_BASED_CLUSTERS=${PULL_BASED_CLUSTERS:-"member3:$KUBECONFIG_PATH/members.config"}

# KARMADA_RUNNING_ON_KIND indicates if current testing against on karmada that installed on a kind cluster.
# Defaults to true.
# For kind cluster, the kind related logs will be collected after the testing.
KARMADA_RUNNING_ON_KIND=${KARMADA_RUNNING_ON_KIND:-true}

KARMADA_HOST_CLUSTER_NAME=${KARMADA_HOST_CLUSTER_NAME:-"karmada-host"}

ARTIFACTS_PATH=${ARTIFACTS_PATH:-"${HOME}/karmada-e2e-logs"}
mkdir -p "$ARTIFACTS_PATH"

# Install ginkgo
GO111MODULE=on go install github.com/onsi/ginkgo/ginkgo

# Run e2e
export KUBECONFIG=${KARMADA_APISERVER_KUBECONFIG}
export PULL_BASED_CLUSTERS=${PULL_BASED_CLUSTERS}

set +e
ginkgo -v -race -failFast ./test/e2e/
TESTING_RESULT=$?

# Collect logs
echo "Collect logs to $ARTIFACTS_PATH..."
cp "$KARMADA_APISERVER_KUBECONFIG" "$ARTIFACTS_PATH"

if [ "$KARMADA_RUNNING_ON_KIND" = true ]; then
echo "Collecting $KARMADA_HOST_CLUSTER_NAME logs..."
mkdir -p "$ARTIFACTS_PATH/$KARMADA_HOST_CLUSTER_NAME"
kind export logs --name="$KARMADA_HOST_CLUSTER_NAME" "$ARTIFACTS_PATH/$KARMADA_HOST_CLUSTER_NAME"
fi

echo "Collected logs at $ARTIFACTS_PATH:"
ls -al "$ARTIFACTS_PATH"

exit $TESTING_RESULT

0 comments on commit 87afdbb

Please sign in to comment.