move docker image building to be a global autouse fixture to make sure it runs before tests that use output
This commit is contained in:
parent
8326771570
commit
b372f0101d
|
@ -1,5 +1,6 @@
|
|||
import pytest
|
||||
import testinfra
|
||||
import DockerfileGeneration
|
||||
|
||||
WEB_SERVER = { 'alpine_amd64': 'nginx', 'debian_amd64': 'lighttpd' }
|
||||
|
||||
|
@ -142,3 +143,22 @@ def RunningPiHole(DockerPersist, Slow, persist_webserver):
|
|||
Slow(lambda: DockerPersist.run('pgrep {}'.format(persist_webserver) ).rc == 0)
|
||||
return DockerPersist
|
||||
|
||||
|
||||
''' Everything should depend on the building of the docker images '''
|
||||
@pytest.fixture(autouse=True)
|
||||
@pytest.mark.parametrize('arch', [ 'amd64', 'armhf', 'aarch64' ])
|
||||
@pytest.mark.parametrize('os', [ 'debian', 'alpine' ])
|
||||
def test_build_pihole_image(os, arch):
|
||||
run_local = testinfra.get_backend(
|
||||
"local://"
|
||||
).get_module("Command").run
|
||||
|
||||
''' Build the entire matrix of OS+Architecture '''
|
||||
DockerfileGeneration.generate_dockerfiles()
|
||||
dockerfile = 'Dockerfile_{}_{}'.format(os, arch)
|
||||
image_tag = '{}:{}_{}'.format('pi-hole', os, arch)
|
||||
build_cmd = run_local('docker build --pull -f {} -t {} .'.format(dockerfile, image_tag))
|
||||
if build_cmd.rc != 0:
|
||||
print build_cmd.stdout
|
||||
print build_cmd.stderr
|
||||
assert build_cmd.rc == 0
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
''' This file starts with 000 to make it run first '''
|
||||
import pytest
|
||||
import testinfra
|
||||
import DockerfileGeneration
|
||||
|
||||
run_local = testinfra.get_backend(
|
||||
"local://"
|
||||
).get_module("Command").run
|
||||
|
||||
|
||||
def test_generate_dockerfiles():
|
||||
DockerfileGeneration.generate_dockerfiles()
|
||||
|
||||
@pytest.mark.parametrize('arch', [ 'amd64', 'armhf', 'aarch64' ])
|
||||
@pytest.mark.parametrize('os', [ 'debian', 'alpine' ])
|
||||
def test_build_pihole_image(os, arch):
|
||||
''' Build the entire matrix of OS+Architecture '''
|
||||
dockerfile = 'Dockerfile_{}_{}'.format(os, arch)
|
||||
image_tag = '{}:{}_{}'.format('pi-hole', os, arch)
|
||||
build_cmd = run_local('docker build --pull -f {} -t {} .'.format(dockerfile, image_tag))
|
||||
if build_cmd.rc != 0:
|
||||
print build_cmd.stdout
|
||||
print build_cmd.stderr
|
||||
assert build_cmd.rc == 0
|
Loading…
Reference in New Issue