Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework the system tests #375

Merged
merged 2 commits into from
Feb 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions playbooks/fedora-30/pre-common.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
- name: Pull registry.fedoraproject.org/f30/fedora-toolbox:30
command: podman pull registry.fedoraproject.org/f30/fedora-toolbox:30
register: _podman
until: _podman.rc == 0
retries: 5
delay: 10

- name: Pull registry.fedoraproject.org/f29/fedora-toolbox:29
command: podman pull registry.fedoraproject.org/f29/fedora-toolbox:29
register: _podman
until: _podman.rc == 0
retries: 5
delay: 10
2 changes: 2 additions & 0 deletions playbooks/fedora-30/setup-rpm-env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@

- name: Check versions of crucial packages
command: rpm -q podman runc conmon fuse-overlayfs flatpak-session-helper

- include_tasks: ./pre-common.yaml
13 changes: 13 additions & 0 deletions playbooks/fedora-31/pre-common.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
- name: Pull registry.fedoraproject.org/f31/fedora-toolbox:31
command: podman pull registry.fedoraproject.org/f31/fedora-toolbox:31
register: _podman
until: _podman.rc == 0
retries: 5
delay: 10

- name: Pull registry.fedoraproject.org/f29/fedora-toolbox:29
command: podman pull registry.fedoraproject.org/f29/fedora-toolbox:29
register: _podman
until: _podman.rc == 0
retries: 5
delay: 10
2 changes: 2 additions & 0 deletions playbooks/fedora-31/setup-rpm-env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@

- name: Check versions of crucial packages
command: rpm -q podman crun conmon fuse-overlayfs flatpak-session-helper

- include_tasks: ./pre-common.yaml
13 changes: 13 additions & 0 deletions playbooks/fedora-rawhide/pre-common.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
- name: Pull registry.fedoraproject.org/f32/fedora-toolbox:32
command: podman pull registry.fedoraproject.org/f32/fedora-toolbox:32
register: _podman
until: _podman.rc == 0
retries: 5
delay: 10

- name: Pull registry.fedoraproject.org/f29/fedora-toolbox:29
command: podman pull registry.fedoraproject.org/f29/fedora-toolbox:29
register: _podman
until: _podman.rc == 0
retries: 5
delay: 10
2 changes: 2 additions & 0 deletions playbooks/fedora-rawhide/setup-rpm-env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@

- name: Check versions of crucial packages
command: rpm -q podman crun conmon fuse-overlayfs flatpak-session-helper

- include_tasks: ./pre-common.yaml
12 changes: 0 additions & 12 deletions test/system/001-basics.bats → test/system/001-version.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@

load helpers

function setup() {
:
}

function teardown() {
:
}

@test "Output version number using full flag" {
skip "Not implemented"
run_toolbox --version
Expand All @@ -20,7 +12,3 @@ function teardown() {
run_toolbox version
}

@test "Show usage screen when no command is given" {
run_toolbox 1
is "${lines[0]}" "toolbox: missing command" "Usage line 1"
}
8 changes: 8 additions & 0 deletions test/system/002-help.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bats

load helpers

@test "Show usage screen when no command is given" {
run_toolbox 1
is "${lines[0]}" "toolbox: missing command" "Usage line 1"
}
20 changes: 0 additions & 20 deletions test/system/101-create.bats

This file was deleted.

24 changes: 24 additions & 0 deletions test/system/101-list.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bats

load helpers

@test "Run list with zero containers and two images" {
run_toolbox list
is "${#lines[@]}" "3" "Expected number of lines of the output is 3 (Img: 3 + Spc: 0 + Cont: 0)"

is "${lines[1]}" ".*registry.fedoraproject.org/.*" "First of the two images"
is "${lines[2]}" ".*registry.fedoraproject.org/.*" "Second of the two images"
}

@test "Run list with zero containers (-c flag)" {
run_toolbox list -c
is "$output" "" "Output of list should be blank"
}

@test "Run list with zero images (-i flag)" {
run_toolbox list -i
is "${#lines[@]}" "3" "Expected number of lines of the output is 3"

is "${lines[1]}" ".*registry.fedoraproject.org/.*" "First of the two images"
is "${lines[2]}" ".*registry.fedoraproject.org/.*" "Second of the two images"
}
20 changes: 20 additions & 0 deletions test/system/102-create.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bats

load helpers

@test "Create the default container" {
run_toolbox -y create
}

@test "Create a container with a valid custom name ('not-running')" {
run_toolbox -y create -c "not-running"
}

@test "Create a container with a custom image and name ('running';f29)" {
run_toolbox -y create -c "running" -i fedora-toolbox:29
}

@test "Try to create a container with invalid custom name" {
run_toolbox 1 -y create -c "ß[email protected]€"
is "${lines[0]}" "toolbox: invalid argument for '--container'" "Toolbox reports invalid argument for --container"
}
44 changes: 0 additions & 44 deletions test/system/102-list.bats

This file was deleted.

15 changes: 15 additions & 0 deletions test/system/103-list.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bats

load helpers

@test "Run list with three containers and two images" {
run_toolbox list
is "${#lines[@]}" "8" "Expected number of lines of the output is 8 (Img: 3 + Cont: 5 (duplication expected))"

is "${lines[1]}" ".*registry.fedoraproject.org/.*" "The first of the two images"
is "${lines[2]}" ".*registry.fedoraproject.org/.*" "The second of the two images"

is "${lines[4]}" ".*fedora-toolbox-.*" "The default container should be first in the list"
is "${lines[5]}" ".*not-running.*" "The container 'not-running' should be second"
is "${lines[6]}" ".*running.*" "The container 'running' should be third (last)"
}
56 changes: 0 additions & 56 deletions test/system/103-remove.bats

This file was deleted.

12 changes: 0 additions & 12 deletions test/system/104-run.bats

This file was deleted.

23 changes: 23 additions & 0 deletions test/system/201-run.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bats

load helpers

@test "Echo 'Hello World' inside of the default container" {
run_toolbox run echo "Hello World"
is "$output" "Hello World" "Should say 'Hello World'"
}

@test "Echo 'Hello World' inside of the 'running' container" {
run_toolbox run -c running echo "Hello World"
is "$output" "Hello World" "Should say 'Hello World'"
}

@test "Stop the 'running' container using 'podman stop'" {
run_podman stop running
is "${#lines[@]}" "1" "Expected number of lines of the output is 1 (with the id of the container)"
}

@test "Echo 'hello World' again in the 'running' container after being stopped and exit" {
run_toolbox run -c running echo "Hello World"
is "$output" "Hello World" "Should say 'Hello World'"
}
28 changes: 28 additions & 0 deletions test/system/301-rm.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bats

load helpers

@test "Try to remove a nonexistent container" {
run_toolbox 1 rm nonexistentcontainer
is "$output" "toolbox: failed to inspect $todelete" "Toolbox should fail with: no such container"
}

@test "Try to remove the running container 'running'" {
run_toolbox 1 rm running
is "$output" "toolbox: failed to remove container running" "Toolbox should fail to remove the running container"
}

@test "Remove the not running container 'not-running'" {
run_toolbox rm not-running
is "$output" "" "The output should be empty"
}

@test "Force remove the running container 'running'" {
run_toolbox rm --force running
is "$output" "" "The output should be empty"
}

@test "Force remove all remaining containers (only 1 should be left)" {
run_toolbox rm --force --all
is "$output" "" "The output should be empty"
}
8 changes: 8 additions & 0 deletions test/system/302-rmi.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bats

load helpers

@test "Remove all images (2 should be present; --force should not be necessary)" {
run_toolbox rmi --all
is "$output" "" "The output should be empty"
}
Loading