-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathpulp_test.py
More file actions
106 lines (77 loc) · 3.71 KB
/
pulp_test.py
File metadata and controls
106 lines (77 loc) · 3.71 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
101
102
103
104
105
106
import json
import pytest
PULP_HOST = 'localhost'
PULP_API_PORT = 24817
PULP_CONTENT_PORT = 24816
@pytest.fixture(scope="module")
def pulp_status_curl(server):
return server.run(f"curl -k -s -w '%{{stderr}}%{{http_code}}' http://{PULP_HOST}:{PULP_API_PORT}/pulp/api/v3/status/")
@pytest.fixture(scope="module")
def pulp_status(pulp_status_curl):
return json.loads(pulp_status_curl.stdout)
@pytest.fixture(scope="module")
def pulp_import_export_paths(server):
result = server.run("podman inspect pulp-api --format '{{json .Config.Env}}'")
assert result.succeeded
env = {v.split('=', 1)[0]: v.split('=', 1)[1] for v in json.loads(result.stdout)}
import_paths = json.loads(env['PULP_ALLOWED_IMPORT_PATHS'].replace("'", '"'))
export_paths = json.loads(env['PULP_ALLOWED_EXPORT_PATHS'].replace("'", '"'))
return import_paths, export_paths
def test_pulp_api_service(server):
pulp_api = server.service("pulp-api")
assert pulp_api.is_running
def test_pulp_content_service(server):
pulp_content = server.service("pulp-content")
assert pulp_content.is_running
def test_pulp_worker_services(server):
result = server.run("systemctl list-units --all --type=service --no-legend 'pulp-worker@*.service' | awk '{print $1}'")
worker_services = [s.strip() for s in result.stdout.split('\n') if s.strip()]
assert len(worker_services) > 0
for worker_service in worker_services:
worker = server.service(worker_service)
assert worker.is_running
def test_pulp_api_port(server):
pulp_api = server.addr(PULP_HOST)
assert pulp_api.port(PULP_API_PORT).is_reachable
def test_pulp_content_port(server):
pulp_content = server.addr(PULP_HOST)
assert pulp_content.port(PULP_CONTENT_PORT).is_reachable
def test_pulp_status(pulp_status_curl):
assert pulp_status_curl.succeeded
assert pulp_status_curl.stderr == '200'
def test_pulp_status_database_connection(pulp_status):
assert pulp_status['database_connection']['connected']
def test_pulp_status_redis_connection(pulp_status):
assert pulp_status['redis_connection']['connected']
def test_pulp_status_api(pulp_status):
assert pulp_status['online_api_apps']
def test_pulp_status_content(pulp_status):
assert pulp_status['online_content_apps']
def test_pulp_status_workers(pulp_status):
assert pulp_status['online_workers']
def test_pulp_volumes(server):
assert server.file("/var/lib/pulp").is_directory
def test_pulp_worker_target(server):
pulp_worker_target = server.service("pulp-worker.target")
assert pulp_worker_target.is_running
assert pulp_worker_target.is_enabled
def test_pulp_manager_check(server):
result = server.run("podman exec -ti pulp-api pulpcore-manager check --deploy")
assert result.succeeded
def test_pulp_import_directories(server, pulp_import_export_paths):
import_paths, _ = pulp_import_export_paths
for path in import_paths:
assert server.file(path).is_directory
def test_pulp_export_directories(server, pulp_import_export_paths):
_, export_paths = pulp_import_export_paths
for path in export_paths:
assert server.file(path).is_directory
@pytest.mark.parametrize("container", ["pulp-api", "pulp-content", "pulp-worker-1"])
def test_pulp_import_export_volume_mounts(server, container, pulp_import_export_paths):
import_paths, export_paths = pulp_import_export_paths
result = server.run(f"podman inspect {container} --format '{{{{json .Mounts}}}}'")
assert result.succeeded
mounts = json.loads(result.stdout)
destinations = [mount['Destination'] for mount in mounts]
for path in import_paths + export_paths:
assert path in destinations, f"expected {path} to be mounted as a volume in {container}"