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

test(*): add pipeline for EE features #83

Merged
merged 1 commit into from
Aug 24, 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
95 changes: 95 additions & 0 deletions .github/workflows/.reusable_e2e_tests_ee.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# This is a BASE reusable workflow used by other workflows for E2E testing with Gateway EE

name: Run E2E Tests - EE

on:
workflow_call:
inputs:
base-url:
type: string
default: http://localhost:8002
gateway-image:
type: string
default: kong/kong:nightly-ubuntu
retries:
type: number
default: 0

env:
GATEWAY_IMAGE: ${{ inputs.gateway-image }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN_PRIVATE_READ }}

jobs:
e2e-tests:
strategy:
matrix:
suite:
- plugins
fail-fast: false
name: ${{ matrix.suite }}
runs-on: ${{ vars.RUNS_ON }}

steps:
- name: Checkout source code
uses: actions/checkout@v3

- name: Download assets
timeout-minutes: 5
uses: actions/download-artifact@v3
with:
name: assets

- name: Unpack assets
run: tar xzvf ./assets.tar.gz

- id: setup-node
name: Setup Node
timeout-minutes: 5
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"

- name: Install Playwright
timeout-minutes: 10
run: |
npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
yarn install:e2e
yarn playwright install chromium

- name: Log in to GitHub Container Registry
timeout-minutes: 1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Start Kong
timeout-minutes: 10
working-directory: ${{ github.workspace }}
run: |
echo "Using image: $GATEWAY_IMAGE"
docker_compose_exit_code=0
docker compose -f .ci/docker-compose.yml up -d kong --wait || docker_compose_exit_code=$?
docker compose -f .ci/docker-compose.yml logs
exit $compose_exit

- name: Run E2E tests - EE
timeout-minutes: 10
env:
KM_TEST_GUI_URL: ${{ inputs.base-url }}
run: |
yarn test:e2e \
--pass-with-no-tests \
--retries ${{ inputs.retries }} \
--reporter=list \
${{ format('specs-ee/{0}/', matrix.suite) }}

- name: Upload results
if: ${{ !cancelled() }}
continue-on-error: true
uses: actions/upload-artifact@v3
with:
name: results-${{ matrix.suite }}
path: tests/playwright/test-results/
retention-days: 1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is a BASE reusable workflow used by other workflows for E2E testing
# This is a BASE reusable workflow used by other workflows for E2E testing with Gateway CE

name: Run E2E Tests
name: Run E2E Tests - OSS

on:
workflow_call:
Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
docker compose -f .ci/docker-compose.yml logs
exit $compose_exit

- name: Run E2E tests
- name: Run E2E tests - OSS
timeout-minutes: 10
env:
KM_TEST_GUI_URL: ${{ inputs.base-url }}
Expand All @@ -94,7 +94,7 @@ jobs:
--pass-with-no-tests \
--retries ${{ inputs.retries }} \
--reporter=list \
${{ matrix.suite }}/
${{ format('specs/{0}/', matrix.suite) }}

- name: Upload results
if: ${{ !cancelled() }}
Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/.reusable_test_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ on:
description: Name of the Gateway image (base) to use
type: string
default: kong/kong:nightly-ubuntu
image-name:
description: Name of the Gateway test image being built
type: string
default: kong-manager
outputs:
gateway-test-image:
description: Name of the Gateway test image being built
value: ${{ jobs.build-and-push-test-image.outputs.image-name }}

env:
GATEWAY_IMAGE: ${{ inputs.gateway-image }} # Important for the "Build image" step. Do not delete.
GATEWAY_TEST_IMAGE: ghcr.io/kong/kong-manager:${{ github.sha }}
GATEWAY_TEST_IMAGE: ghcr.io/kong/${{ inputs.image-name }}:${{ github.sha }}

jobs:
build-and-push-test-image:
Expand Down Expand Up @@ -50,6 +54,14 @@ jobs:
echo "KONG_MANAGER_BUILD_SHA1=${KONG_MANAGER_BUILD_SHA1}" >> $GITHUB_ENV
echo "KONG_MANAGER_BUILD_SHA1 = ${KONG_MANAGER_BUILD_SHA1}"

- name: Log in to Docker Hub
if: ${{ inputs.image-name == 'kong-manager-ee' }}
timeout-minutes: 1
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0
with:
username: ${{ secrets.DOCKER_PULL_USER }}
password: ${{ secrets.DOCKER_PULL_PASSWORD }}

- name: Log in to GitHub Container Registry
timeout-minutes: 1
uses: docker/login-action@v2
Expand Down
33 changes: 25 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,43 @@ jobs:
uses: ./.github/workflows/.reusable_build.yml
secrets: inherit

build-and-push-test-image:
name: Build and Push Test Image to GHCR
build-and-push-test-image-oss:
name: Build and Push Test Image to GHCR - OSS
uses: ./.github/workflows/.reusable_test_image.yml
needs: build
secrets: inherit
with:
gateway-image: kong/kong:nightly-ubuntu

e2e-tests:
name: E2E Tests
needs: build-and-push-test-image
uses: ./.github/workflows/.reusable_e2e_tests.yml
build-and-push-test-image-ee:
name: Build and Push Test Image to GHCR - EE
uses: ./.github/workflows/.reusable_test_image.yml
needs: build
secrets: inherit
with:
gateway-image: kong/kong-gateway-internal:nightly-ubuntu
image-name: kong-manager-ee

e2e-tests-oss:
name: E2E Tests - OSS
needs: build-and-push-test-image-oss
uses: ./.github/workflows/.reusable_e2e_tests_oss.yml
with:
gateway-image: ${{ needs.build-and-push-test-image-oss.outputs.gateway-test-image }}
secrets: inherit

e2e-tests-ee:
name: E2E Tests - EE
needs: build-and-push-test-image-ee
uses: ./.github/workflows/.reusable_e2e_tests_ee.yml
with:
gateway-image: ${{ needs.build-and-push-test-image.outputs.gateway-test-image }}
gateway-image: ${{ needs.build-and-push-test-image-ee.outputs.gateway-test-image }}
secrets: inherit

release:
name: Release
runs-on: ${{ vars.RUNS_ON }}
needs: e2e-tests
needs: [e2e-tests-oss, e2e-tests-ee]
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN_PRIVATE_READ }}

Expand Down
31 changes: 24 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,35 @@ jobs:
uses: ./.github/workflows/.reusable_build.yml
secrets: inherit

build-and-push-test-image:
name: Build and Push Test Image to GHCR
build-and-push-test-image-oss:
name: Build and Push Test Image to GHCR - OSS
uses: ./.github/workflows/.reusable_test_image.yml
needs: build
secrets: inherit
with:
gateway-image: kong/kong:nightly-ubuntu

e2e-tests:
name: E2E Tests
needs: build-and-push-test-image
uses: ./.github/workflows/.reusable_e2e_tests.yml
build-and-push-test-image-ee:
name: Build and Push Test Image to GHCR - EE
uses: ./.github/workflows/.reusable_test_image.yml
needs: build
secrets: inherit
with:
gateway-image: kong/kong-gateway-internal:nightly-ubuntu
image-name: kong-manager-ee

e2e-tests-oss:
name: E2E Tests - OSS
needs: build-and-push-test-image-oss
uses: ./.github/workflows/.reusable_e2e_tests_oss.yml
with:
gateway-image: ${{ needs.build-and-push-test-image-oss.outputs.gateway-test-image }}
secrets: inherit

e2e-tests-ee:
name: E2E Tests - EE
needs: build-and-push-test-image-ee
uses: ./.github/workflows/.reusable_e2e_tests_ee.yml
with:
gateway-image: ${{ needs.build-and-push-test-image.outputs.gateway-test-image }}
gateway-image: ${{ needs.build-and-push-test-image-ee.outputs.gateway-test-image }}
secrets: inherit
2 changes: 1 addition & 1 deletion tests/playwright/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dotenv.config({ path: '../../.env' })

const config: PlaywrightTestConfig = {
reporter: [['junit', { outputFile: './test-results/playwright.xml' }]],
testDir: './specs',
testDir: '.', // Using default value here. Let's keep it here to prevent it from being forgotten in future migrations.
retries: 1,
workers: 1,
use: {
Expand Down
11 changes: 11 additions & 0 deletions tests/playwright/specs-ee/plugins/01-Plugins.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { expect } from '@playwright/test'
import baseTest from '@pw/base-test'

const test = baseTest()

test.describe('PLACEHOLDER', () => {
test('is enterprise edition', async ({ page }) => {
await page.goto('/')
await expect(page.locator('[aria-label="Gateway"] .info-list')).toContainText('enterprise')
})
})
Loading