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 cypress image #1427

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions .github/workflows/on-pull-request.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

name: Test
on:
pull_request:
env:
CONTAINER_CMD: docker
FORKLIFT_PLUGIN_IMAGE: localhost:5001/forklift-console-plugin:latest
OKD_CONSOLE_YAML: ./ci/yaml/okd-console.yaml
OKD_CONSOLE_YAML: ./ci/yaml/okd-console.yaml

jobs:
tests:
Expand Down Expand Up @@ -47,13 +46,15 @@ jobs:
e2e:
name: Run e2e tests
runs-on: ubuntu-latest
env:
BASE_ADDRESS: http://localhost:30080
steps:
- name: Increase File Descriptors Limit
run: ulimit -n 4096

- name: Checkout
uses: actions/checkout@v4

- name: Run pre e2e test tasks
run: yarn e2e:pre-test

Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/on-push-main-cypress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Container image UI tests

on:
push:
branches:
- main

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Increase File Descriptors Limit
run: ulimit -n 4096

- name: Checkout
uses: actions/checkout@v4

- name: Log in to Quay.io
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./build/CypressContainerFile
push: true
tags: quay.io/kubev2v/forklift-ui-tests:latest

- name: Logout from Quay.io
run: docker logout quay.io
8 changes: 8 additions & 0 deletions build/CypressContainerFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM cypress/included:13.17.0

WORKDIR /cypress

COPY ./cypress .

RUN npm install

27 changes: 19 additions & 8 deletions ci/start-console.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@ source ${script_dir}/configure/openshift.sh
CONSOLE_CONTAINER_NAME=okd-console
FORKLIFT_NAMESPACE=konveyor-forklift

PLUGIN_NAME="forklift-console-plugin"
PLUGIN_URL=${PLUGIN_URL:-"http://localhost:9001"}
BASE_HOST_URL=${BASE_HOST_URL:-"https://localhost"}
CONTAINER_NETWORK_TYPE=${CONTAINER_NETWORK_TYPE:-"host"}
CONTAINER_NETWORK=${CONTAINER_NETWORK:-"--network=${CONTAINER_NETWORK_TYPE}"}

if [[ $(uname) = "Darwin" ]]; then
# On macOS
BASE_HOST_URL="http://host.containers.internal"
CONTAINER_NETWORK=""

fi

PLUGIN_NAME="forklift-console-plugin"
PLUGIN_URL=${PLUGIN_URL:-"$BASE_HOST_URL:9001"}
CONSOLE_IMAGE=${CONSOLE_IMAGE:-"quay.io/openshift/origin-console:latest"}
CONSOLE_PORT=${CONSOLE_PORT:-9000}

Expand All @@ -21,8 +31,8 @@ if oc_available_loggedin; then
fi

# Default to localhost if no route found
INVENTORY_SERVER_HOST=${INVENTORY_SERVER_HOST:-"https://localhost:30444"}
SERVICES_API_SERVER_HOST=${SERVICES_API_SERVER_HOST:-"https://localhost:30446"}
INVENTORY_SERVER_HOST=${INVENTORY_SERVER_HOST:-"$BASE_HOST_URL:30444"}
SERVICES_API_SERVER_HOST=${SERVICES_API_SERVER_HOST:-"$BASE_HOST_URL:30446"}
Comment on lines +34 to +35
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the urls were set by default before the fix to https://localhost and not to http://localhost, so you may need two variables or just set the HOST part..

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to https thanks!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not working now, since the console doesn't find the plugin. It is searching for the plugin on https://localhost and the plugin is running using http://localhost.
The original line was:

PLUGIN_URL=${PLUGIN_URL:-"http://localhost:9001"}

You need to use different schema for each:
for PLUGIN_URL - http
for BASE_HOST_URL - https


if [[ ${CONSOLE_IMAGE} =~ ^localhost/ ]]; then
PULL_POLICY="never"
Expand All @@ -32,8 +42,8 @@ fi

# Test if console is already running
if podman container exists ${CONSOLE_CONTAINER_NAME}; then
echo "container named ${CONSOLE_CONTAINER_NAME} is running, exit."
exit 1
echo "container named ${CONSOLE_CONTAINER_NAME} is running, exit."
exit 1
fi

# Base setup for the bridge
Expand All @@ -49,7 +59,8 @@ fi
#
# NOTE: When running KinD we should use host network type because KinD only listen on localhost.
BRIDGE_PLUGINS="${PLUGIN_NAME}=${PLUGIN_URL}"
BRIDGE_PLUGIN_PROXY=$(cat << END | jq -c .
BRIDGE_PLUGIN_PROXY=$(
cat <<END | jq -c .
{"services":[
{
"consoleAPIPath":"/api/proxy/plugin/${PLUGIN_NAME}/forklift-inventory/",
Expand Down Expand Up @@ -95,7 +106,7 @@ podman run \
--pull=${PULL_POLICY} \
--rm \
${mount_tmp_dir_flag} \
--network=${CONTAINER_NETWORK_TYPE} \
${CONTAINER_NETWORK} \
--publish=${CONSOLE_PORT}:${CONSOLE_PORT} \
--name=${CONSOLE_CONTAINER_NAME} \
--env "BRIDGE_*" \
Expand Down
2 changes: 1 addition & 1 deletion cypress/cypress.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { defineConfig } from "cypress";

export default defineConfig({
e2e: {
baseUrl: process.env.BRIDGE_BASE_ADDRESS || "http://localhost:30080",
baseUrl: process.env.BRIDGE_BASE_ADDRESS||process.env.BASE_ADDRESS || "http://host.docker.internal:9000",
setupNodeEvents(on, config) {
// implement node event listeners here
},
Expand Down
3 changes: 2 additions & 1 deletion cypress/e2e/tests/Providers/CreateProvider.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ describe('Providers list view', () => {
beforeEach(() => {
// close all nav items
cy.visit('/');

cy.wait(10000);
// navigate to migration -> providers list
cy.findByTestId('migration-nav-item').should('exist').click();
cy.findByTestId('providers-nav-item').should('exist').click();
cy.wait(10000);
});

it('has a add-provider button', () => {
Expand Down
15 changes: 15 additions & 0 deletions cypress/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "cypress",
"version": "1.0.0",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"description": "",
"devDependencies": {
"@testing-library/cypress": "^10.0.2",
"cypress": "^13.17.0",
"typescript": "^5.7.2"
}
}
Loading
Loading