forked from sclorg/nginx-container
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_container_sizes.py
More file actions
50 lines (43 loc) · 1.64 KB
/
test_container_sizes.py
File metadata and controls
50 lines (43 loc) · 1.64 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
import pytest
from container_ci_suite.container_lib import ContainerTestLib
from container_ci_suite.compare_images import ContainerCompareClass
from container_ci_suite.utils import get_public_image_name, get_previous_os_version
from conftest import VARS
class TestNginxContainerSizes:
"""
Test container sizes
"""
def setup_method(self):
"""
Setup method
"""
self.app = ContainerTestLib(image_name=VARS.IMAGE_NAME, s2i_image=True)
def teardown_method(self):
"""
Teardown method
"""
self.app.cleanup()
def test_compare_container_sizes(self):
"""
Test the size of the Nginx container against the
already published container images.
"""
published_image_name = get_public_image_name(
os_name=get_previous_os_version(VARS.OS),
base_image_name="postgresql",
version=VARS.VERSION,
stage_registry=True,
)
is_less_uncopressed = ContainerCompareClass.is_uncompressed_image_smaller(
built_image_name=VARS.IMAGE_NAME,
published_image=published_image_name,
)
is_less_compressed = ContainerCompareClass.is_compressed_image_smaller(
built_image_name=VARS.IMAGE_NAME,
published_image_name=published_image_name,
)
if not is_less_uncopressed or not is_less_compressed:
pytest.skip(
f"Container size is not less than the published image {published_image_name}. "
f"Uncompressed image size: {is_less_uncopressed}, Compressed image size: {is_less_compressed}"
)