Skip to content

Commit

Permalink
Pk5/fix integration tests for release (#195)
Browse files Browse the repository at this point in the history
* Add retry logic to fix integration tests

* Modify the publisher name because previous name is used up

* Regenerate the recordings
  • Loading branch information
patrykkulik-microsoft authored May 16, 2024
1 parent ca17b6d commit f5a787a
Show file tree
Hide file tree
Showing 14 changed files with 1,339 additions and 1,027 deletions.
27 changes: 21 additions & 6 deletions src/aosm/azext_aosm/common/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from azext_aosm.common.registry import ContainerRegistry, AzureContainerRegistry
from azext_aosm.vendored_sdks.models import ArtifactType
from azext_aosm.vendored_sdks import HybridNetworkManagementClient
from azure.core.exceptions import ServiceResponseError
from knack.log import get_logger
from oras.client import OrasClient

Expand Down Expand Up @@ -82,12 +83,26 @@ def _manifest_credentials(
aosm_client: HybridNetworkManagementClient,
) -> MutableMapping[str, Any]:
"""Gets the details for uploading the artifacts in the manifest."""
return aosm_client.artifact_manifests.list_credential(
resource_group_name=config.publisherResourceGroupName,
publisher_name=config.publisherName,
artifact_store_name=config.acrArtifactStoreName,
artifact_manifest_name=config.acrManifestName,
).as_dict()
retries = 0
# This retry logic is to handle the ServiceResponseError that is hit in the integration tests.
# This error is not hit when running the cli normally because the CLI framework automatically retries,
# the testing framework does not support automatic retries.
while retries < 2:
try:
credential_dict = aosm_client.artifact_manifests.list_credential(
resource_group_name=config.publisherResourceGroupName,
publisher_name=config.publisherName,
artifact_store_name=config.acrArtifactStoreName,
artifact_manifest_name=config.acrManifestName,
).as_dict()
break
except ServiceResponseError as error:
retries += 1
if retries == 2:
logger.debug(error, exc_info=True)
raise ServiceResponseError("Failed to get manifest credentials.")

return credential_dict

@staticmethod
def _get_oras_client(manifest_credentials: MutableMapping[str, Any]) -> OrasClient:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"location": "uksouth",
// Name of the Publisher resource you want your definition published to.
// Will be created if it does not exist.
"publisher_name": "automated-cli-tests-nginx-publisher",
"publisher_name": "automated-cli-test-nginx-publisher",
// Optional. Resource group for the Publisher resource.
// Will be created if it does not exist (with a default name if none is supplied).
"publisher_resource_group_name": "{{publisher_resource_group_name}}",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"publisher_name": "automated-cli-tests-nginx-publisher",
"publisher_name": "automated-cli-test-nginx-publisher",
"publisher_resource_group_name": "{{publisher_resource_group_name}}",
"acr_artifact_store_name": "nginx-nsd-acr",
"location": "uksouth",
"network_functions": [
{
"publisher": "automated-cli-tests-nginx-publisher",
"publisher": "automated-cli-test-nginx-publisher",
"publisher_resource_group": "{{publisher_resource_group_name}}",
"name": "nginx-nfdg",
"version": "1.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"location": "uksouth",
"publisher_name": "automated-cli-tests-ubuntu-publisher",
"publisher_name": "automated-cli-test-ubuntu-publisher",
"publisher_resource_group_name": "cli_test_nsd",
"acr_artifact_store_name": "ubuntu-acr",
"resource_element_templates": [
{
"resource_element_type": "NF",
"properties": {
// The name of the existing publisher for the NSD.
"publisher": "automated-cli-tests-ubuntu-publisher",
"publisher": "automated-cli-test-ubuntu-publisher",
// The resource group that the publisher is hosted in.
"publisher_resource_group": "cli_test_nsd",
// The name of the existing Network Function Definition Group to deploy using this NSD.
Expand All @@ -26,7 +26,7 @@
"resource_element_type": "NF",
"properties": {
// The name of the existing publisher for the NSD.
"publisher": "automated-cli-tests-ubuntu-publisher",
"publisher": "automated-cli-test-ubuntu-publisher",
// The resource group that the publisher is hosted in.
"publisher_resource_group": "cli_test_nsd",
// The name of the existing Network Function Definition Group to deploy using this NSD.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"location": "uksouth",
"publisher_name": "automated-cli-tests-ubuntu-publisher",
"publisher_name": "automated-cli-test-ubuntu-publisher",
"publisher_resource_group_name": "cli_test_nsd",
"acr_artifact_store_name": "ubuntu-acr",
"resource_element_templates": [
{
"resource_element_type": "NF",
"properties": {
// The name of the existing publisher for the NSD.
"publisher": "automated-cli-tests-ubuntu-publisher",
"publisher": "automated-cli-test-ubuntu-publisher",
// The resource group that the publisher is hosted in.
"publisher_resource_group": "cli_test_nsd",
// The name of the existing Network Function Definition Group to deploy using this NSD.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"location": "uksouth",
"publisher_name": "automated-cli-tests-ubuntu-publisher",
"publisher_name": "automated-cli-test-ubuntu-publisher",
"publisher_resource_group_name": "test_publisher_name",
"acr_artifact_store_name": "ubuntu-acr",
"resource_element_templates": [
{
"resource_element_type": "NF",
"properties": {
// The name of the existing publisher for the NSD.
"publisher": "automated-cli-tests-ubuntu-publisher",
"publisher": "automated-cli-test-ubuntu-publisher",
// The resource group that the publisher is hosted in.
"publisher_resource_group": "test_publisher_name",
// The name of the existing Network Function Definition Group to deploy using this NSD.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"location": "uksouth",
// Name of the Publisher resource you want your definition published to.
// Will be created if it does not exist.
"publisher_name": "automated-cli-tests-ubuntu-publisher",
"publisher_name": "automated-cli-test-ubuntu-publisher",
// Optional. Resource group for the Publisher resource.
// Will be created if it does not exist (with a default name if none is supplied).
"publisher_resource_group_name": "{{publisher_resource_group_name}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"location": "uksouth",
// Name of the Publisher resource you want your definition published to.
// Will be created if it does not exist.
"publisher_name": "automated-cli-tests-ubuntu-publisher",
"publisher_name": "automated-cli-test-ubuntu-publisher",
// Optional. Resource group for the Publisher resource.
// Will be created if it does not exist (with a default name if none is supplied).
"publisher_resource_group_name": "{{publisher_resource_group_name}}",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"location": "uksouth",
"publisher_name": "automated-cli-tests-ubuntu-publisher",
"publisher_name": "automated-cli-test-ubuntu-publisher",
"publisher_resource_group_name": "{{publisher_resource_group_name}}",
"acr_artifact_store_name": "ubuntu-acr",
"resource_element_templates": [
{
"resource_element_type": "NF",
"properties": {
// The name of the existing publisher for the NSD.
"publisher": "automated-cli-tests-ubuntu-publisher",
"publisher": "automated-cli-test-ubuntu-publisher",
// The resource group that the publisher is hosted in.
"publisher_resource_group": "{{publisher_resource_group_name}}",
// The name of the existing Network Function Definition Group to deploy using this NSD.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"location": "uksouth",
"publisherName": "automated-cli-tests-ubuntu-publisher",
"publisherName": "automated-cli-test-ubuntu-publisher",
"publisherResourceGroupName": "test_publisher_name",
"acrArtifactStoreName": "ubuntu-acr",
"acrManifestName": "ubuntu-nsd-manifest-1-0-0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"location": "uksouth",
"publisherName": "automated-cli-tests-ubuntu-publisher",
"publisherName": "automated-cli-test-ubuntu-publisher",
"publisherResourceGroupName": "cli_test_nsd",
"acrArtifactStoreName": "ubuntu-acr",
"acrManifestName": "ubuntu-nsd-manifest-1-0-0",
Expand Down
Loading

0 comments on commit f5a787a

Please sign in to comment.