What I often need is to test my code against different environments. In this small post I am going to show how one can build hosted solution to test your source code in running Docker container by using Sparrowdo and Sparky.
Imperative deployment scenarios written on Perl6, nice web UI and asynchronous task execution is what you'll get for free!
This step is trivial, as we pull desired docker image and run it as a container:
$ git pull docker pull base/archlinux $ docker run -itd base/archlinux sh
So as we might guess I want to test my code against Arch Linux server. The same pattern is applied if you need to test against different environments, just change the docker image.
Say, I keep my source code somewhere in GitHub repository - https://github.com/melezhik/hello-world/blob/master/hello.bash - and for example purpose it is as simple as "hello world" Bash script:
#!bash echo "Hello World!"
Of course real life application are much more sophisticated, however this does not limit our approach.
I am going to use Sparrowdo to deploy an application code, so as the code is quite trivial this one should be as simple as fetching a source code from GitHub and running the "main" script:
#!perl6 git-scm "https://github.com/melezhik/hello-world.git"; bash "bash ./hello.bash";
Let's create a Sparky project to deploy mentioned Sparrowdo scenario on the running docker container. Sparky profile
sparky.yaml would be:
crontab: "*/10 * * * *" sparrowdo: docker: elastic_sinoussi no_sudo: true
Here we ask Sparky to run our deployment scenario every 10 minutes on the running docker container named
elastic_sinoussi ( the name of the container could be given by command
So the final structure of our Sparky project would be:
$ tree hello-world/ hello-world/ ├── sparky.yaml └── sparrowfile
sparrowfile file contains a Sparrow deployment scenario and
sparky.yaml does a Sparky settings ( like scheduler parameters, docker instance name and so on ).
It will take for awhile to build a project by Sparky, meanwhile we can observer the project builds by visiting nice Sparky web UI, following is couple of screen shots:
And finally we might notice that the project gets built successfully:
running sparrow tasks on 127.0.0.1 ... target OS is - archlinux push [task] fetch from git source: https://github.com/melezhik ... OK push [task] run bash: bash ./hello.bash ... OK SPL file /opt/sparky-sparrowdo/hello-world/sparrow.list is empty get index updates from SparrowHub ... OK set up task box file - /home/melezhik/.sparrowdo//opt/sparky-sparrowdo/hello-world/task-box.json - OK public@bash is uptodate (0.1.7) running task box from /opt/sparky-sparrowdo/hello-world/sparrow-cache/task-box.json ... 2017-12-04 14:13:34 : [task] fetch from git source: https://github.com/melezhik ... [path] modules/bash-command/ [params] envvars: 2017-12-04 14:13:35 : [task] run bash: bash ./hello.bash ... [path] modules/bash-command/ [params] envvars:
Sparky is a lightweight CI server built upon Sparrowdo framework. In just a few moments in enables integration tests under various environments working smoothly with Docker containers or ssh accessed hosts.
You're one click away
Level up every day