Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix integration tests #163

Merged
merged 46 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
75798dd
Initial stab at making the multiple registry support work
patrykkulik-microsoft Feb 6, 2024
571ed65
Update TODO
patrykkulik-microsoft Feb 6, 2024
ebb0071
update TODO
patrykkulik-microsoft Feb 6, 2024
37b0cc8
Merge branch 'main' into pk5/improve_image_sourcing
Feb 7, 2024
6b73b71
merge fixes
patrykkulik-microsoft Feb 20, 2024
31f8a45
add logic to find registry credentials
patrykkulik-microsoft Feb 21, 2024
092e365
Code cleanup and adding unit tests
patrykkulik-microsoft Feb 22, 2024
fa7dbab
updates to the registry class
patrykkulik-microsoft Feb 29, 2024
3e68af5
In Progress work
patrykkulik-microsoft Mar 1, 2024
aa21e42
Working publish
patrykkulik-microsoft Mar 5, 2024
f0ab274
Move _push_image_from_local_registry and copy_image into the registry…
patrykkulik-microsoft Mar 5, 2024
ef2a072
tidy up changes
patrykkulik-microsoft Mar 7, 2024
dbb3967
Namespace and style fixes
patrykkulik-microsoft Mar 8, 2024
7a85e24
Minor input config change
patrykkulik-microsoft Mar 8, 2024
dbccbc3
unit tests
patrykkulik-microsoft Mar 8, 2024
fb1e4c1
Merge branch 'main' into pk5/improve_image_sourcing
patrykkulik-microsoft Mar 8, 2024
49e1d18
Do not push image namespace to target ACR
patrykkulik-microsoft Mar 12, 2024
5fd68c6
Make sure not to break the nexus part of the code
patrykkulik-microsoft Mar 12, 2024
406d12e
Update CHANGELOG
patrykkulik-microsoft Mar 12, 2024
81115bf
initial commit for integration tests
Mar 14, 2024
d333ade
Fix error not being caught correctly
patrykkulik-microsoft Mar 14, 2024
234750e
Minor comment change
patrykkulik-microsoft Mar 15, 2024
26086d7
Merge branch 'pk5/improve_image_sourcing' into jl/build-integration-t…
patrykkulik-microsoft Mar 15, 2024
a78ead2
Fix integration tests
patrykkulik-microsoft Mar 18, 2024
2b59df5
Merge branch 'main' into jl/build-integration-testing
patrykkulik-microsoft Mar 18, 2024
54aff2f
Moving files around
patrykkulik-microsoft Mar 19, 2024
e4da140
Working vnf integration test
patrykkulik-microsoft Mar 19, 2024
4a43fec
Comment out test that is not working
patrykkulik-microsoft Mar 19, 2024
e274f76
Clean up the structure of the integration tests
patrykkulik-microsoft Mar 20, 2024
1629a13
Delete unnecessary tests
patrykkulik-microsoft Mar 21, 2024
eacd51a
Fix CNF test and move a util function
patrykkulik-microsoft Mar 21, 2024
e64fff3
fix other integration tests
patrykkulik-microsoft Mar 22, 2024
feae09f
Delete the broken tests folder
patrykkulik-microsoft Mar 25, 2024
03fb0aa
Fix the vnf test
patrykkulik-microsoft Mar 25, 2024
e94bed3
move files around
patrykkulik-microsoft Mar 25, 2024
a8f588d
Improve the update_input_file function
patrykkulik-microsoft Mar 25, 2024
6c560aa
improve the nsd test
patrykkulik-microsoft Mar 25, 2024
1586d56
Move files around and improve the nsd output
patrykkulik-microsoft Mar 25, 2024
3f86a60
remove unnecessary line
patrykkulik-microsoft Mar 25, 2024
9105eba
Update recording processors and recordings
patrykkulik-microsoft Mar 25, 2024
11def31
Fix linting issues
patrykkulik-microsoft Mar 26, 2024
c863f95
Merge branch 'main' into jl/build-integration-testing
patrykkulik-microsoft Mar 26, 2024
13ba505
bad merge change
patrykkulik-microsoft Mar 26, 2024
1c13830
Update the nsd output with Open CGVs
patrykkulik-microsoft Mar 26, 2024
ddcea29
Fix few unit tests broken by merge
patrykkulik-microsoft Mar 26, 2024
04e398b
Markups
patrykkulik-microsoft Mar 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/aosm/azext_aosm/common/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
clean_registry_name,
push_image_from_local_registry_to_acr,
call_subprocess_raise_output,
check_tool_installed,
)
from azext_aosm.configuration_models.common_parameters_config import (
BaseCommonParametersConfig,
Expand All @@ -31,8 +32,6 @@
from azext_aosm.common.registry import ContainerRegistry, AzureContainerRegistry
from azext_aosm.vendored_sdks.models import ArtifactType
from azext_aosm.vendored_sdks import HybridNetworkManagementClient
from azext_aosm.common.command_context import CommandContext
from azext_aosm.common.utils import check_tool_installed, convert_bicep_to_arm
from knack.util import CLIError
from knack.log import get_logger
from oras.client import OrasClient
Expand Down
11 changes: 4 additions & 7 deletions src/aosm/azext_aosm/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
import json
import re
import os
import tarfile
from typing import Tuple
from pathlib import Path
from jinja2 import StrictUndefined, Template
import json
import shutil
import subprocess
from time import sleep
import tarfile
import tempfile
from typing import Tuple
from time import sleep
from pathlib import Path
from typing import Union
from jinja2 import StrictUndefined, Template

from knack.log import get_logger
from knack.util import CLIError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ def write(self):
self.path.mkdir(exist_ok=True)
artifacts_list = []
for artifact in self.artifacts:
artifact_dict = artifact.to_dict()
logger.debug(
"Writing artifact %s as: %s", artifact.artifact_name, artifact.to_dict()
"Writing artifact %s as: %s", artifact.artifact_name, artifact_dict
)
artifacts_list.append(artifact.to_dict())
artifacts_list.append(artifact_dict)
(self.path / "artifacts.json").write_text(json.dumps(artifacts_list, indent=4))
self._write_supporting_files()
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
patrykkulik-microsoft marked this conversation as resolved.
Show resolved Hide resolved
// Azure location to use when creating resources e.g uksouth
"location": "uksouth",
// Name of the Publisher resource you want your definition published to.
// Will be created if it does not exist.
"publisher_name": "cli-test-vnfpub",
// Resource group for the Publisher resource.
// Will be created if it does not exist.
"publisher_resource_group_name": "cli-test-vnfrg",
// Name of the ACR Artifact Store resource.
// Will be created if it does not exist.
"acr_artifact_store_name": "cli-test-vnfacr",
// Name of the network function.
"nf_name": "cli-test-vnfnf",
// Version of the network function definition in 1.1.1 format (three integers separated by dots).
"version": "1.0.0",
// Optional. Name of the storage account Artifact Store resource.
// Will be created if it does not exist (with a default name if none is supplied).
"blob_artifact_store_name": "cli-test-vnfsa",
// ARM template configuration. The ARM templates given here would deploy a VM if run. They will be used to generate the VNF.
"arm_templates": [
{
// Name of the artifact. Used as internal reference only.
"artifact_name": "cli-test-vnfartifact",
// Version of the artifact in 1.1.1 format (three integers separated by dots).
"version": "1.0.0",
// File path (absolute or relative to this configuration file) of the artifact you wish to upload from your local disk.
// Use Linux slash (/) file separator even if running on Windows.
"file_path": "../ubuntu-template.json"
}
],
// VHD image configuration.
"vhd": {
// Optional. Name of the artifact. Name will be generated if not supplied.
"artifact_name": "cli-test-dummy-vm-vhd",
// Version of the artifact in A-B-C format. Note the '-' (dash) not '.' (dot).
"version": "1-0-0",
// Supply either file_path or blob_sas_url, not both.
// File path (absolute or relative to this configuration file) of the artifact you wish to upload from your local disk.
// Leave as empty string if not required. Use Linux slash (/) file separator even if running on Windows.
"file_path": "../dummy.vhd",
// Supply either file_path or blob_sas_url, not both.
// SAS URL of the blob artifact you wish to copy to your Artifact Store.
// Leave as empty string if not required. Use Linux slash (/) file separator even if running on Windows.
"blob_sas_url": "",
// Optional. Specifies the size of empty data disks in gigabytes.
// This value cannot be larger than 1023 GB. Delete if not required.
"image_disk_size_GB": "",
// Optional. Specifies the HyperVGenerationType of the VirtualMachine created from the image.
// Valid values are V1 and V2. V1 is the default if not specified. Delete if not required.
"image_hyper_v_generation": "",
// Optional. The ARM API version used to create the Microsoft.Compute/images resource.
// Delete if not required.
"image_api_version": ""
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
// Azure location to use when creating resources e.g uksouth
patrykkulik-microsoft marked this conversation as resolved.
Show resolved Hide resolved
"location": "uksouth",
// Name of the Publisher resource you want your definition published to.
// Will be created if it does not exist.
"publisher_name": "cli-test-vnfpub",
// Resource group for the Publisher resource.
// Will be created if it does not exist.
"publisher_resource_group_name": "cli-test-vnfrg",
// Name of the ACR Artifact Store resource.
// Will be created if it does not exist.
"acr_artifact_store_name": "cli-test-vnfacr",
// Name of the network function.
"nf_name": "cli-test-vnfnf",
// Version of the network function definition in 1.1.1 format (three integers separated by dots).
"version": "1.0.0",
// Optional. Name of the storage account Artifact Store resource.
// Will be created if it does not exist (with a default name if none is supplied).
"blob_artifact_store_name": "cli-test-vnfsa",
// The parameter name in the VM ARM template which specifies the name of the image to use for the VM.
"arm_templates": [
{
// Name of the artifact. Used as internal reference only.
"artifact_name": "cli-test-vnfartifact",
// Version of the artifact in 1.1.1 format (three integers separated by dots).
"version": "1.0.0",
// File path (absolute or relative to this configuration file) of the artifact you wish to upload from your local disk.
// Use Linux slash (/) file separator even if running on Windows.
"file_path": "../ubuntu-template.json"
}
],
// VHD image configuration.
"vhd": {
// Optional. Name of the artifact. Name will be generated if not supplied.
"artifact_name": "cli-test-dummy-vm-vhd",
// Version of the artifact in A-B-C format. Note the '-' (dash) not '.' (dot).
"version": "1-0-0",
// Supply either file_path or blob_sas_url, not both.
// File path (absolute or relative to this configuration file) of the artifact you wish to upload from your local disk.
// Leave as empty string if not required. Use Linux slash (/) file separator even if running on Windows.
"file_path": "../dummy.vhd",
// Supply either file_path or blob_sas_url, not both.
// SAS URL of the blob artifact you wish to copy to your Artifact Store.
// Leave as empty string if not required. Use Linux slash (/) file separator even if running on Windows.
"blob_sas_url": "",
// Optional. Specifies the size of empty data disks in gigabytes.
// This value cannot be larger than 1023 GB. Delete if not required.
"image_disk_size_GB": "30",
// Optional. Specifies the HyperVGenerationType of the VirtualMachine created from the image.
// Valid values are V1 and V2. V1 is the default if not specified. Delete if not required.
"image_hyper_v_generation": "V1",
// Optional. The ARM API version used to create the Microsoft.Compute/images resource.
// Delete if not required.
"image_api_version": "2023-03-01"
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.21.1.54444",
"templateHash": "2626436546580286549"
}
},
"parameters": {
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]"
},
"subnetName": {
"type": "string"
},
"ubuntuVmName": {
"type": "string",
"defaultValue": "ubuntu-vm"
},
"virtualNetworkId": {
"type": "string"
},
"sshPublicKeyAdmin": {
"type": "string"
},
"imageName": {
"type": "string"
}
},
"variables": {
"imageResourceGroup": "[resourceGroup().name]",
"subscriptionId": "[subscription().subscriptionId]",
"vmSizeSku": "Standard_D2s_v3"
},
"resources": [
{
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2021-05-01",
"name": "[format('{0}_nic', parameters('ubuntuVmName'))]",
"location": "[parameters('location')]",
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"subnet": {
"id": "[format('{0}/subnets/{1}', parameters('virtualNetworkId'), parameters('subnetName'))]"
},
"primary": true,
"privateIPAddressVersion": "IPv4"
}
}
]
}
},
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2021-07-01",
"name": "[parameters('ubuntuVmName')]",
"location": "[parameters('location')]",
"properties": {
"hardwareProfile": {
"vmSize": "[variables('vmSizeSku')]"
},
"storageProfile": {
"imageReference": {
"id": "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', variables('subscriptionId'), variables('imageResourceGroup')), 'Microsoft.Compute/images', parameters('imageName'))]"
},
"osDisk": {
"osType": "Linux",
"name": "[format('{0}_disk', parameters('ubuntuVmName'))]",
"createOption": "FromImage",
"caching": "ReadWrite",
"writeAcceleratorEnabled": false,
"managedDisk": "[json('{\"storageAccountType\": \"Premium_LRS\"}')]",
"deleteOption": "Delete",
"diskSizeGB": 30
}
},
"osProfile": {
"computerName": "[parameters('ubuntuVmName')]",
"adminUsername": "azureuser",
"linuxConfiguration": {
"disablePasswordAuthentication": true,
"ssh": {
"publicKeys": [
{
"path": "/home/azureuser/.ssh/authorized_keys",
"keyData": "[parameters('sshPublicKeyAdmin')]"
}
]
},
"provisionVMAgent": true,
"patchSettings": {
"patchMode": "ImageDefault",
"assessmentMode": "ImageDefault"
}
},
"secrets": [],
"allowExtensionOperations": true
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', format('{0}_nic', parameters('ubuntuVmName')))]"
}
]
}
},
"dependsOn": [
"[resourceId('Microsoft.Network/networkInterfaces', format('{0}_nic', parameters('ubuntuVmName')))]"
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
// Azure location to use when creating resources.
"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",
// 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}}",
// Optional. Name of the ACR Artifact Store resource.
// Will be created if it does not exist (with a default name if none is supplied).
"acr_artifact_store_name": "nginx-acr",
// Name of NF definition.
"nf_name": "nginx",
// Version of the NF definition in A.B.C format.
"version": "1.0.0",
// List of registries from which to pull the image(s).
// For example [sourceacr.azurecr.io/test, myacr2.azurecr.io].
"image_sources": ["docker.io"],

// List of Helm packages to be included in the CNF.
"helm_packages": [
{
"name": "nginxdemo",
"path_to_chart": "{{path_to_chart}}",
"default_values": "",
"depends_on": []
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"publisher_name": "automated-cli-tests-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_resource_group": "{{publisher_resource_group_name}}",
"name": "nginx-nfdg",
"version": "1.0.0",
"publisher_offering_location": "uksouth",
"type": "cnf",
"multiple_instances": false
}
],
"nsd_name": "nginx-nsdg",
"nsd_version": "1.0.0",
"nsdv_description": "Deploys a basic NGINX CNF"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"location": "uksouth",
patrykkulik-microsoft marked this conversation as resolved.
Show resolved Hide resolved
"publisher_name": "automated-cli-tests-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",
// 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.
"name": "ubuntu-vm",
// The version of the existing Network Function Definition to base this NSD on.
// This NSD will be able to deploy any NFDV with deployment parameters compatible with this version.
"version": "1.0.0",
// The region that the NFDV is published to.
"publisher_offering_location": "uksouth",
// Type of Network Function. Valid values are 'cnf' or 'vnf'.
"type": "vnf",
// Set to true or false. Whether the NSD should allow arbitrary numbers of this type of NF. If false only a single instance will be allowed. Only supported on VNFs, must be set to false on CNFs.
"multiple_instances": "false"
}
},
{
"resource_element_type": "NF",
"properties": {
// The name of the existing publisher for the NSD.
"publisher": "automated-cli-tests-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.
"name": "nginx",
// The version of the existing Network Function Definition to base this NSD on.
// This NSD will be able to deploy any NFDV with deployment parameters compatible with this version.
"version": "1.0.0",
// The region that the NFDV is published to.
"publisher_offering_location": "uksouth",
// Type of Network Function. Valid values are 'cnf' or 'vnf'.
"type": "cnf",
// Set to true or false. Whether the NSD should allow arbitrary numbers of this type of NF. If false only a single instance will be allowed. Only supported on VNFs, must be set to false on CNFs.
"multiple_instances": "false"
}
}
],
"nfvi_type": "AzureCore",
"nsd_name": "multi-nf",
"nsd_version": "1.0.0",
"nsdv_description": "Plain ubuntu VM"
}
Loading