-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
The request can have a key for the repository and that must be deleted for the underlying tasks to NOT attempt to create a new repository version, as that is where race conditions most often occur. No-Issue Signed-off-by: James Tanner <[email protected]> (cherry picked from commit 9900a96)
- Loading branch information
Showing
4 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
galaxy_ng/tests/integration/api/test_upload_concurrency.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import pytest | ||
|
||
import concurrent.futures | ||
|
||
from ..utils import ( | ||
AnsibleDistroAndRepo, | ||
ansible_galaxy, | ||
build_collection, | ||
create_unused_namespace, | ||
get_client, gen_string, | ||
) | ||
|
||
|
||
@pytest.mark.standalone_only | ||
def test_upload_concurrency(ansible_config, settings, galaxy_client): | ||
|
||
total = 10 | ||
|
||
config = ansible_config(profile="admin") | ||
client = get_client( | ||
config=config | ||
) | ||
|
||
# make a repo | ||
repo = AnsibleDistroAndRepo( | ||
client, | ||
gen_string(), | ||
) | ||
repo_data = repo.get_repo() | ||
repo_name = repo_data['name'] | ||
|
||
# make 10 namespaces | ||
namespaces = [create_unused_namespace(client) for x in range(0, total + 1)] | ||
|
||
# make a collection for each namespace | ||
artifacts = [] | ||
for namespace in namespaces: | ||
artifact = build_collection(namespace=namespace, name='foo') | ||
artifacts.append(artifact) | ||
|
||
server_url = config.get('url').rstrip('/') + '/content/' + repo_data['name'] + '/' | ||
|
||
args_list = [f"collection publish -vvvv {x.filename}" for x in artifacts] | ||
kwargs_list = [{'ansible_config': config, 'server_url': server_url} for x in artifacts] | ||
|
||
with concurrent.futures.ThreadPoolExecutor(max_workers=total) as executor: | ||
|
||
future_to_args_kwargs = { | ||
executor.submit(ansible_galaxy, args, **kwargs): (args, kwargs) | ||
for args, kwargs in zip(args_list, kwargs_list) | ||
} | ||
|
||
for future in concurrent.futures.as_completed(future_to_args_kwargs): | ||
args, kwargs = future_to_args_kwargs[future] | ||
try: | ||
result = future.result() | ||
except Exception as exc: | ||
print(f"Function raised an exception: {exc}") | ||
else: | ||
print(f"Function returned: {result}") | ||
|
||
gc = galaxy_client("admin") | ||
cvs = gc.get( | ||
( | ||
"/api/automation-hub/v3/plugin/ansible/search/collection-versions/" | ||
+ f"?repository_name={repo_name}" | ||
) | ||
) | ||
|
||
assert cvs['meta']['count'] == len(artifacts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters