Skip to content

Commit

Permalink
feat: Add new e2e test cases for example to create workspaces and sta…
Browse files Browse the repository at this point in the history
…rt and… (#678)

* Add new e2e test cases for example to create workspaces and start and stop eclipse che cluster

Signed-off-by: flacatus <[email protected]>

* Add a very simple devfile instead of large quarkus devfile

Signed-off-by: flacatus <[email protected]>

* Add coverage for workspace:start, delete, stop

Signed-off-by: flacatus <[email protected]>

* Add coverage for workspace:inject command and add some little fixes to function names

Signed-off-by: flacatus <[email protected]>

* Fix names constants

Signed-off-by: flacatus <[email protected]>

* Fix constants name

Signed-off-by: flacatus <[email protected]>
  • Loading branch information
flacatus authored May 5, 2020
1 parent fab7b52 commit 05b537b
Show file tree
Hide file tree
Showing 4 changed files with 373 additions and 22 deletions.
128 changes: 115 additions & 13 deletions test/e2e/minikube.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*********************************************************************
* Copyright (c) 2019 Red Hat, Inc.
* Copyright (c) 2020 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -8,27 +8,129 @@
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
import { expect, test } from '@oclif/test'
import * as execa from 'execa'

import { E2eHelper } from './util/e2e'
const helper = new E2eHelper()
jest.setTimeout(600000)

describe('e2e test', () => {
describe('server:start without parameters', () => {
const PLATFORM = 'kubernetes'

describe('Eclipse Che deploy test suite', () => {
describe('server:start using operator and self signed certificates', () => {
test
.stdout({print:true})
.command(['server:start', '--platform=minikube', '--skip-cluster-availability-check', '--tls', '--self-signed-cert', '--installer=operator'])
.stdout({ print: true })
.command(['server:start', '--platform=minikube', '--tls', '--self-signed-cert', '--installer=operator', '--skip-cluster-availability-check'])
.exit(0)
.it('uses minikube as platform, operator as installer and auth is enabled', ctx => {
expect(ctx.stdout).to.contain('Minikube preflight checklist')
.and.to.contain('Running the Eclipse Che operator')
.and.to.contain('Post installation checklist')
.and.to.contain('Command server:start has completed successfully')
.it('uses minikube as platform, operator as installer and auth is enabled')
test
.it('Obtain access_token from keycloak.', async () => {
const token = await helper.getAccessToken(PLATFORM)
process.env.CHE_ACCESS_TOKEN = token
})
})
})

describe('Workspace creation, list, start, inject, delete. Support stop and delete commands for Eclipse Che server', () => {
const binChectl = `${process.cwd()}/bin/run`

describe('Create Workspace', () => {
test
.skip()
.stdout()
.stdout({ print: true })
.command(['workspace:create', '--devfile=test/e2e/util/devfile-example.yaml'])
.exit(0)
.it('Create a workspace and wait to be started')
})

describe('Start Workspace', () => {
it('Start a workspace using execa library', async () => {
const workspaceId = await helper.getWorkspaceId(PLATFORM)
const command = `${binChectl} workspace:start ${workspaceId}`

const { exitCode, stdout, stderr } = await execa(command, { timeout: 30000, shell: true })

expect(exitCode).equal(0)
console.log(stdout)

// Sleep time to wait to workspace to be running
await helper.SleepTests(200000)
if (exitCode !== 0) {
console.log(stderr)
}

const workspaceStatus = await helper.getWorkspaceStatus(PLATFORM)

expect(workspaceStatus).to.contain('RUNNING')
})
})

describe('Inject kubeconfig to workspaces', () => {
it('Inject kubeconfig to workspaces', async () => {
const command = `${binChectl} workspace:inject --kubeconfig`

const { exitCode, stdout, stderr } = await execa(command, { timeout: 30000, shell: true })

expect(exitCode).equal(0)
console.log(stdout)

if (exitCode !== 0) {
console.log(stderr)
}
})
})

describe('List Workspace', () => {
test
.stdout({ print: true })
.command(['workspace:list'])
.it('List workspaces')
})

describe('Stop Workspace', () => {
it('Stop a workspace using execa library', async () => {
const workspaceId = await helper.getWorkspaceId(PLATFORM)
const command = `${binChectl} workspace:stop ${workspaceId}`

const { exitCode, stdout, stderr } = await execa(command, { timeout: 30000, shell: true })
expect(exitCode).equal(0)

console.log(stdout)

if (exitCode !== 0) {
console.log(stderr)
}

const workspaceStatus = await helper.getWorkspaceStatus(PLATFORM)
expect(workspaceStatus).to.contain('STOPPING')
})
})

describe('Delete Workspace', () => {
it('Delete a workspace using execa library', async () => {
const workspaceId = await helper.getWorkspaceId(PLATFORM)
const command = `${binChectl} workspace:delete ${workspaceId}`

const { exitCode, stdout, stderr } = await execa(command, { timeout: 30000, shell: true })
expect(exitCode).equal(0)

console.log(stdout)

if (exitCode !== 0) {
console.log(stderr)
}
})
})

describe('Stop Eclipse Che Server', () => {
test
.stdout({ print: true })
.do(async () => helper.SleepTests(30000))
.command(['server:stop'])
.exit(0)
.it('stops Server on minikube successfully')
.it('Stop Eclipse Che Server on minikube platform')
})

describe('Delete Eclipse Che Server', () => {
test
.stdout()
.command(['server:delete', '--skip-deletion-check'])
Expand Down
124 changes: 115 additions & 9 deletions test/e2e/minishift.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*********************************************************************
* Copyright (c) 2019 Red Hat, Inc.
* Copyright (c) 2020 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -8,13 +8,19 @@
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
import { expect, test } from '@oclif/test'
import * as execa from 'execa'

import { E2eHelper } from './util/e2e'

const helper = new E2eHelper()
jest.setTimeout(600000)

describe('e2e test', () => {
describe('server:start without parameters', () => {
const PLATFORM = 'openshift'

describe('Eclipse Che deploy test suite', () => {
describe('server:start using operator and self signed certificates', () => {
test
.stdout({print:true})
.stdout({ print: true })
.command(['server:start', '--platform=minishift', '--tls', '--self-signed-cert', '--installer=operator'])
.exit(0)
.it('uses minishift as platform, operator as installer and auth is enabled', ctx => {
Expand All @@ -24,15 +30,115 @@ describe('e2e test', () => {
.and.to.contain('Command server:start has completed successfully')
})
test
.skip()
.stdout()
.it('Obtain access_token from keycloak and set it like environment variable.', async () => {
const token = await helper.getAccessToken(PLATFORM)
process.env.CHE_ACCESS_TOKEN = token
})
})
})


describe('Workspace creation, list, start, inject, delete. Support stop and delete commands for Eclipse Che server', () => {
const binChectl = `${process.cwd()}/bin/run`

describe('Create Workspace', () => {
test
.stdout({ print: true })
.command(['workspace:create', '--devfile=test/e2e/util/devfile-example.yaml'])
.exit(0)
.it('Create a workspace and wait to be started')
})

describe('Start Workspace', () => {
it('Start a workspace using execa library', async () => {
const workspaceId = await helper.getWorkspaceId(PLATFORM)
const command = `${binChectl} workspace:start ${workspaceId}`

const { exitCode, stdout, stderr } = await execa(command, { timeout: 30000, shell: true })

expect(exitCode).equal(0)
console.log(stdout)

// Sleep time to wait to workspace to be running
await helper.SleepTests(200000)
if (exitCode !== 0) {
console.log(stderr)
}

const workspaceStatus = await helper.getWorkspaceStatus(PLATFORM)

expect(workspaceStatus).to.contain('RUNNING')
})
})

describe('Inject kubeconfig to workspaces', () => {
it('Inject kubeconfig to workspaces', async () => {
const command = `${binChectl} workspace:inject --kubeconfig`

const { exitCode, stdout, stderr } = await execa(command, { timeout: 30000, shell: true })

expect(exitCode).equal(0)
console.log(stdout)

if (exitCode !== 0) {
console.log(stderr)
}
})
})

describe('List Workspace', () => {
test
.stdout({ print: true })
.command(['workspace:list'])
.it('List workspaces')
})

describe('Stop Workspace', () => {
it('Stop a workspace using execa library', async () => {
const workspaceId = await helper.getWorkspaceId(PLATFORM)
const command = `${binChectl} workspace:stop ${workspaceId}`

const { exitCode, stdout, stderr } = await execa(command, { timeout: 30000, shell: true })
expect(exitCode).equal(0)

console.log(stdout)

if (exitCode !== 0) {
console.log(stderr)
}
})
})

describe('Delete Workspace', () => {
it('Delete a workspace using execa library', async () => {
const workspaceId = await helper.getWorkspaceId(PLATFORM)
const command = `${binChectl} workspace:delete ${workspaceId}`

const { exitCode, stdout, stderr } = await execa(command, { timeout: 30000, shell: true })
expect(exitCode).equal(0)

console.log(stdout)

if (exitCode !== 0) {
console.log(stderr)
}
})
})

describe('Stop Eclipse Che Server', () => {
test
.stdout({ print: true })
.do(async () => helper.SleepTests(30000))
.command(['server:stop'])
.exit(0)
.it('stops Server on minishift successfully')
.it('Stop Eclipse Che Server on minikube platform')
})

describe('Delete Eclipse Che Server', () => {
test
.stdout({print:true})
.stdout()
.command(['server:delete', '--skip-deletion-check'])
.exit(0)
.it('deletes Eclipse Che resources on minishift successfully')
.it('deletes Eclipse Che resources on minikube successfully')
})
})
3 changes: 3 additions & 0 deletions test/e2e/util/devfile-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
metadata:
name: e2e-tests
apiVersion: 1.0.0
Loading

0 comments on commit 05b537b

Please sign in to comment.