Merge pull request #33983 from ClickHouse/docker-green-on-retry

Fix dependencies tree for docker image check
This commit is contained in:
Ilya Yatsishin 2022-01-25 14:43:00 +03:00 committed by GitHub
commit fe84167c99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 72 additions and 22 deletions

View File

@ -38,9 +38,22 @@ class DockerImage:
self.parent = parent
self.built = False
def __eq__(self, other):
def __eq__(self, other) -> bool: # type: ignore
"""Is used to check if DockerImage is in a set or not"""
return self.path == other.path
return self.path == other.path and self.repo == self.repo
def __lt__(self, other) -> bool:
if not isinstance(other, DockerImage):
return False
if self.parent and not other.parent:
return False
if not self.parent and other.parent:
return True
if self.path < other.path:
return True
if self.repo < other.repo:
return True
return False
def __hash__(self):
return hash(self.path)
@ -49,7 +62,7 @@ class DockerImage:
return self.repo
def __repr__(self):
return f"DockerImage(path={self.path},path={self.path},parent={self.parent})"
return f"DockerImage(path={self.path},repo={self.repo},parent={self.parent})"
def get_changed_docker_images(
@ -105,7 +118,9 @@ def get_changed_docker_images(
dependent,
image,
)
changed_images.append(DockerImage(dependent, image.repo, image))
changed_images.append(
DockerImage(dependent, images_dict[dependent]["name"], image)
)
index += 1
if index > 5 * len(images_dict):
# Sanity check to prevent infinite loop.

View File

@ -22,24 +22,59 @@ class TestDockerImageCheck(unittest.TestCase):
"docker/test/base",
"docker/docs/builder",
}
images = di.get_changed_docker_images(pr_info, "/", self.docker_images_path)
expected = {
di.DockerImage("docker/test/base", "clickhouse/test-base"),
di.DockerImage("docker/docs/builder", "clickhouse/docs-builder"),
di.DockerImage("docker/test/stateless", "clickhouse/stateless-test"),
di.DockerImage(
"docker/test/integration/base", "clickhouse/integration-test"
),
di.DockerImage("docker/test/fuzzer", "clickhouse/fuzzer"),
di.DockerImage(
"docker/test/keeper-jepsen", "clickhouse/keeper-jepsen-test"
),
di.DockerImage("docker/docs/check", "clickhouse/docs-check"),
di.DockerImage("docker/docs/release", "clickhouse/docs-release"),
di.DockerImage("docker/test/stateful", "clickhouse/stateful-test"),
di.DockerImage("docker/test/unit", "clickhouse/unit-test"),
di.DockerImage("docker/test/stress", "clickhouse/stress-test"),
}
images = sorted(
list(di.get_changed_docker_images(pr_info, "/", self.docker_images_path))
)
self.maxDiff = None
expected = sorted(
[
di.DockerImage("docker/test/base", "clickhouse/test-base"),
di.DockerImage("docker/docs/builder", "clickhouse/docs-builder"),
di.DockerImage(
"docker/test/stateless",
"clickhouse/stateless-test",
"clickhouse/test-base",
),
di.DockerImage(
"docker/test/integration/base",
"clickhouse/integration-test",
"clickhouse/test-base",
),
di.DockerImage(
"docker/test/fuzzer", "clickhouse/fuzzer", "clickhouse/test-base"
),
di.DockerImage(
"docker/test/keeper-jepsen",
"clickhouse/keeper-jepsen-test",
"clickhouse/test-base",
),
di.DockerImage(
"docker/docs/check",
"clickhouse/docs-check",
"clickhouse/docs-builder",
),
di.DockerImage(
"docker/docs/release",
"clickhouse/docs-release",
"clickhouse/docs-builder",
),
di.DockerImage(
"docker/test/stateful",
"clickhouse/stateful-test",
"clickhouse/stateless-test",
),
di.DockerImage(
"docker/test/unit",
"clickhouse/unit-test",
"clickhouse/stateless-test",
),
di.DockerImage(
"docker/test/stress",
"clickhouse/stress-test",
"clickhouse/stateful-test",
),
]
)
self.assertEqual(images, expected)
def test_gen_version(self):