Skip to content

Commit

Permalink
Merge pull request #1197 from spadgett/test-in-cluster-console
Browse files Browse the repository at this point in the history
Test in-cluster console for e2e tests
  • Loading branch information
openshift-merge-robot authored Feb 22, 2019
2 parents be656a7 + eeeb4eb commit afb2707
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 57 deletions.
4 changes: 4 additions & 0 deletions frontend/integration-tests/protractor.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const config: Config = {
plugins: [failFast.init()],
capabilities: {
browserName: 'chrome',
acceptInsecureCerts: true,
chromeOptions: {
args: [
'--disable-gpu',
Expand Down Expand Up @@ -67,6 +68,9 @@ export const config: Config = {
consoleLogStream.write(`${format.apply(null, [`[${level.name}]`, messageStr])}\n`);
});

const url = await browser.getCurrentUrl();
console.log('Last browser URL: ', url);

// Use projects if OpenShift so non-admin users can run tests. We need the fully-qualified name
// since we're using kubectl instead of oc.
const resource = browser.params.openshift === 'true' ? 'projects.project.openshift.io' : 'namespaces';
Expand Down
7 changes: 1 addition & 6 deletions frontend/integration-tests/tests/base.scenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ const BROWSER_TIMEOUT = 15000;

describe('Basic console test', () => {

afterAll(async() => {
// Clears HTTP 401 errors for subsequent tests
await browser.manage().logs().get('browser');
});

it('logs into console if necessary', async() => {
await browser.get(appHost);

Expand All @@ -22,7 +17,7 @@ describe('Basic console test', () => {
await loginView.nameInput.sendKeys(BRIDGE_AUTH_USERNAME);
await loginView.passwordInput.sendKeys(BRIDGE_AUTH_PASSWORD);
await loginView.submitButton.click();
await browser.wait(until.visibilityOf($('#header-logo')), BROWSER_TIMEOUT);
await browser.wait(until.visibilityOf($('.pf-c-page__header')), BROWSER_TIMEOUT);
}

expect(browser.getCurrentUrl()).toContain(appHost);
Expand Down
2 changes: 1 addition & 1 deletion frontend/integration-tests/tests/olm/etcd.scenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as catalogView from '../../views/olm-catalog.view';
import * as sidenavView from '../../views/sidenav.view';
import * as yamlView from '../../views/yaml.view';

describe('Interacting with the etcd OCS', () => {
xdescribe('Interacting with the etcd OCS', () => {
const etcdClusterResources = new Set(['Service', 'Pod']);
const deleteRecoveryTime = 60000;
const etcdOperatorName = 'etcd-operator';
Expand Down
1 change: 1 addition & 0 deletions frontend/integration-tests/tests/performance.scenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ describe('Performance test', () => {

it(`downloads new bundle for ${routeName}`, async() => {
await browser.get(`${appHost}/status/all-namespaces`);
await browser.executeScript(() => performance.setResourceTimingBufferSize(1000));
await browser.wait(until.presenceOf(crudView.resourceTitle));
// Avoid problems where the Catalog nav section appears where Workloads was at the moment the tests try to click.
await browser.wait(until.visibilityOf(sidenavView.navSectionFor('Catalog')));
Expand Down
4 changes: 2 additions & 2 deletions frontend/integration-tests/views/login.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

import { $ } from 'protractor';

export const nameInput = $('input[name=login]');
export const passwordInput = $('input[name=password]');
export const nameInput = $('#inputUsername');
export const passwordInput = $('#inputPassword');
export const submitButton = $('button[type=submit]');
42 changes: 5 additions & 37 deletions test-gui.sh
Original file line number Diff line number Diff line change
@@ -1,46 +1,14 @@
#!/usr/bin/env bash

set -euo pipefail


BRIDGE_K8S_AUTH_BEARER_TOKEN=$(kubectl config view -o json | jq '{myctx: .["current-context"], ctxs: .contexts[], users: .users[]}' | jq 'select(.myctx == .ctxs.name)' | jq 'select(.ctxs.context.user == .users.name)' | jq '.users.user.token' -r)
export BRIDGE_K8S_AUTH_BEARER_TOKEN
if [ -z "$BRIDGE_K8S_AUTH_BEARER_TOKEN" ];
then
echo "no BRIDGE_K8S_AUTH_BEARER_TOKEN!?"
exit 1
fi

BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT=$(kubectl config view -o json | jq '{myctx: .["current-context"], ctxs: .contexts[], clusters: .clusters[]}' | jq 'select(.myctx == .ctxs.name)' | jq 'select(.ctxs.context.cluster == .clusters.name)' | jq '.clusters.cluster.server' -r)
export BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT
if [ -z "$BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT" ];
then
echo "no BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT!?"
exit 1
fi

BRIDGE_BASE_PATH="/path-$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c10)/"
export BRIDGE_BASE_PATH

# TODO: eventually test auth
./bin/bridge \
--k8s-mode="off-cluster" \
--user-auth="disabled" \
--k8s-mode-off-cluster-skip-verify-tls=true \
--k8s-auth="bearer-token" \
--k8s-mode-off-cluster-endpoint="$BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT" \
--k8s-auth-bearer-token="$BRIDGE_K8S_AUTH_BEARER_TOKEN" &

echo $! > bridge.pid
set -exuo pipefail

cd frontend
yarn run webdriver-update --quiet > /dev/null 2>&1
yarn install
yarn run webdriver-update

if [ $# -gt 0 ] && [ -n "$1" ];
then
yarn run test-suite --suite "$1" --params.openshift true --params.servicecatalog false
yarn run test-suite --suite "$1" --params.openshift true
else
yarn run test-gui --params.openshift true --params.servicecatalog true
yarn run test-gui --params.openshift true
fi

kill "$(cat ../bridge.pid)"
26 changes: 15 additions & 11 deletions test-prow-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@

set -exuo pipefail

ARTIFACT_DIR=/tmp/artifacts
export ARTIFACT_DIR
ARTIFACT_DIR=${ARTIFACT_DIR:=/tmp/artifacts}
SCREENSHOTS_DIR=frontend/gui_test_screenshots
INSTALLER_DIR=${INSTALLER_DIR:=${ARTIFACT_DIR}/installer}

function copyArtifacts {
echo "Copying artifacts from $(pwd)..."
cp -rv ./frontend/gui_test_screenshots "${ARTIFACT_DIR}/gui_test_screenshots"
if [ -d "$ARTIFACT_DIR" ] && [ -d "$SCREENSHOTS_DIR" ]; then
echo "Copying artifacts from $(pwd)..."
cp -rv "$SCREENSHOTS_DIR" "${ARTIFACT_DIR}/gui_test_screenshots"
fi
}

trap copyArtifacts EXIT

./build.sh
export BRIDGE_AUTH_USERNAME=kubeadmin
# don't log kubeadmin-password
set +x
export BRIDGE_AUTH_PASSWORD="$(cat "${INSTALLER_DIR}/auth/kubeadmin-password")"
set -x
export BRIDGE_BASE_ADDRESS="https://$(oc get route console -n openshift-console -o jsonpath='{.spec.host}')"

oc login -u kubeadmin -p $(cat "${ARTIFACT_DIR}/installer/auth/kubeadmin-password")

source ./contrib/oc-environment.sh

kubectl create -f https://raw.githubusercontent.com/operator-framework/operator-lifecycle-manager/master/deploy/okd/manifests/0.8.0/0000_30_06-rh-operators.configmap.yaml
kubectl create -f https://raw.githubusercontent.com/operator-framework/operator-lifecycle-manager/master/deploy/okd/manifests/0.8.0/0000_30_09-rh-operators.catalogsource.yaml
oc create -f https://raw.githubusercontent.com/operator-framework/operator-lifecycle-manager/master/deploy/okd/manifests/0.8.0/0000_30_06-rh-operators.configmap.yaml
oc create -f https://raw.githubusercontent.com/operator-framework/operator-lifecycle-manager/master/deploy/okd/manifests/0.8.0/0000_30_09-rh-operators.catalogsource.yaml

./test-gui.sh e2e

0 comments on commit afb2707

Please sign in to comment.