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

Adding pod logs for UI tests #403

Merged
merged 1 commit into from
Jul 12, 2023
Merged
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
29 changes: 24 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,8 @@ jobs:
env:
BRANCH: ${{ github.base_ref || github.ref_name }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# The Azure Location to store test resources
AZURE_LOCATION: westus3
steps:
# TODO: Do we need to set any specific environment variables for pull_request, push,
# schedule, and workflow_dispatch steps?
- name: Generate output variables
id: gen-id
run: |
Expand All @@ -85,7 +82,7 @@ jobs:
--password ${{ secrets.AZURE_SP_TESTS_PASSWORD }} \
--tenant ${{ secrets.AZURE_SP_TESTS_TENANTID }}
- name: Create Azure resource group
if: ${{ matrix.credential == 'azure' }}
if: matrix.credential == 'azure'
env:
RESOURCE_GROUP: ${{ steps.gen-id.outputs.TEST_RESOURCE_GROUP_PREFIX }}-${{ matrix.name }}
SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTIONID_TESTS }}
Expand Down Expand Up @@ -142,7 +139,8 @@ jobs:
label="radius.dev/application=${{ matrix.app }}"
kubectl wait --for=condition=Ready pod -l $label -n $namespace --timeout=5m
- name: Run Playwright Test
if: ${{ matrix.uiTestFile != '' }}
id: run-playwright-test
if: matrix.uiTestFile != ''
run: |
if [[ "${{ matrix.container }}" != "" ]]; then
rad resource expose containers ${{ matrix.container }} ${{ matrix.args }} --port ${{ matrix.port }} &
Expand All @@ -151,6 +149,19 @@ jobs:
npm ci
npx playwright install --with-deps
npx playwright test ${{ matrix.uiTestFile }}
- name: Get Pod Logs For Failed Tests
if: failure() && matrix.uiTestFile != ''
run: |
# Create pod-logs directory
mkdir -p ui-tests/pod-logs/${{ matrix.name }}
# Get pod logs and save to file
namespace="default-${{ matrix.app }}"
label="radius.dev/application=${{ matrix.app }}"
pod_names=($(kubectl get pods -l $label -n $namespace -o jsonpath='{.items[*].metadata.name}'))
for pod_name in "${pod_names[@]}"; do
kubectl logs $pod_name -n $namespace > ui-tests/pod-logs/${{ matrix.name }}/${pod_name}.txt
done
echo "Pod logs saved to ui-tests/pod-logs/${{ matrix.name }}/"
- name: Upload Playwright Results
uses: actions/upload-artifact@v3
if: always() && matrix.uiTestFile != ''
Expand All @@ -159,6 +170,14 @@ jobs:
path: ui-tests/playwright-report/
retention-days: 30
if-no-files-found: error
- name: Upload Pod Logs
uses: actions/upload-artifact@v3
if: failure() && matrix.uiTestFile != ''
with:
name: ${{ matrix.name }}-pod-logs
path: ui-tests/pod-logs/${{ matrix.name }}
retention-days: 30
if-no-files-found: error
- name: Delete app
run: rad app delete ${{ matrix.app }} -y
- name: Delete Azure resource group
Expand Down
Loading