def setUp(self): super(TestErrataAuthorizedGet, self).setUp() self.errata = Errata("https://localhost/") self.patcher = helpers.Patcher('freshmaker.errata.') self.requests_get = self.patcher.patch("requests.get") self.response = MagicMock() self.response.json.return_value = {"foo": "bar"} self.unlink = self.patcher.patch("os.unlink")
def setUp(self): super(TestBotasShippedAdvisory, self).setUp() # Each time when recording a build into database, freshmaker has to # request a pulp repo from ODCS. This is not necessary for running # tests. self.patcher = helpers.Patcher( 'freshmaker.handlers.botas.botas_shipped_advisory.') self.pyxis = self.patcher.patch("Pyxis") # We do not want to send messages to message bus while running tests self.mock_messaging_publish = self.patcher.patch( 'freshmaker.messaging.publish') self.handler = HandleBotasAdvisory() self.botas_advisory = ErrataAdvisory(123, "RHBA-2020", "SHIPPED_LIVE", ['docker']) self.botas_advisory._reporter = "botas/[email protected]"
def setUp(self): super(TestPrepareYumReposForRebuilds, self).setUp() self.patcher = helpers.Patcher() self.mock_prepare_yum_repo = self.patcher.patch( 'freshmaker.odcsclient.FreshmakerODCSClient.prepare_yum_repo', side_effect=[ { 'id': 1, 'result_repofile': 'http://localhost/repo/1' }, { 'id': 2, 'result_repofile': 'http://localhost/repo/2' }, { 'id': 3, 'result_repofile': 'http://localhost/repo/3' }, { 'id': 4, 'result_repofile': 'http://localhost/repo/4' }, ]) self.mock_find_dependent_event = self.patcher.patch( 'freshmaker.models.Event.find_dependent_events') self.db_event = Event.create(db.session, 'msg-1', 'search-key-1', 1, state=EventState.INITIALIZED, released=False) self.build_1 = ArtifactBuild.create(db.session, self.db_event, 'build-1', ArtifactType.IMAGE) self.build_2 = ArtifactBuild.create(db.session, self.db_event, 'build-2', ArtifactType.IMAGE) db.session.commit()
def setUp(self): super(TestRebuildImagesOnAsyncManualBuild, self).setUp() self.patcher = helpers.Patcher( 'freshmaker.handlers.koji.RebuildImagesOnAsyncManualBuild.') # We do not want to send messages to message bus while running tests self.mock_messaging_publish = self.patcher.patch( 'freshmaker.messaging.publish') # Mocking koji self.mock_get_build = self.patcher.patch( 'freshmaker.kojiservice.KojiService.get_build', return_value={'build_id': 123456, 'extra': {'container_koji_task_id': 21938204}}) self.mock_get_task_request = self.patcher.patch( 'freshmaker.kojiservice.KojiService.get_task_request', return_value=[ 'git://example.com/rpms/repo-1#commit_hash1', 'test-target', {'compose_ids': None, 'git_branch': 'test_branch', 'scratch': False, 'signing_intent': None, 'yum_repourls': [('fake-url.repo')]}]) self.mock_allow_build = self.patcher.patch('allow_build', return_value=True) # Mocking Lightblue self.mock_find_images_to_rebuild = self.patcher.patch('_find_images_to_rebuild') self.mock_lightblue = self.patcher.patch('init_lightblue_instance') self.mock_start_to_build_images = self.patcher.patch('start_to_build_images') self.mock_get_image_builds_in_first_batch = self.patcher.patch( 'freshmaker.models.Event.get_image_builds_in_first_batch') # Structure of the images used for testing: # image_0 # + # | # + # image_a # + # | # +----+----+ # | | # + + # image_b image_d # + # | # + # image_e # image_c and image_f are unrelated. # image_0 is a base image, with no parent self.image_0 = ContainerImage({ 'repository': 'repo_1', 'commit': '1234567', 'target': 'container-candidate', 'git_branch': 'test_branch', 'content_sets': ['image_0_content_set_1', 'image_0_content_set_2'], 'arches': 'x86_64', 'brew': { 'build': 'image-container-1.0-2', 'package': 'image-container', }, 'parent': None, 'parsed_data': { 'layers': [ 'sha512:7890', 'sha512:5678', ] }, 'published': False, }) self.image_a = ContainerImage({ 'repository': 'repo_1', 'commit': '1234567', 'target': 'container-candidate', 'git_branch': 'test_branch', 'content_sets': ['image_a_content_set_1', 'image_a_content_set_2'], 'arches': 'x86_64', 'brew': { 'build': 'image-a-container-1.0-2', 'package': 'image-a-container', }, 'parent': self.image_0, 'parsed_data': { 'layers': [ 'sha512:7890', 'sha512:5678', ] }, 'published': False, }) # image_b is a child image of image_a self.image_b = ContainerImage({ 'repository': 'repo_2', 'commit': '5678901', 'target': 'container-candidate', 'git_branch': 'test_branch', 'content_sets': ['image_b_content_set_1', 'image_b_content_set_2'], 'arches': 'x86_64', 'brew': { 'build': 'image-b-container-2.14-1', 'package': 'image-b-container' }, 'parent': self.image_a, 'parsed_data': { 'layers': [ 'sha512:f109', 'sha512:7890', 'sha512:5678', ] }, 'published': False, }) # image_c is an image unrelated to image_a and image_b # it also has no parent image. # image_c has the same name of image_a, that's why it has this name self.image_c = ContainerImage({ 'repository': 'repo_1', 'commit': '1234569', 'target': 'container-candidate', 'git_branch': 'test_branch', 'content_sets': ['image_a_content_set_1', 'image_a_content_set_2'], 'arches': 'x86_64', 'brew': { 'build': 'image-a-container-1.0-3', 'package': 'image-a-container', }, 'parent': None, 'parsed_data': { 'layers': [ 'sha512:7890', 'sha512:5678', ] }, 'published': False, }) # image_d is a child image of image_a, same as image_b # so image_d and image_b are unrelated, since they are sibilings self.image_d = ContainerImage({ 'repository': 'repo_2', 'commit': '5678906', 'target': 'container-candidate', 'git_branch': 'test_branch', 'content_sets': ['image_d_content_set_1', 'image_d_content_set_2'], 'arches': 'x86_64', 'brew': { 'build': 'image-d-container-3.3-1', 'package': 'image-d-container' }, 'parent': self.image_a, 'parsed_data': { 'layers': [ 'sha512:f109', ] }, 'published': False, }) # image_e is a child image of image_d self.image_e = ContainerImage({ 'repository': 'repo_2', 'commit': '5678906', 'target': 'container-candidate', 'git_branch': 'test_branch', 'content_sets': ['image_e_content_set_1', 'image_e_content_set_2'], 'arches': 'x86_64', 'brew': { 'build': 'image-e-container-3.3-1', 'package': 'image-e-container' }, 'parent': self.image_d, 'parsed_data': { 'layers': [ 'sha512:f109', ] }, 'published': False, }) self.image_f = ContainerImage({ 'architecture': 'arm64', 'brew': {'build': 's2i-core-container-1-147', 'completion_date': '20200603T12:00:24.000-0400', 'nvra': 's2i-core-container-1-147.arm64', 'package': 's2i-core-container'}, 'content_sets': ['rhel-8-for-x86_64-appstream-rpms', 'rhel-8-for-aarch64-baseos-rpms', 'rhel-8-for-x86_64-baseos-rpms', 'rhel-8-for-s390x-baseos-rpms', 'rhel-8-for-aarch64-appstream-rpms', 'rhel-8-for-ppc64le-appstream-rpms', 'rhel-8-for-ppc64le-baseos-rpms', 'rhel-8-for-s390x-appstream-rpms'], 'multi_arch_rpm_manifest': {}, 'parent_brew_build': 'ubi8-container-8.2-299', 'parsed_data': {}, 'repositories': [{'published': True, 'repository': 'rhel8/s2i-core', 'tags': [{'name': '1-147'}]}, {'published': True, 'repository': 'ubi8/s2i-core', 'tags': [{'name': '1-147'}]}] })
def setUp(self): super().setUp() self.patcher = helpers.Patcher('freshmaker.pyxis.') self.fake_server_url = 'https://pyxis.localhost/' self.px = Pyxis(self.fake_server_url) self.response = create_autospec(requests.Response) self.response.status_code = HTTPStatus.OK self.bad_requests_response = { "detail": [ "Unable to parse the filter from URL.", "Please verify the 'Field Name' in the RSQL Expression.", "Please visit the following end-point for more details:", " /v1/docs/filtering-language" ], "status": 400, "title": "Bad Request", "type": "about:blank" } self.empty_response_page = { "data": [], "page": 0, "page_size": 100, "total": 0 } self.indices = [{ "_id": "1", "created_by": "meteor", "creation_date": "2020-01-01T09:32:31.692000+00:00", "last_update_date": "2020-01-01T09:32:31.692000+00:00", "last_updated_by": "meteor", "ocp_version": "4.5", "organization": "org", "path": "path/to/registry:v4.5" }, { "_id": "2", "created_by": "meteor", "creation_date": "2020-01-01T09:32:38.486000+00:00", "last_update_date": "2020-01-01T09:32:38.486000+00:00", "last_updated_by": "meteor", "ocp_version": "4.6", "organization": "org", "path": "path/to/registry:v4.6" }, { "_id": "2", "created_by": "meteor", "creation_date": "2020-01-01T09:32:38.486000+00:00", "last_update_date": "2020-01-01T09:32:38.486000+00:00", "last_updated_by": "meteor", "ocp_version": "4.6", "organization": "org", "path": "" }] self.bundles = [ { "channel_name": "streams-1.5.x", "related_images": [{ "image": "registry/amq7/amq-streams-r-operator@sha256:111", "name": "strimzi-cluster-operator", "digest": "sha256:111" }, { "image": "registry/amq7/amq-streams-kafka-24-r@sha256:222", "name": "strimzi-kafka-24", "digest": "sha256:222" }, { "image": "registry/amq7/amq-streams-kafka-25-r@sha256:333", "name": "strimzi-kafka-25", "digest": "sha256:333" }, { "image": "registry/amq7/amq-streams-bridge-r@sha256:444", "name": "strimzi-bridge", "digest": "sha256:444" }], "version": "1.5.3" }, { "channel_name": "streams-1.5.x", "related_images": [{ "image": "registry/amq7/amq-streams-r-operator@sha256:555", "name": "strimzi-cluster-operator", "digest": "sha256:555" }, { "image": "registry/amq7/amq-streams-kafka-24-r@sha256:666", "name": "strimzi-kafka-24", "digest": "sha256:666" }, { "image": "registry/amq7/amq-streams-kafka-25-r@sha256:777", "name": "strimzi-kafka-25", "digest": "sha256:777" }, { "image": "registry/amq7/amq-streams-bridge-r@sha256:888", "name": "strimzi-bridge", "digest": "sha256:888" }], "version": "1.5.4" }, { "channel_name": "stable", "related_images": [{ "image": "registry/amq7/amq--operator@sha256:999", "name": "strimzi-cluster-operator", "digest": "sha256:999" }, { "image": "registry/amq7/kafka-24-r@sha256:aaa", "name": "strimzi-kafka-24", "digest": "sha256:aaa" }, { "image": "registry/amq7/kafka-25-r@sha256:bbb", "name": "strimzi-kafka-25", "digest": "sha256:bbb" }, { "image": "registry/amq7/amq-streams-bridge-r@sha256:ccc", "name": "strimzi-bridge", "digest": "sha256:ccc" }], "version": "1.5.3" }, { "channel_name": "stable", "related_images": [{ "image": "registry/tracing/j-operator:1.13.2", "name": "j-1.13.2-annotation", "digest": "sha256:fff" }, { "image": "registry/tracing/j-operator:1.13.2", "name": "j-operator", "digest": "sha256:ffff" }], "version": "1.5.2" }, { "channel_name": "quay-v3.3", "related_images": [{ "image": "registry/quay/quay-operator@sha256:ddd", "name": "quay-operator-annotation", "digest": "sha256:ddd" }, { "image": "registry/quay/quay-security-r-operator@sha256:eee", "name": "container-security-operator", "digest": "sha256:eee" }], "version": "3.3.1" }, ] self.images = [{ "brew": { "build": "s2i-1-2", "completion_date": "2020-08-12T11:31:39+00:00", "nvra": "s2i-1-2.ppc64le", "package": "s2i-core-container" }, "repositories": [{ "manifest_list_digest": "sha256:1111", "published": False, "registry": "reg1", "repository": "repo1", "tags": [{ "name": "tag0" }] }, { "manifest_list_digest": "sha256:1112", "published": True, "registry": "reg2", "repository": "repo2", "tags": [{ "name": "tag1" }, { "name": "tag2" }] }] }, { "brew": { "build": "s2i-1-2", "completion_date": "2020-08-12T11:31:39+00:00", "nvra": "s2i-1-2.s390x", "package": "s2i-core-container" }, "repositories": [{ "manifest_list_digest": "sha256:2222", "published": True, "registry": "reg2", "repository": "repo2", "tags": [{ "name": "tag2" }] }] }, { "brew": { "build": "s2i-1-2", "completion_date": "2020-08-12T11:31:39+00:00", "nvra": "s2i-1-2.amd64", "package": "s2i-core-container" }, "repositories": [{ "manifest_list_digest": "sha256:3333", "published": True, "registry": "reg3", "repository": "repo3", "tags": [{ "name": "latest" }] }] }, { "brew": { "build": "s2i-1-2", "completion_date": "2020-08-12T11:31:39+00:00", "nvra": "s2i-1-2.arm64", "package": "s2i-core-container" }, "repositories": [{ "manifest_list_digest": "sha256:4444", "published": True, "registry": "reg4", "repository": "repo4", "tags": [{ "name": "tag1" }] }] }]
def setUp(self): super(TestErrata, self).setUp() self.errata = Errata("https://localhost/") self.patcher = helpers.Patcher('freshmaker.errata.SFM2API.') self.patcher.patch("fetch_cve_metadata", return_value=["moderate", {}])