Skip to content

Commit

Permalink
OCP 4.14+ knative service link changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cardil committed Aug 28, 2023
1 parent 020c674 commit 20bc3c6
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 5 deletions.
2 changes: 0 additions & 2 deletions test/ui-e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ if [ -n "${BUILD_ID:-}" ]; then
fi
export OCP_VERSION OCP_USERNAME OCP_PASSWORD OCP_LOGIN_PROVIDER CYPRESS_BASE_URL

create_namespaces "${TEST_NAMESPACES[@]}"
add_user "$OCP_USERNAME" "$OCP_PASSWORD"
oc adm policy add-role-to-user edit "$OCP_USERNAME" -n "$TEST_NAMESPACE"
check_node
archive_cypress_artifacts
logger.success '🚀 Cluster prepared for testing.'
Expand Down
27 changes: 26 additions & 1 deletion test/ui/cypress/code/knative/serving/showcase.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ class ShowcaseKservice {
.should('have.attr', 'value')
.and('include', 'showcase')
}
return cy.get('a.co-external-link')
let selector = '.co-external-link--block a'
if (environment.ocpVersion().satisfies('<=4.13')) {
selector = 'a.co-external-link'
}
return cy.get(selector)
.last()
.scrollIntoView()
.should('have.attr', 'href')
Expand Down Expand Up @@ -112,6 +116,26 @@ class ShowcaseKservice {
cy.contains('Running')
}

ensureNamespaceExists() {
cy.log(`Ensure namespace ${this.namespace} exists`)
this.doesNamespaceExists().then((exists) => {
if (!exists) {
cy.exec(`kubectl create ns ${this.namespace}`)
cy.exec(`oc adm policy add-role-to-user edit "${environment.username()}" -n "${this.namespace}"`)
}
})
}

doesNamespaceExists() {
return new Cypress.Promise((resolve, _) => {
const cmd = `kubectl get ns ${this.namespace} -o name`
cy.exec(cmd, {failOnNonZeroExit: false}).then((result) => {
let out = result.stdout.trim()
resolve(out.length > 0)
})
})
}

isServiceDeployed() {
return new Cypress.Promise((resolve, _) => {
const cmd = `kubectl get all -l app.kubernetes.io/part-of=${this.app} -n ${this.namespace} -o name`
Expand All @@ -137,6 +161,7 @@ class ShowcaseKservice {
}

removeApp() {
this.ensureNamespaceExists()
this.isServiceDeployed().then((deployed) => {
if (deployed) {
cy.log("Service is deployed. Removing it.")
Expand Down
1 change: 1 addition & 0 deletions test/ui/cypress/e2e/serving/cluster-local.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe('OCP UI for Serverless Serving', () => {
const openshiftConsole = new OpenshiftConsole()
const showcaseKsvc = new ShowcaseKservice({
clusterLocal: true,
namespace: 'test-cluster-local'
})

it('can deploy a cluster-local service', () => {
Expand Down
22 changes: 22 additions & 0 deletions test/ui/cypress/e2e/serving/delete-app.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Environment from '../../code/environment'
import ShowcaseKservice from '../../code/knative/serving/showcase'
import OpenshiftConsole from '../../code/openshift/openshiftConsole'

describe('OCP UI for Serverless Serving', () => {
const environment = new Environment()
const openshiftConsole = new OpenshiftConsole()
const showcaseKsvc = new ShowcaseKservice({
namespace: 'test-delete-app'
})

it('can delete an app with Knative service', () => {
openshiftConsole.login()
showcaseKsvc.removeApp()
showcaseKsvc.deployImage()
showcaseKsvc.removeApp()
showcaseKsvc.deployImage()
showcaseKsvc.url().then((url) => {
showcaseKsvc.makeRequest(url)
})
})
})
4 changes: 3 additions & 1 deletion test/ui/cypress/e2e/serving/multiple-revisions.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import Environment from '../../code/environment'
describe('OCP UI for Serverless Serving', () => {

const openshiftConsole = new OpenshiftConsole()
const showcaseKsvc = new ShowcaseKservice()
const showcaseKsvc = new ShowcaseKservice({
namespace: 'test-multiple-revisions'
})
const environment = new Environment()

it('can route traffic to multiple revisions', () => {
Expand Down
4 changes: 3 additions & 1 deletion test/ui/cypress/e2e/serving/scale-to-zero.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import OpenshiftConsole from '../../code/openshift/openshiftConsole'
describe('OCP UI for Serverless Serving', () => {

const openshiftConsole = new OpenshiftConsole()
const showcaseKsvc = new ShowcaseKservice()
const showcaseKsvc = new ShowcaseKservice({
namespace: 'test-scale-to-zero'
})

it('can deploy kservice and scale it', () => {
openshiftConsole.login()
Expand Down

0 comments on commit 20bc3c6

Please sign in to comment.