-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathtest_helper_scripts.py
90 lines (71 loc) · 2.98 KB
/
test_helper_scripts.py
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
import pytest
@pytest.mark.php
def test_php_images_contain_helper_scripts(host):
official_helper_scripts = [
"/usr/local/bin/docker-php-entrypoint",
"/usr/local/bin/docker-php-ext-configure",
"/usr/local/bin/docker-php-ext-enable",
"/usr/local/bin/docker-php-ext-install",
"/usr/local/bin/docker-php-source",
]
for file in official_helper_scripts:
expected_file_mode = get_expected_os_mode(host)
assert host.file(file).exists is True
assert host.file(file).is_file is True
assert host.file(file).mode == expected_file_mode
helper_scripts = [
"/usr/local/bin/docker-php-dev-mode",
"/usr/local/bin/docker-php-entrypoint-init",
"/usr/local/bin/docker-php-ext-pdo-pgsql",
"/usr/local/bin/docker-php-ext-rdkafka",
"/usr/local/bin/docker-php-source-tarball",
"/usr/local/bin/php-fpm-healthcheck",
]
for file in helper_scripts:
assert host.file(file).exists is True
assert host.file(file).is_file is True
assert host.file(file).mode == 0o755
@pytest.mark.php_dev
def test_php_images_contain_dev_helper_scripts(host):
file = host.file('/usr/local/bin/docker-php-dev-mode')
assert file.is_file is True
assert file.mode == 0o755
@pytest.mark.php
def test_php_source_tarball_script(host):
assert host.file("/usr/src/php.tar.xz").exists is False
assert host.file("/usr/src/php.tar.xz.asc").exists is False
assert host.file("/usr/src/php").exists is False
host.run("apk add --no-cache gnupg")
host.run("docker-php-source-tarball download")
assert host.file("/usr/src/php.tar.xz").exists is True
assert host.file("/usr/src/php.tar.xz.asc").exists is True
assert host.file("/usr/src/php").exists is False
host.run("docker-php-source extract")
assert host.file("/usr/src/php").exists is True
host.run("docker-php-source-tarball delete")
assert host.file("/usr/src/php.tar.xz").exists is False
assert host.file("/usr/src/php.tar.xz.asc").exists is False
assert host.file("/usr/src/php").exists is True
host.run("docker-php-source-tarball clean")
assert host.file("/usr/src/php").exists is False
@pytest.mark.php_fpm
def test_php_fpm_status_is_enabled(host):
health_check = host.run("php-fpm-healthcheck -v")
assert health_check.rc == 0
assert "pool:" in health_check.stdout
@pytest.mark.php
def test_php_extension_script_for_rdkafka(host):
host.run_expect([0], "docker-php-ext-rdkafka")
assert 'rdkafka' in host.run('php -m').stdout
@pytest.mark.php
def test_php_extension_script_for_pdo_pgsql(host):
host.run_expect([0], "docker-php-ext-pdo-pgsql")
assert 'pdo_pgsql' in host.run('php -m').stdout
def get_os_version(host):
return host.run("cat /etc/alpine-release").stdout
def get_expected_os_mode(host):
expected_file_mode = 0o775
os_version = get_os_version(host)
if os_version > "3.17.999":
expected_file_mode = 0o755
return expected_file_mode