1010Define language independent tests for your command line scripts and programs in simple ` yaml ` files.
1111
1212 - It runs on ` windows ` , ` osx ` and ` linux `
13+ - It can validate local machines, ssh hosts and docker containers
1314 - It is a self-contained binary - no need to install a heavy lib or language
1415 - It is easy and fast to write
1516
@@ -47,6 +48,10 @@ For more information take a look at the [quick start](#quick-start), the [exampl
4748 - [ interval] ( #interval )
4849 - [ retries] ( #retries )
4950 - [ timeout] ( #timeout )
51+ - [ nodes] ( #nodes )
52+ + [ Nodes] ( #nodes )
53+ - [ local] ( #local )
54+ - [ ssh] ( #ssh )
5055 + [ Development] ( #development )
5156* [ Misc] ( #misc )
5257
@@ -108,12 +113,32 @@ Count: 1, Failed: 0
108113Here you can see an example with all features for a quick reference
109114
110115``` yaml
116+ nodes :
117+ ssh-host1 :
118+ type : ssh
119+ addr : 192.168.0.1:22
120+ user : root
121+ pass : pass
122+ ssh-host2 :
123+ type : ssh
124+ addr : 192.168.0.1:22
125+ user : root
126+ identity-file : /home/user/id_rsa.pub
127+ docker-host1 :
128+ type : docker
129+ image : alpine:2.4
130+ docker-host2 :
131+ type : docker
132+ instance : alpine_instance_1
133+
111134config : # Config for all executed tests
112135 dir : /tmp # Set working directory
113136 env : # Environment variables
114137 KEY : global
115138 timeout : 50s # Define a timeout for a command under test
116139 retries : 2 # Define retries for each test
140+ nodes :
141+ - ssh-host1 # define default hosts
117142
118143tests :
119144 echo hello : # Define command as title
@@ -141,7 +166,7 @@ tests:
141166 command : echo hello
142167 stdout :
143168 contains :
144- - hello # See test "it should fail"
169+ - hello # See test "it should fail"
145170 exactly : hello
146171 line-count : 1
147172 config :
@@ -152,6 +177,9 @@ tests:
152177 ANOTHER : yeah # Add another env variable
153178 timeout : 1s # Overwrite timeout
154179 retries : 5
180+ nodes : # overwrite default nodes
181+ - docker-host1
182+ - docker-host2
155183 exit-code : 0
156184` ` `
157185
@@ -607,6 +635,82 @@ If a tests exceeds the given `timeout` the test will fail.
607635timeout: 600s
608636` ` `
609637
638+ # ## Nodes
639+
640+ ` Commander` has the option to execute tests against other hosts, i.e. via ssh.
641+
642+ Available node types are currently :
643+
644+ - ` local` , execute tests locally
645+ - ` ssh` , execute tests viá ssh
646+
647+ ` ` ` yaml
648+ nodes: # define nodes in the node section
649+ ssh-host:
650+ type: ssh # define the type of the connection
651+ user: root # set the user which is used by the connection
652+ pass: password # set password for authentication
653+ addr: 192.168.0.100:2222 # target host address
654+ identity-file: ~/.ssh/id_rsa # auth with private key
655+ tests:
656+ echo hello:
657+ config:
658+ nodes: # define on which host the test should be executed
659+ - ssh-host
660+ stdout: hello
661+ exit-code: 0
662+ ` ` `
663+
664+ You can identify on which node a test failed by inspecting the test output.
665+ The `[local]` and `[ssh-host]` represent the node name on which the test were executed.
666+
667+ ```
668+ ✗ [ local] it should test ssh host
669+ ✗ [ ssh-host] it should fail if env could not be set
670+ ```
671+
672+ #### local
673+
674+ The `local` node is the default execution and will be applied if nothing else was configured.
675+ It is always pre-configured and available, i.e. if you want to execute tests on a node and locally.
676+
677+ ```yaml
678+ nodes:
679+ ssh-host:
680+ addr: 192.168.1.100
681+ user: ...
682+ tests:
683+ echo hello:
684+ config:
685+ nodes: # will be executed on local and ssh-host
686+ - ssh-host
687+ - local
688+ exit-code: 0
689+ ```
690+
691+ #### ssh
692+
693+ The ` ssh ` will execute tests against a configured node using ssh.
694+
695+ ** Limitations:** The ` inhereit-env ` config is disabled for ssh hosts, nevertheless it is possible to set env variables
696+
697+ ``` yaml
698+ nodes : # define nodes in the node section
699+ ssh-host :
700+ type : ssh # define the type of the connection
701+ user : root # set the user which is used by the connection
702+ pass : password # set password for authentication
703+ addr : 192.168.0.100:2222 # target host address
704+ identity-file : ~/.ssh/id_rsa # auth with private key
705+ tests :
706+ echo hello :
707+ config :
708+ nodes : # define on which host the test should be executed
709+ - ssh-host
710+ stdout : hello
711+ exit-code : 0
712+ ` ` `
713+
610714### Development
611715
612716` ` `
@@ -622,13 +726,35 @@ $ make test
622726# Coverage
623727$ make test-coverage
624728
625- # Integration tests
626- $ make integration
729+ # Coverage with more complex tests like ssh execution
730+ $ make test-coverage-all
731+
732+ # Integration tests for linux and macos
733+ $ make integration-unix
734+
735+ # Integration on linux
736+ $ make integration-linux
737+
738+ # Integration windows
739+ $ make integration-windows
627740
628741# Add depdencies to vendor
629742$ make deps
630743```
631744
745+ ### Unit tests
746+
747+ Enables ssh tests in unit test suite and sets the credentials for the target host.
748+ ` COMMANDER_SSH_TEST ` must be set to ` 1 ` to enable ssh tests.
749+
750+ ```
751+ export COMMANDER_TEST_SSH=1
752+ export COMMANDER_TEST_SSH_HOST=localhost:2222
753+ export COMMANDER_TEST_SSH_PASS=pass
754+ export COMMANDER_TEST_SSH_USER=root
755+ export COMMANDER_TEST_SSH_IDENTITY_FILE=integration/containers/ssh/.ssh/id_rsa
756+ ```
757+
632758## Misc
633759
634760Heavily inspired by [ goss] ( https://github.com/aelsabbahy/goss ) .
0 commit comments