Skip to content

Commit

Permalink
Additional end-to-end tests (#1261)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andres Martinez Gotor authored Oct 30, 2019
1 parent ff14c10 commit 67fa388
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 8 deletions.
5 changes: 1 addition & 4 deletions chart/kubeapps/templates/apprepository-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ rules:
resources:
- apprepositories
verbs:
- get
- create
- update
- delete
- "*"
- apiGroups:
- ""
resources:
Expand Down
3 changes: 2 additions & 1 deletion integration/jest-puppeteer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ module.exports = {
launch: {
headless,
args: ["--no-sandbox"]
}
},
browserContext: "incognito"
};
2 changes: 1 addition & 1 deletion integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"private": true,
"scripts": {
"start": "jest",
"start:window": "HEADLESS=false jest"
"start:window": "INTEGRATION_HEADLESS=false jest"
},
"dependencies": {
"expect-puppeteer": "^4.3.0",
Expand Down
41 changes: 41 additions & 0 deletions integration/use-cases/create-registry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
jest.setTimeout(120000);

test("Deploys an application with the values by default", async () => {
page.setDefaultTimeout(4000);
await page.goto(getUrl("/#/login"));

await expect(page).toFillForm("form", {
token: process.env.ADMIN_TOKEN
});

await expect(page).toClick("button", { text: "Login" });

// Double click to show configuration
await expect(page).toClick("a", { text: "Configuration" });
await expect(page).toClick("a", { text: "Configuration" });

await expect(page).toClick("a", { text: "App Repositories" });

await expect(page).toClick("button", { text: "Add App Repository" });

await page.type("#kubeapps-repo-name", "my-repo");

await page.type("#kubeapps-repo-url", "https://charts.gitlab.io/");

await expect(page).toClick("button", { text: "Install Repo" });

await expect(page).toClick("a", { text: "my-repo" });

let retries = 3;
while (retries > 0) {
try {
await expect(page).toMatch("gitlab", { timeout: 2000 });
break;
} catch (e) {
// Refresh since the chart will get a bit of time to populate
await page.reload({ waitUntil: ["networkidle0", "domcontentloaded"] });
} finally {
retries--;
}
}
});
2 changes: 1 addition & 1 deletion integration/use-cases/default-deployment.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
jest.setTimeout(120000);

test("Deploys an application with the values by default", async () => {
page.setDefaultTimeout(2000);
page.setDefaultTimeout(4000);
await page.goto(getUrl("/#/login"));

await expect(page).toFillForm("form", {
Expand Down
27 changes: 27 additions & 0 deletions integration/use-cases/missing-permissions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
jest.setTimeout(120000);

test("Fails to deploy an application due to missing permissions", async () => {
page.setDefaultTimeout(4000);
await page.goto(getUrl("/#/login"));

await expect(page).toFillForm("form", {
token: process.env.VIEW_TOKEN
});

await page.screenshot({ path: "example.png" });

await expect(page).toClick("button", { text: "Login" });

await expect(page).toClick("a", { text: "Catalog" });

await expect(page).toClick("a", { text: "aerospike", timeout: 60000 });

await expect(page).toClick("button", { text: "Deploy" });

await expect(page).toClick("button", { text: "Submit" });

await expect(page).toMatch(
"You don't have sufficient permissions to create",
{ timeout: 20000 }
);
});
7 changes: 6 additions & 1 deletion script/e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,15 @@ kubectl cp ./use-cases ${pod}:/app/
## Create admin user
kubectl create serviceaccount kubeapps-operator -n kubeapps
kubectl create clusterrolebinding kubeapps-operator-admin --clusterrole=admin --serviceaccount kubeapps:kubeapps-operator
kubectl create -n kubeapps rolebinding kubeapps-repositories-write --role=kubeapps-ci-repositories-write --serviceaccount kubeapps:kubeapps-operator
admin_token=`kubectl get -n kubeapps secret $(kubectl get -n kubeapps serviceaccount kubeapps-operator -o jsonpath='{.secrets[].name}') -o go-template='{{.data.token | base64decode}}' && echo`
## Create view user
kubectl create serviceaccount kubeapps-view -n kubeapps
kubectl create clusterrolebinding kubeapps-view --clusterrole=view --serviceaccount kubeapps:kubeapps-view
view_token=`kubectl get -n kubeapps secret $(kubectl get -n kubeapps serviceaccount kubeapps-view -o jsonpath='{.secrets[].name}') -o go-template='{{.data.token | base64decode}}' && echo`
## Run tests
set +e
kubectl exec -it ${pod} -- /bin/sh -c "INTEGRATION_ENTRYPOINT=http://kubeapps-ci.kubeapps ADMIN_TOKEN=${admin_token} yarn start"
kubectl exec -it ${pod} -- /bin/sh -c "INTEGRATION_ENTRYPOINT=http://kubeapps-ci.kubeapps ADMIN_TOKEN=${admin_token} VIEW_TOKEN=${view_token} yarn start"
code=$?
set -e
if [[ "$code" != 0 ]]; then
Expand Down

0 comments on commit 67fa388

Please sign in to comment.