Skip to content

Commit 7456021

Browse files
committed
Enable a containerized version of the ADD API endpoint
[CLOUDDST-28643]
1 parent 928990a commit 7456021

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

iib/web/api_v1.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
from iib.web.s3_utils import get_object_from_s3_bucket
4545
from botocore.response import StreamingBody
4646
from iib.web.utils import pagination_metadata, str_to_bool
47-
from iib.workers.tasks.build import (
48-
handle_add_request,
47+
from iib.workers.tasks.build_containerized_add import (
48+
handle_containerized_add_request,
4949
)
5050
from iib.workers.tasks.build_containerized_rm import handle_containerized_rm_request
5151
from iib.workers.tasks.build_add_deprecations import handle_add_deprecations_request
@@ -619,7 +619,7 @@ def add_bundles() -> Tuple[flask.Response, int]:
619619
args.append(current_user.username)
620620

621621
try:
622-
handle_add_request.apply_async(
622+
handle_containerized_add_request.apply_async(
623623
args=args,
624624
link_error=error_callback,
625625
argsrepr=repr(safe_args),
@@ -1066,7 +1066,7 @@ def add_rm_batch() -> Tuple[flask.Response, int]:
10661066
error_callback = failed_request_callback.s(request.id)
10671067
try:
10681068
if isinstance(request, RequestAdd):
1069-
handle_add_request.apply_async(
1069+
handle_containerized_add_request.apply_async(
10701070
args=args,
10711071
link_error=error_callback,
10721072
argsrepr=repr(safe_args),

iib/workers/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class Config(object):
9494
'iib.workers.tasks.build_create_empty_index',
9595
'iib.workers.tasks.build_fbc_operations',
9696
'iib.workers.tasks.build_add_deprecations',
97+
'iib.workers.tasks.build_containerized_add',
9798
'iib.workers.tasks.build_containerized_fbc_operations',
9899
'iib.workers.tasks.build_containerized_rm',
99100
'iib.workers.tasks.general',

tests/test_web/test_api_v1.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ def test_add_bundles_graph_update_mode_not_allowed(
587587

588588
@pytest.mark.parametrize('from_index', ('some-common-index:v4.15', 'another-common-index:v4.15'))
589589
@mock.patch('iib.web.api_v1.messaging.send_message_for_state_change')
590-
@mock.patch('iib.web.api_v1.handle_add_request')
590+
@mock.patch('iib.web.api_v1.handle_containerized_add_request')
591591
def test_add_bundles_graph_update_mode_allowed(
592592
mock_har, mock_smfsc, app, client, auth_env, db, from_index
593593
):
@@ -611,7 +611,7 @@ def test_add_bundles_graph_update_mode_allowed(
611611
@mock.patch('iib.web.api_v1.db.session')
612612
@mock.patch('iib.web.api_v1.flask.jsonify')
613613
@mock.patch('iib.web.api_v1.RequestAdd')
614-
@mock.patch('iib.web.api_v1.handle_add_request.apply_async')
614+
@mock.patch('iib.web.api_v1.handle_containerized_add_request.apply_async')
615615
@mock.patch('iib.web.api_v1.messaging.send_message_for_state_change')
616616
def test_add_bundles_unique_bundles(mock_smfsc, mock_har, mock_radd, mock_fj, mock_dbs, client):
617617
data = {
@@ -830,7 +830,7 @@ def test_add_bundle_from_index_and_add_arches_missing(mock_smfsc, db, auth_env,
830830
('scratch', True, 'username:password', [], 'some:thing', 'DeV', 'semver'),
831831
),
832832
)
833-
@mock.patch('iib.web.api_v1.handle_add_request')
833+
@mock.patch('iib.web.api_v1.handle_containerized_add_request')
834834
@mock.patch('iib.web.api_v1.messaging.send_message_for_state_change')
835835
def test_add_bundle_success(
836836
mock_smfsc,
@@ -926,7 +926,7 @@ def test_add_bundle_success(
926926

927927

928928
@pytest.mark.parametrize('force_backport', (False, True))
929-
@mock.patch('iib.web.api_v1.handle_add_request')
929+
@mock.patch('iib.web.api_v1.handle_containerized_add_request')
930930
def test_add_bundle_force_backport(mock_har, force_backport, db, auth_env, client):
931931
data = {
932932
'bundles': ['some:thing'],
@@ -942,7 +942,7 @@ def test_add_bundle_force_backport(mock_har, force_backport, db, auth_env, clien
942942
assert mock_har.apply_async.call_args[1]['args'][7] == force_backport
943943

944944

945-
@mock.patch('iib.web.api_v1.handle_add_request')
945+
@mock.patch('iib.web.api_v1.handle_containerized_add_request')
946946
@mock.patch('iib.web.api_v1.messaging.send_message_for_state_change')
947947
def test_add_bundle_overwrite_token_redacted(mock_smfsc, mock_har, app, auth_env, client, db):
948948
token = 'username:password'
@@ -1002,7 +1002,7 @@ def test_add_bundle_overwrite_token_redacted(mock_smfsc, mock_har, app, auth_env
10021002
({'[email protected]': 'Patriots'}, True, None),
10031003
),
10041004
)
1005-
@mock.patch('iib.web.api_v1.handle_add_request')
1005+
@mock.patch('iib.web.api_v1.handle_containerized_add_request')
10061006
@mock.patch('iib.web.api_v1.messaging.send_message_for_state_change')
10071007
def test_add_bundle_custom_user_queue(
10081008
mock_smfsc, mock_har, app, auth_env, client, user_to_queue, overwrite_from_index, expected_queue
@@ -1807,7 +1807,7 @@ def test_regenerate_bundle_batch_invalid_input(payload, error_msg, app, auth_env
18071807
assert rv.json == {'error': error_msg}
18081808

18091809

1810-
@mock.patch('iib.web.api_v1.handle_add_request')
1810+
@mock.patch('iib.web.api_v1.handle_containerized_add_request')
18111811
@mock.patch('iib.web.api_v1.handle_containerized_rm_request')
18121812
@mock.patch('iib.web.api_v1.messaging.send_messages_for_new_batch_of_requests')
18131813
@mock.patch.dict('iib.web.api_v1.flask.current_app.config', {'IIB_INDEX_TO_GITLAB_PUSH_MAP': {}})

tests/test_web/test_broker_error.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def assert_testing(rv, mock_smfsc, db):
1515
assert req_state.state.state == RequestStateMapping.failed.value
1616

1717

18-
@mock.patch('iib.web.api_v1.handle_add_request')
18+
@mock.patch('iib.web.api_v1.handle_containerized_add_request')
1919
@mock.patch('iib.web.api_v1.messaging.send_message_for_state_change')
2020
def test_catch_add_bundle_failure(mock_smfsc, mock_har, db, auth_env, client):
2121
mock_har.apply_async.side_effect = OperationalError
@@ -108,7 +108,7 @@ def test_catch_regenerate_bundle_batch_failure(
108108
assert r.state == RequestStateMapping.failed.value
109109

110110

111-
@mock.patch('iib.web.api_v1.handle_add_request')
111+
@mock.patch('iib.web.api_v1.handle_containerized_add_request')
112112
@mock.patch('iib.web.api_v1.handle_containerized_rm_request')
113113
@mock.patch('iib.web.api_v1.messaging.send_messages_for_new_batch_of_requests')
114114
def test_add_rm_batch_add_failure(mock_smfnbor, mock_hrr, mock_har, app, auth_env, client, db):
@@ -158,7 +158,7 @@ def test_add_rm_batch_add_failure(mock_smfnbor, mock_hrr, mock_har, app, auth_en
158158
assert req_rm.state.state == RequestStateMapping.failed.value
159159

160160

161-
@mock.patch('iib.web.api_v1.handle_add_request')
161+
@mock.patch('iib.web.api_v1.handle_containerized_add_request')
162162
@mock.patch('iib.web.api_v1.handle_containerized_rm_request')
163163
@mock.patch('iib.web.api_v1.messaging.send_messages_for_new_batch_of_requests')
164164
def test_add_rm_batch_rm_failure(mock_smfnbor, mock_hrr, mock_har, app, auth_env, client, db):

0 commit comments

Comments
 (0)