-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile_node_test.py
More file actions
100 lines (74 loc) · 2.2 KB
/
Dockerfile_node_test.py
File metadata and controls
100 lines (74 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import pytest
import subprocess
import testinfra
@pytest.fixture(scope="session")
def host(request):
image = "landtech/ci-node"
subprocess.check_call(
["docker", "build", "-t", image, "-f", "Dockerfile_node", "."]
)
container = (
subprocess.check_output(["docker", "run", "--rm", "--detach", "--tty", image])
.decode()
.strip()
)
yield testinfra.get_host("docker://" + container)
subprocess.check_call(["docker", "rm", "-f", container])
@pytest.mark.parametrize(
"package",
[
("bash"),
("coreutils"),
("curl"),
("docker"),
("docker-compose"),
("grep"),
("jq"),
("lsof"),
("libressl"),
("make"),
("netcat-openbsd"),
("ncurses"),
("rsync"),
("tar"),
("util-linux"),
("wget"),
("yarn"),
("zip"),
],
)
def test_installed_dependencies(host, package):
assert host.package(package).is_installed
def test_awscli_alias(host):
assert host.file("/root/.aws/cli/alias").exists
# run a version command with an alias, a fail will return code 2
assert host.run("aws account-id --version").succeeded
def test_docker(host):
assert host.run("docker --version").succeeded
def test_bats(host):
assert host.run("bats --version").succeeded
def test_pip_packages(host):
packages = host.pip.get_packages()
assert "awscli" in packages
assert "credstash" in packages
assert "pipenv" in packages
assert "yq" in packages
def test_pipenv_works(host):
host.run(
"echo '"
"[[source]]\n"
'name = "pypi"\n'
'url = "https://pypi.org/simple"\n'
"verify_ssl = true' > Pipfile"
)
assert host.run("pipenv install").succeeded
def test_node(host):
assert host.run("node --version").succeeded
def test_semver_exists(host):
assert host.run("semver.sh --help").succeeded
def test_deployment_exists(host):
assert host.run("command -v deployment").succeeded
assert host.run("timeout --help").succeeded
assert host.run("command -v nc").succeeded
def test_entrypoint_is_bash(host):
assert host.check_output("echo $SHELL") == "/bin/bash"