docker-unittests

Testing of docker images during CI/CD process

License

License

${project.licence}
Categories

Categories

Docker Container Virtualization Tools
GroupId

GroupId

com.github.dgroup
ArtifactId

ArtifactId

docker-unittests
Last Version

Last Version

1.1.2
Release Date

Release Date

Type

Type

jar
Description

Description

docker-unittests
Testing of docker images during CI/CD process
Project URL

Project URL

http://github.com/dgroup/docker-unittests
Source Code Management

Source Code Management

http://github.com/dgroup/docker-unittests/tree/master

Download docker-unittests

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.dgroup/docker-unittests/ -->
<dependency>
    <groupId>com.github.dgroup</groupId>
    <artifactId>docker-unittests</artifactId>
    <version>1.1.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.dgroup/docker-unittests/
implementation 'com.github.dgroup:docker-unittests:1.1.2'
// https://jarcasting.com/artifacts/com.github.dgroup/docker-unittests/
implementation ("com.github.dgroup:docker-unittests:1.1.2")
'com.github.dgroup:docker-unittests:jar:1.1.2'
<dependency org="com.github.dgroup" name="docker-unittests" rev="1.1.2">
  <artifact name="docker-unittests" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.dgroup', module='docker-unittests', version='1.1.2')
)
libraryDependencies += "com.github.dgroup" % "docker-unittests" % "1.1.2"
[com.github.dgroup/docker-unittests "1.1.2"]

Dependencies

compile (15)

Group / Artifact Type Version
org.cactoos : cactoos jar 0.38
org.llorllale : cactoos-matchers jar 0.13
com.github.docker-java : docker-java jar 3.1.0
com.fasterxml.jackson.core : jackson-databind jar 2.9.8
org.bouncycastle : bcprov-jdk15on jar 1.60
org.apache.commons : commons-compress jar 1.18
com.google.guava : guava jar 27.0.1-jre
org.fusesource.jansi : jansi jar 1.16
org.yaml : snakeyaml jar 1.19
org.slf4j : slf4j-api jar 1.7.25
ch.qos.logback : logback-classic jar 1.2.3
ch.qos.logback : logback-core jar 1.2.3
com.jcabi.incubator : xembly jar 0.22
com.jcabi : jcabi-xml jar 0.21.4
org.hamcrest : hamcrest-all jar 1.3

test (4)

Group / Artifact Type Version
junit : junit jar 4.12
com.tngtech.junit.dataprovider : junit4-dataprovider jar 2.0
com.jcabi : jcabi-matchers jar 1.4
org.assertj : assertj-core jar 3.8.0

Project Modules

There are no modules declared in this project.

Maven Javadocs License: MIT Commit activity Hits-of-Code

Build Status 0pdd Dependency Status Known Vulnerabilities

Winner Badge

DevOps By Rultor.com EO badge We recommend IntelliJ IDEA

Qulice Maintainability Rating Codebeat Codacy Badge SQ coverage Codecov

The main concept is that all tests should use the image as is without any 'internal' go-related features. We, like users, receive the image and we are going to check what we've got.

The project has been started in Java as POC, however, I'm thinking about porting to python which is more suitable lang for the Ansible-oriented stack. Kindly ask you to raise the issue in case of any suggestions/bugs.

General image test

  1. Download the latest shaded dist from https://github.com/dgroup/docker-unittests/releases:

    wget https://github.com/dgroup/docker-unittests/releases/download/s1.1.1/docker-unittests-app-1.1.1.jar
    
  2. Define an *.yml file with tests.

    version: 1.1
    
    setup:
     - apt-get update
     - apt-get install -y tree
    
    tests:
    
     - assume: java version is 1.9, Debian build
       cmd:    java -version
       output:
         contains:
          - openjdk version "9.0.1"
          - build 9.0.1+11-Debian
    
     - assume: curl version is 7.xxx
       cmd:    curl --version
       output:
         startsWith: curl 7.
         matches:
          - "^curl\\s7.*\\n.*\\nProtocols.+ftps.+https.+telnet.*\\n.*\\n$"
         contains:
          - AsynchDNS IDN IPv6 Largefile GSS-API
    
     - assume:  Setup section installed `tree`
       cmd:     tree --version
       output:
         contains: ["Steve Baker", "Florian Sesser"]
       
  3. Run tests for image

     java -jar docker-unittests.jar -f image-tests.yml -i openjdk:9.0.1-11

    docker image tests results

General image test with output to xml file

  1. Use -o xml option in order to receive the testing report in xml format
     java -jar docker-unittests.jar -f image-tests.yml -i openjdk:9.0.1-11 -o xml
    xml result of docker image testing

Test image by shell script

  1. Define the test.yml with tests.
     version: 1.1
     
     tests:
     
       -  assume: "java version is 1.9, Debian build"
          cmd:    "java -version"
          output:
             contains:
              - openjdk version "9.0.1"
              - build 9.0.1+11-Debian
     
       # The test below will fail due to wrong version of curl.
       -  assume: "curl version is 8000"
          cmd:    "curl --version"
          output:
             startsWith: "curl 8000"
             matches:
               - "^curl\\s7.*\\n.*\\nProtocols.+ftps.+https.+telnet.*\\n.*\\n$"
             contains:
               - "AsynchDNS IDN IPv6 Largefile GSS-API"
  2. Define an test.sh with testing command
     #!/usr/bin/env bash
     set -e
     echo Testing has been started
     java -jar docker-unittests.jar -f test.yml -i openjdk:9.0.1-11
     echo This line will not be executed as testing will fail
  3. Run the test.sh docker image tests results

Output matching predicates

Predicate Multiple YML tag format
startsWith No startsWith: "curl 8000"
endsWith No endsWith: "VM (build 25.181-b13, mixed mode)"
equals No equals: "curl 7.54.0"
contains Yes contains: ["7.54", "LibreSSL", "pop3 pop3s"]
matches Yes matches: ["^curl\\s7.*\\n.*\\nProtocols.+ftps.+https.+.*\\n$"]

F.A.Q.

Versions

Version
1.1.2
1.1.1
1.1.0
1.0.4
1.0.3
1.0.2
1.0.1