Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit d83c28e

Browse files
committed
improved support for activation result and activation logs
Fixes #455
1 parent 60580d9 commit d83c28e

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed

app/plugins/views/sidecar/mode.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ module.exports = (commandTree, require) => {
4242
const wsk = require('/ui/commands/openwhisk-core'),
4343
sidecarVisibility = require('/views/sidecar/visibility')
4444

45-
const switchSidecarMode = (entityType, mode) => (block, nextBlock) => {
45+
const switchSidecarMode = (entityType, mode) => (block, nextBlock, argv) => {
4646
const sidecar = document.querySelector('#sidecar')
47+
4748
if (sidecar && sidecar.entity && (!entityType
4849
|| sidecar.entity.type === entityType
4950
|| util.isArray(entityType) && entityType.find(t => t === sidecar.entity.type))) {
@@ -56,6 +57,10 @@ module.exports = (commandTree, require) => {
5657
sidecarVisibility.show()
5758
return ui.showEntity(sidecar.entity, { show: mode }, block, nextBlock)
5859
}
60+
} else if (argv.length === 3 || argv.length === 4) { // activation logs xxx or wsk activation logs xxx
61+
return repl.qexec(`${entityType} get ${argv[argv.length - 1]}`)
62+
.then(_ => ui.showEntity(_, { show: mode }, block, nextBlock))
63+
.then(() => true) // make repl happy
5964
} else {
6065
throw new Error(!entityType ? 'You have not selected an entity'
6166
: `You have not yet selected ${ui.startsWithVowel(entityType) ? 'an' : 'a'} ${entityType.replace(/s$/, '')}`)

tests/lib/ui.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ exports.sidecar = {
236236
it('should toggle closed the sidecar', () => exports.sidecar.doClose(ctx.app))
237237
},
238238

239+
expectMode: expectedMode => app => app.client.waitUntil(() => {
240+
return app.client.waitForVisible(`${selectors.SIDECAR_MODE_BUTTON(expectedMode)}.sidecar-bottom-stripe-button-active`)
241+
.then(() => app)
242+
}),
243+
239244
expectShowing: (expectedName, expectedActivationId, expectSubstringMatchOnName=false, expectedPackageName, expectType, waitThisLong=timeout) => app => app.client.waitUntil(() => {
240245
// check selected name in sidecar
241246
return app.client.waitForVisible(`${selectors.SIDECAR}${!expectType ? '' : '.entity-is-' + expectType}`)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright 2018 IBM Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
//
18+
// tests that create an action and test that it shows up in the list UI
19+
// this test also covers toggling the sidecar
20+
//
21+
const common = require('../../../lib/common'),
22+
openwhisk = require('../../../lib/openwhisk'),
23+
ui = require('../../../lib/ui'),
24+
assert = require('assert'),
25+
keys = ui.keys,
26+
cli = ui.cli,
27+
sidecar = ui.sidecar,
28+
actionName1 = `foo1-${new Date().getTime()}`,
29+
actionName2 = `foo2-${new Date().getTime()}`
30+
31+
describe('wsk activation result and wsk activation logs', function() {
32+
before(common.before(this))
33+
after(common.after(this))
34+
35+
it('should have an active repl', () => cli.waitForRepl(this.app))
36+
37+
// create an action
38+
it(`should create an action ${actionName1}`, () => cli.do(`create ${actionName1} ./data/foo.js`, this.app)
39+
.then(cli.expectOK)
40+
.then(sidecar.expectOpen)
41+
.then(sidecar.expectShowing(actionName1))
42+
.catch(common.oops(this)))
43+
44+
it(`should async that action then show its logs and result`, () => cli.do(`async ${actionName1}`, this.app)
45+
.then(cli.expectOKWithCustom(cli.makeCustom('.activationId', '')))
46+
.then(selector => this.app.client.getText(selector)
47+
.then(activationId => cli.do(`wsk activation logs ${activationId}`, this.app)
48+
.then(() => sidecar.expectOpen(this.app))
49+
.then(sidecar.expectShowing(actionName1, activationId))
50+
.then(sidecar.expectMode('logs'))
51+
.then(() => this.app.restart())
52+
.then(() => cli.do(`activation logs ${activationId}`, this.app))
53+
.then(() => sidecar.expectOpen(this.app))
54+
.then(sidecar.expectShowing(actionName1, activationId))
55+
.then(sidecar.expectMode('logs'))
56+
.then(() => this.app.restart())
57+
.then(() => cli.do(`activation result ${activationId}`, this.app))
58+
.then(() => sidecar.expectOpen(this.app))
59+
.then(sidecar.expectShowing(actionName1, activationId))
60+
.then(sidecar.expectMode('result'))))
61+
.catch(common.oops(this)))
62+
})

0 commit comments

Comments
 (0)