GitHub user geomacy reopened a pull request:
https://github.com/apache/incubator-brooklyn/pull/1030
SimpleCommand addition to brooklyn-test-framework
### Description
An additional feature for the brooklyn-test-framework.
Supports a test that runs a simple command (expected to return quickly)
on the host of the target entity and allows assertions to be made on the
exit code, standard out and standard error of the command.
This is to support the use of arbitrary 'entities' (in the general sense)
in tests using the brooklyn-test-framework. Tests are regular blueprints
so already allow the deployment of arbitrary Brooklyn entities.
Additionally,
to deploy arbitrary server type processes (expected to continue running),
one can use the VanillaSoftwareProcess, which runs an arbitrary script.
The SimpleCommandTest in this PR is to support a similar case to that of
the
VanillaSoftwareProcess, except the command is expected to "do something",
finishing quickly, and return a result (process exit code), along with its
standard out and error streams, which can then be tested using assertions
provided by the test-framework.
See below for example YAML.
### Usage
- The type is type: org.apache.brooklyn.test.framework.SimpleCommandTest.
- The command can be specified as a script to be downloaded, by default
to /tmp, using the "downloadUrl" flag,
- Download directory can be changed using flag scriptDir.
- Alternatively the command can be specified as a simple command
to be executed, using the "defaultCommand" flag. This command can have
bash style command syntax including pipes and redirects.
- The command is run on the node of the target entity of the test via
an SSH connection.
- Assertions are made on the return code of the command using the
assertStatus flag, and on the standard output and error using assertOut
and assertErr.
### TODO
- The currently supported exceptions are equals, contains, matches and
isEmpty. A TODO is to merge this with the refactored standalone assertion
class currently being developed for the test-framework.
- Make the command execute against members of a cluster. At present
the command will only run against one of the cluster members.
### Example YAML
```
name: simpleCommandTest
location: byon4
services:
- type: org.apache.brooklyn.test.framework.TestCase
name: testcase1
targetId: testprocess
brooklyn.children:
- type: org.apache.brooklyn.entity.software.base.EmptySoftwareProcess
id: testprocess
- type: org.apache.brooklyn.test.framework.SimpleCommandTest
defaultCommand: hostname
assertStatus:
equals: 0
assertOut:
equals: byon4
assertErr:
isEmpty: true
- type: org.apache.brooklyn.test.framework.SimpleCommandTest
downloadUrl: http://localhost:8080/script1.sh
assertStatus:
equals: 0
assertOut:
equals: hello world
assertErr:
isEmpty: true
```
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/geomacy/incubator-brooklyn simplecommand
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-brooklyn/pull/1030.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #1030
----
commit b4e3ac7b68ed26f3efa74be7285de013d1f8c02a
Author: Geoff Macartney <[email protected]>
Date: 2015-11-05T15:06:45Z
Initial draft of SimpleCommand.
commit 6cd62e7d3b58876f40bbea9efb49426c9464589f
Author: Geoff Macartney <[email protected]>
Date: 2015-11-13T15:31:13Z
Disable failing tests while I inquire about proper use of tests that
require SSH access on Jenkins build machine.
commit 014b6bf162c2ca5df7cedf55c63232eed8028e22
Author: Geoff Macartney <[email protected]>
Date: 2015-11-13T15:44:46Z
Make SimpleCommand tests be Integration tests as they use SSH.
commit b30489ed043da00162f5102dbb6ccfd8582d05df
Author: Geoff Macartney <[email protected]>
Date: 2015-11-17T10:41:42Z
Initial restructuring due to review comments.
Removes as much as possible of the driver/lifecycle material, in response to
https://github.com/apache/incubator-brooklyn/pull/1030#issuecomment-156714424
Driver related classes removed.
SshEffectorTasks used where possible.
The lifecycle class is slimmed down but retained as it takes care of getting
hold of the MachineLocation.
commit 93039184a736a9fc698758d014e545a010438e42
Author: Geoff Macartney <[email protected]>
Date: 2015-11-17T11:41:00Z
Use /tmp rather than Os.tmp()
https://github.com/apache/incubator-brooklyn/pull/1030#discussion_r44859808
commit cff1961fa442f6695ebc3b891f87a3235c3988c5
Author: Geoff Macartney <[email protected]>
Date: 2015-11-17T12:18:52Z
Add RUN_DIR.
https://github.com/apache/incubator-brooklyn/pull/1030#discussion_r45050093
commit f6801227a90ebe0710a4f98509e61036606a2e81
Author: Geoff Macartney <[email protected]>
Date: 2015-11-17T12:23:46Z
Add 'this' to loggers for context.
https://github.com/apache/incubator-brooklyn/pull/1030#discussion_r44859887
commit f06fb74fed0b92d97f037efe4b958212df6d3156
Author: Geoff Macartney <[email protected]>
Date: 2015-11-17T12:25:14Z
Remove unnecessary annotation.
https://github.com/apache/incubator-brooklyn/pull/1030#discussion_r44859924
commit f173ad31f2ec08ac3602d92d4c0a14cb71406f4b
Author: Geoff Macartney <[email protected]>
Date: 2015-11-17T12:31:58Z
Rename DEFAULT_COMMAND to COMMAND.
https://github.com/apache/incubator-brooklyn/pull/1030#discussion_r44859961
commit 4467878da3e5f5738c469fe67da2ce544f0082da
Author: Geoff Macartney <[email protected]>
Date: 2015-11-17T12:34:22Z
Format change.
https://github.com/apache/incubator-brooklyn/pull/1030#discussion_r44859977
commit f3a6395e0028d26af473428f9d248a7d917ee7d1
Author: Geoff Macartney <[email protected]>
Date: 2015-11-17T13:19:43Z
Simplify integration test, avoid TestHttpServer and just have one test file.
https://github.com/apache/incubator-brooklyn/pull/1030#discussion_r44860563
https://github.com/apache/incubator-brooklyn/pull/1030#discussion_r44860570
commit 5f98079e62a7668aec8139fab4848b8e064824b6
Author: Geoff Macartney <[email protected]>
Date: 2015-11-17T14:14:57Z
Rename everything as SimpleShellCommand.
https://github.com/apache/incubator-brooklyn/pull/1030#issuecomment-157311566
commit 89d69269cad450f342a622c375b92c00c5482670
Author: Geoff Macartney <[email protected]>
Date: 2015-11-17T14:18:17Z
Don't need to configure name in integration test.
https://github.com/apache/incubator-brooklyn/pull/1030#discussion_r44860541
commit 60178809b3c51a429e6871bb68404245baa86269
Author: Geoff Macartney <[email protected]>
Date: 2015-11-17T16:23:23Z
Additional tests and improvements.
commit b2713ca4d7382ff1057531a6ef92a8a038a59d39
Author: Geoff Macartney <[email protected]>
Date: 2015-11-18T12:59:25Z
Fix location handling in integration test and remove unnecessary classes.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---