Skip to content

Commit

Permalink
Add playwright tests for channel change
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Hines committed Aug 6, 2024
1 parent a19443b commit 3961a04
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/actions/kots-e2e/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ runs:
- name: execute suite "${{ inputs.test-focus }}"
env:
TESTIM_ACCESS_TOKEN: ${{ inputs.testim-access-token }}
REPLICATED_API_TOKEN: ${{ inputs.replicated-api-token }}
KOTS_NAMESPACE: ${{ inputs.kots-namespace }}
run: |
make -C e2e test \
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,40 @@ jobs:
kots-dockerhub-username: '${{ secrets.E2E_DOCKERHUB_USERNAME }}'
kots-dockerhub-password: '${{ secrets.E2E_DOCKERHUB_PASSWORD }}'

validate-change-channel:
runs-on: ubuntu-20.04
needs: [ enable-tests, can-run-ci, build-kots, build-kotsadm, build-e2e, build-kurl-proxy, build-migrations, push-minio, push-rqlite ]
strategy:
fail-fast: false
matrix:
cluster: [
{distribution: kind, version: v1.28.0}
]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: download e2e deps
uses: actions/download-artifact@v4
with:
name: e2e
path: e2e/bin/
- run: docker load -i e2e/bin/e2e-deps.tar
- run: chmod +x e2e/bin/*
- name: download kots binary
uses: actions/download-artifact@v4
with:
name: kots
path: bin/
- run: chmod +x bin/*
- uses: ./.github/actions/kots-e2e
with:
test-focus: 'Change Channel'
kots-namespace: 'change-channel'
k8s-distribution: ${{ matrix.cluster.distribution }}
k8s-version: ${{ matrix.cluster.version }}
replicated-api-token: '${{ secrets.C11Y_MATRIX_TOKEN }}'
kots-dockerhub-username: '${{ secrets.E2E_DOCKERHUB_USERNAME }}'
kots-dockerhub-password: '${{ secrets.E2E_DOCKERHUB_PASSWORD }}'

validate-minimal-rbac-override:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -4130,6 +4164,7 @@ jobs:
- validate-backup-and-restore
- validate-no-required-config
- validate-config
- validate-change-channel
# non-testim tests
- validate-minimal-rbac
- validate-minimal-rbac-override
Expand Down
1 change: 1 addition & 0 deletions e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ test:
docker run --rm -i --net host \
-e TESTIM_ACCESS_TOKEN \
-v $(BIN_DIR)/e2e.test:/usr/local/bin/e2e.test \
-e REPLICATED_API_TOKEN \
-v $(KOTS_BIN_DIR)/kots:/usr/local/bin/kots \
-v $(KOTS_BIN_DIR)/kots:/usr/local/bin/kubectl-kots \
-v $(PLAYWRIGHT_DIR)/playwright-report:/playwright/playwright-report \
Expand Down
1 change: 1 addition & 0 deletions e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ var _ = Describe("E2E", func() {
Entry(nil, inventory.MultiAppTest()),
Entry(nil, inventory.NewSupportBundle()),
Entry(nil, inventory.NewGitOps()),
Entry(nil, inventory.NewChangeChannel()),
)

})
Expand Down
10 changes: 10 additions & 0 deletions e2e/inventory/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,16 @@ func NewGitOps() Test {
}
}

func NewChangeChannel() Test {
return Test{
ID: "change-channel",
Name: "Change Channel",
Namespace: "change-channel",
AppSlug: "change-channel",
UpstreamURI: "change-channel/automated",
}
}

func SetupRegressionTest(kubectlCLI *kubectl.CLI) TestimParams {
cmd := kubectlCLI.Command(
context.Background(),
Expand Down
29 changes: 29 additions & 0 deletions e2e/playwright/tests/change-channel/license.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: kots.io/v1beta1
kind: License
metadata:
name: github-action
spec:
appSlug: change-channel
channelID: 2k6j62KPRQLjO0tF9zZB6zJJukg
channelName: Automated
channels:
- channelID: 2k6j62KPRQLjO0tF9zZB6zJJukg
channelName: Automated
channelSlug: automated
endpoint: https://replicated.app
isDefault: true
customerName: github-action
endpoint: https://replicated.app
entitlements:
expires_at:
description: License Expiration
signature: {}
title: Expiration
value: ""
valueType: String
isKotsInstallEnabled: true
isNewKotsUiEnabled: true
licenseID: 2k6jempcB6aQyddcIEBSTj0Bvvv
licenseSequence: 16
licenseType: trial
signature: eyJsaWNlbnNlRGF0YSI6ImV5SmhjR2xXWlhKemFXOXVJam9pYTI5MGN5NXBieTkyTVdKbGRHRXhJaXdpYTJsdVpDSTZJa3hwWTJWdWMyVWlMQ0p0WlhSaFpHRjBZU0k2ZXlKdVlXMWxJam9pWjJsMGFIVmlMV0ZqZEdsdmJpSjlMQ0p6Y0dWaklqcDdJbXhwWTJWdWMyVkpSQ0k2SWpKck5tcGxiWEJqUWpaaFVYbGtaR05KUlVKVFZHb3dRbloyZGlJc0lteHBZMlZ1YzJWVWVYQmxJam9pZEhKcFlXd2lMQ0pqZFhOMGIyMWxjazVoYldVaU9pSm5hWFJvZFdJdFlXTjBhVzl1SWl3aVlYQndVMngxWnlJNkltTm9ZVzVuWlMxamFHRnVibVZzSWl3aVkyaGhibTVsYkVsRUlqb2lNbXMyYWpZeVMxQlNVVXhxVHpCMFJqbDZXa0kyZWtwS2RXdG5JaXdpWTJoaGJtNWxiRTVoYldVaU9pSkJkWFJ2YldGMFpXUWlMQ0pqYUdGdWJtVnNjeUk2VzNzaVkyaGhibTVsYkVsRUlqb2lNbXMyYWpZeVMxQlNVVXhxVHpCMFJqbDZXa0kyZWtwS2RXdG5JaXdpWTJoaGJtNWxiRk5zZFdjaU9pSmhkWFJ2YldGMFpXUWlMQ0pqYUdGdWJtVnNUbUZ0WlNJNklrRjFkRzl0WVhSbFpDSXNJbWx6UkdWbVlYVnNkQ0k2ZEhKMVpTd2laVzVrY0c5cGJuUWlPaUpvZEhSd2N6b3ZMM0psY0d4cFkyRjBaV1F1WVhCd0luMWRMQ0pzYVdObGJuTmxVMlZ4ZFdWdVkyVWlPakUyTENKbGJtUndiMmx1ZENJNk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1pTTUhoNFUzazROV0l6VGxKV2JtUXhVbTVXTldNeFVsSmllWFJEWWpGQk0wMUhVbHBqYkc4d1lUSTViRk13UlhoaFdHUmFZbnBhV0dGVWJFcFphMk15U3pCUmQxTkhjRWRrYlhnelVtMVZNbUpUZEV0a2JsSlBZak5yTldSR1ZuRlRXRkpUVmpGSmVtRnJNVmRWUkZwUllsVTRkMWRYVWt4UFNFMTZWMWRhVldOdVRrOWlibWgxV2pGUk1WWlZUVEZhVkVKM1UxVTVWMXBYVGpOVlZrSkhWa2hqZGxSc1dsQmlSVnBxWVRCS05rOUlRbHBsVjBaTVpESlZNbE5YZEhWT1EzUndVbXBDVTJSVVVsQk9NalZDWVRBNGNsRnNhR3BUYlZZeldYcGtRMVZVUms5bFJXUmhVV3hGTkU1VmR6VmtSM2N4WTBaa2NsTkZUbmRMTWxadFVqSkpNV1J1UmpKU1NFcHRWVlZhZEdNelJrWlhVemxIV1dwYVVWZFliSE5OYlU1RVZucHNSVmx1YUhWWFIzUnJZbFpqTVU5VVdsWlhiVkV6VDFadmNsZFlVbmRNTVdSdFpWZEtlVlpHYnpOaVIxSnpaRzVzYjJNd05XaGpTRlpYWTFST1VrNXNiSFZhTVdoMFRXNXdOVnBIWXpsUVUwbHpTVzFrYzJJeVNtaGlSWFJzWlZWc2EwbHFiMmxaYlZKc1dsUlZNazVVV1hkWk1scHBUa1JPYWs5WFNYbFBSMHB0VDFSb2JGbFhUbWhhYlVVeVRrUlphV1pSUFQwaWZRPT0ifQ==
58 changes: 58 additions & 0 deletions e2e/playwright/tests/change-channel/test.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { test, expect } from '@playwright/test';
import { login, uploadLicense } from '../shared';

const CUSTOMER_ID = '2k6jemHbYgZFqtwgyjqiVfjRQqi';
const APP_ID = '2k6j65t0STtrZ1emyP5PUqBIQ23';
const AUTOMATED_CHANNEL_ID = '2k6j62KPRQLjO0tF9zZB6zJJukg';
const ALTERNATE_CHANNEL_ID = '2k6j61j49IPyDyQlbmRZJsxy3TP';

test('change channel', async ({ page }) => {
test.slow();
await changeChannel(AUTOMATED_CHANNEL_ID);
await login(page);
await uploadLicense(page, expect);
await page.getByRole('button', { name: 'Deploy' }).click();
await expect(page.locator('#app')).toContainText('Automated');
await changeChannel(ALTERNATE_CHANNEL_ID);

await page.getByText('Sync license').click();

await expect(page.getByLabel('Next step')).toContainText('License synced', { timeout: 10000 });
await page.getByRole('button', { name: 'Ok, got it!' }).click();

await expect(page.locator('#app')).toContainText('Alternate');
await expect(page.locator('#app')).toContainText('1.0.3', { timeout: 10000 });
await expect(page.locator('#app')).toContainText('Upstream Update', { timeout: 10000 });

await page.getByRole('button', { name: 'Deploy', exact: true }).click();
await page.getByRole('button', { name: 'Yes, Deploy' }).click();

await expect(page.locator('#app')).toContainText('Currently deployed version', { timeout: 15000 });
await expect(page.getByText('v1.0.0')).not.toBeVisible();
await expect(page.getByText('1.0.3')).toBeVisible();
});

async function changeChannel(channelId: string) {
await fetch(`https://api.replicated.com/vendor/v3/customer/${CUSTOMER_ID}`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
'Authorization': process.env.REPLICATED_API_TOKEN,
},
body: JSON.stringify({
"app_id": APP_ID,
"name": "github-action", // customer name
"channels": [
{
"channel_id": channelId,
"pinned_channel_sequence": null,
"is_default_for_customer": true
}
]
})
}).then(response => {
if (!response.ok) {
throw new Error(`Unexpected status code: ${response.status}`);
}
});
}

0 comments on commit 3961a04

Please sign in to comment.