Skip to content

Commit

Permalink
Deprecate old term gallery in favor of new "Marketplace".
Browse files Browse the repository at this point in the history
  • Loading branch information
glima committed Apr 5, 2021
1 parent a69d3b4 commit 3a32bce
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 113 deletions.
8 changes: 6 additions & 2 deletions docs/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ The log shows five test cases are scheduled, two passed, and three skipped. For

### Run in Azure

Below commands shows how to run Microsoft tier 0 (t0) tests on an Azure gallery image.
Below commands show how to run Microsoft tier 0 (t0) tests on an Azure
Marketplace image (as in
https://docs.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage):

1. Sign in to Azure

Expand Down Expand Up @@ -138,7 +140,9 @@ Below commands shows how to run Microsoft tier 0 (t0) tests on an Azure gallery

![image](img/smoke_test_result.png)

It doesn't need to create new VMs every time. The test Linux distribution can be another gallery image or a VHD. Learn more from [runbook reference](runbook.md).
It doesn't need to create new VMs every time. The test Linux
distribution can be another Marketplace image or a VHD. Learn more
from [runbook reference](runbook.md).
### Run in Ready computers
Expand Down
16 changes: 8 additions & 8 deletions lisa/runners/legacy_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ class LogParser(InitializableMixin):
# SetupConfig: { ARMImageName: Canonical UbuntuServer 18.04-LTS latest, OSDiskType:
# Ephemeral, OverrideVMSize: Standard_DS4_v2, TestLocation: westus2 }
CASE_IMAGE_LOCATION = re.compile(
r"SetupConfig: { (?:ARMImageName: (?P<gallery_image>.+?))?(?:, )?"
r"SetupConfig: { (?:ARMImageName: (?P<marketplace_image>.+?))?(?:, )?"
r"(?:DiskType: .*?)?(?:, )?(?:Networking: .*?)?(?:, )?"
r"(?:OsVHD: (?P<vhd_image>.+?))?(?:, )?(?:OSDiskType: .*?)?"
r"(?:, )?(?:, OverrideVMSize: (?P<vmsize>.+?))?(?:, )?"
Expand Down Expand Up @@ -456,7 +456,7 @@ class LogParser(InitializableMixin):
r"'(?P<platform>.*?)','(?P<location>.*?)','.*?','.*?','(?P<name>.*?)',"
r"'(?P<status>.*?)','.*?','(?P<os>.*?)','(?P<kernel_version>.*?)','.*?',"
r"'.*?','(?P<host_version>.*?)','(?P<vmsize>.*?)','.*?',"
r"'(?P<gallery_image>.*?)','(?P<vhd_image>.*?)','(?P<log_path>.*?)',"
r"'(?P<marketplace_image>.*?)','(?P<vhd_image>.*?)','(?P<log_path>.*?)',"
r"'.*?','.*?','.*?','(?P<message>[\w\W]*?)'\)"
)

Expand Down Expand Up @@ -504,9 +504,9 @@ def discover_running_cases(self) -> List[Dict[str, str]]:
if value
}
)
# gallery_image for ARMImage, vhd_image for OsVHD in legacy run
if "gallery_image" in current_case.keys():
current_case["image"] = current_case.pop("gallery_image")
# marketplace_image for ARMImage, vhd_image for OsVHD in legacy run
if "marketplace_image" in current_case.keys():
current_case["image"] = current_case.pop("marketplace_image")
elif "vhd_image" in current_case.keys():
current_case["image"] = current_case.pop("vhd_image")
else:
Expand Down Expand Up @@ -548,9 +548,9 @@ def discover_completed_cases(self) -> List[Dict[str, str]]:
current_case = {
key: value for key, value in case_match.groupdict().items() if value
}
# gallery_image for ARMImage, vhd_image for OsVHD in legacy run
if "gallery_image" in current_case.keys():
current_case["image"] = current_case.pop("gallery_image")
# marketplace_image for ARMImage, vhd_image for OsVHD in legacy run
if "marketplace_image" in current_case.keys():
current_case["image"] = current_case.pop("marketplace_image")
elif "vhd_image" in current_case.keys():
current_case["image"] = current_case.pop("vhd_image")
else:
Expand Down
6 changes: 3 additions & 3 deletions lisa/sut_orchestrator/azure/arm_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
"linuxConfiguration": "[if(empty(parameters('admin_key_data')), json('null'), lisa.getLinuxConfiguration(concat('/home/', parameters('admin_username'), '/.ssh/authorized_keys'), parameters('admin_key_data')))]"
},
"storageProfile": {
"imageReference": "[if(not(empty(parameters('nodes')[copyIndex('vmCopy')]['vhd'])), lisa.getOsDiskVhd(parameters('nodes')[copyIndex('vmCopy')]['name']), lisa.getOsDiskGallery(parameters('nodes')[copyIndex('vmCopy')]))]",
"imageReference": "[if(not(empty(parameters('nodes')[copyIndex('vmCopy')]['vhd'])), lisa.getOsDiskVhd(parameters('nodes')[copyIndex('vmCopy')]['name']), lisa.getOsDiskMarketplace(parameters('nodes')[copyIndex('vmCopy')]))]",
"osDisk": {
"name": "[concat(parameters('nodes')[copyIndex('vmCopy')]['name'], '-osDisk')]",
"managedDisk": {
Expand Down Expand Up @@ -302,7 +302,7 @@
{
"namespace": "lisa",
"members": {
"getOsDiskGallery": {
"getOsDiskMarketplace": {
"parameters": [
{
"name": "node",
Expand All @@ -311,7 +311,7 @@
],
"output": {
"type": "object",
"value": "[parameters('node')['gallery']]"
"value": "[parameters('node')['marketplace']]"
}
},
"getOsDiskVhd": {
Expand Down
82 changes: 42 additions & 40 deletions lisa/sut_orchestrator/azure/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class AzureVmPurchasePlanSchema:

@dataclass_json()
@dataclass
class AzureVmGallerySchema:
class AzureVmMarketplaceSchema:
publisher: str = "Canonical"
offer: str = "UbuntuServer"
sku: str = "18.04-LTS"
Expand All @@ -60,79 +60,81 @@ class AzureNodeSchema:
name: str = ""
vm_size: str = ""
location: str = ""
gallery_raw: Optional[Union[Dict[Any, Any], str]] = field(
default=None, metadata=schema.metadata(data_key="gallery")
marketplace_raw: Optional[Union[Dict[Any, Any], str]] = field(
default=None, metadata=schema.metadata(data_key="marketplace")
)
vhd: str = ""
nic_count: int = 1
# for gallery image, which need to accept terms
# for marketplace image, which need to accept terms
purchase_plan: Optional[AzureVmPurchasePlanSchema] = None

_gallery: InitVar[Optional[AzureVmGallerySchema]] = None
_marketplace: InitVar[Optional[AzureVmMarketplaceSchema]] = None

@property
def gallery(self) -> Optional[AzureVmGallerySchema]:
def marketplace(self) -> Optional[AzureVmMarketplaceSchema]:
# this is a safe guard and prevent mypy error on typing
if not hasattr(self, "_gallery"):
self._gallery: Optional[AzureVmGallerySchema] = None
gallery: Optional[AzureVmGallerySchema] = self._gallery
if not gallery:
if isinstance(self.gallery_raw, dict):
if not hasattr(self, "_marketplace"):
self._marketplace: Optional[AzureVmMarketplaceSchema] = None
marketplace: Optional[AzureVmMarketplaceSchema] = self._marketplace
if not marketplace:
if isinstance(self.marketplace_raw, dict):
# Users decide the cases of image names,
# the inconsistent cases cause the mismatched error in notifiers.
# The lower() normalizes the image names,
# it has no impact on deployment.
self.gallery_raw = dict(
(k, v.lower()) for k, v in self.gallery_raw.items()
self.marketplace_raw = dict(
(k, v.lower()) for k, v in self.marketplace_raw.items()
)
gallery = AzureVmGallerySchema.schema().load( # type: ignore
self.gallery_raw
marketplace = AzureVmMarketplaceSchema.schema().load( # type: ignore
self.marketplace_raw
)
# this step makes gallery_raw is validated, and filter out any unwanted
# content.
self.gallery_raw = gallery.to_dict() # type: ignore
elif self.gallery_raw:
# this step makes marketplace_raw is validated, and
# filter out any unwanted content.
self.marketplace_raw = marketplace.to_dict() # type: ignore
elif self.marketplace_raw:
assert isinstance(
self.gallery_raw, str
), f"actual: {type(self.gallery_raw)}"
self.marketplace_raw, str
), f"actual: {type(self.marketplace_raw)}"
# Users decide the cases of image names,
# the inconsistent cases cause the mismatched error in notifiers.
# The lower() normalizes the image names,
# it has no impact on deployment.
gallery_strings = re.split(r"[:\s]+", self.gallery_raw.strip().lower())
marketplace_strings = re.split(
r"[:\s]+", self.marketplace_raw.strip().lower()
)

if len(gallery_strings) == 4:
gallery = AzureVmGallerySchema(*gallery_strings)
# gallery_raw is used
self.gallery_raw = gallery.to_dict() # type: ignore
if len(marketplace_strings) == 4:
marketplace = AzureVmMarketplaceSchema(*marketplace_strings)
# marketplace_raw is used
self.marketplace_raw = marketplace.to_dict() # type: ignore
else:
raise LisaException(
f"Invalid value for the provided gallery "
f"parameter: '{self.gallery_raw}'."
f"The gallery parameter should be in the format: "
f"Invalid value for the provided marketplace "
f"parameter: '{self.marketplace_raw}'."
f"The marketplace parameter should be in the format: "
f"'<Publisher> <Offer> <Sku> <Version>' "
f"or '<Publisher>:<Offer>:<Sku>:<Version>'"
)
self._gallery = gallery
return gallery
self._marketplace = marketplace
return marketplace

@gallery.setter
def gallery(self, value: Optional[AzureVmGallerySchema]) -> None:
self._gallery = value
@marketplace.setter
def marketplace(self, value: Optional[AzureVmMarketplaceSchema]) -> None:
self._marketplace = value
if value is None:
self.gallery_raw = None
self.marketplace_raw = None
else:
self.gallery_raw = value.to_dict() # type: ignore
self.marketplace_raw = value.to_dict() # type: ignore

def get_image_name(self) -> str:
result = ""
if self.vhd:
result = self.vhd
elif self.gallery:
elif self.marketplace:
assert isinstance(
self.gallery_raw, dict
), f"actual type: {type(self.gallery_raw)}"
result = " ".join([x for x in self.gallery_raw.values()])
self.marketplace_raw, dict
), f"actual type: {type(self.marketplace_raw)}"
result = " ".join([x for x in self.marketplace_raw.values()])
return result


Expand Down
64 changes: 32 additions & 32 deletions lisa/sut_orchestrator/azure/platform_.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
from .common import (
AZURE,
AzureNodeSchema,
AzureVmGallerySchema,
AzureVmMarketplaceSchema,
AzureVmPurchasePlanSchema,
get_compute_client,
get_environment_context,
Expand Down Expand Up @@ -848,21 +848,21 @@ def _create_deployment_parameters(
)
if azure_node_runbook.vhd:
# vhd is higher priority
azure_node_runbook.gallery = None
elif not azure_node_runbook.gallery:
# set to default gallery, if nothing specified
azure_node_runbook.gallery = AzureVmGallerySchema()
azure_node_runbook.marketplace = None
elif not azure_node_runbook.marketplace:
# set to default marketplace, if nothing specified
azure_node_runbook.marketplace = AzureVmMarketplaceSchema()

if azure_node_runbook.gallery:
if azure_node_runbook.marketplace:
# resolve Latest to specified version
azure_node_runbook.gallery = self._parse_gallery_image(
azure_node_runbook.location, azure_node_runbook.gallery
azure_node_runbook.marketplace = self._parse_marketplace_image(
azure_node_runbook.location, azure_node_runbook.marketplace
)
if azure_node_runbook.gallery and not azure_node_runbook.purchase_plan:
azure_node_runbook.purchase_plan = self._process_gallery_image_plan(
azure_node_runbook.location, azure_node_runbook.gallery
if azure_node_runbook.marketplace and not azure_node_runbook.purchase_plan:
azure_node_runbook.purchase_plan = self._process_marketplace_image_plan(
azure_node_runbook.location, azure_node_runbook.marketplace
)
# save parsed runbook back, for example, the version of gallery may be
# save parsed runbook back, for example, the version of marketplace may be
# parsed from latest to a specified version.
node.capability.set_extended_runbook(azure_node_runbook)
nodes_parameters.append(azure_node_runbook)
Expand Down Expand Up @@ -1194,25 +1194,25 @@ def _get_eligible_vm_sizes(
self._eligible_capabilities[location] = location_capabilities
return self._eligible_capabilities[location]

def _parse_gallery_image(
self, location: str, gallery: AzureVmGallerySchema
) -> AzureVmGallerySchema:
def _parse_marketplace_image(
self, location: str, marketplace: AzureVmMarketplaceSchema
) -> AzureVmMarketplaceSchema:
compute_client = get_compute_client(self)
new_gallery = copy.copy(gallery)
if gallery.version.lower() == "latest":
new_marketplace = copy.copy(marketplace)
if marketplace.version.lower() == "latest":
# latest doesn't work, it needs a specified version.
versioned_images = compute_client.virtual_machine_images.list(
location=location,
publisher_name=gallery.publisher,
offer=gallery.offer,
skus=gallery.sku,
publisher_name=marketplace.publisher,
offer=marketplace.offer,
skus=marketplace.sku,
)
# any one should be the same to get purchase plan
new_gallery.version = versioned_images[-1].name
return new_gallery
new_marketplace.version = versioned_images[-1].name
return new_marketplace

def _process_gallery_image_plan(
self, location: str, gallery: AzureVmGallerySchema
def _process_marketplace_image_plan(
self, location: str, marketplace: AzureVmMarketplaceSchema
) -> Optional[PurchasePlan]:
"""
this method to fill plan, if a VM needs it. If don't fill it, the deployment
Expand All @@ -1224,10 +1224,10 @@ def _process_gallery_image_plan(
compute_client = get_compute_client(self)
image_info = compute_client.virtual_machine_images.get(
location=location,
publisher_name=gallery.publisher,
offer=gallery.offer,
skus=gallery.sku,
version=gallery.version,
publisher_name=marketplace.publisher,
offer=marketplace.offer,
skus=marketplace.sku,
version=marketplace.version,
)
plan: Optional[AzureVmPurchasePlanSchema] = None
if image_info.plan:
Expand All @@ -1237,8 +1237,8 @@ def _process_gallery_image_plan(
try:
term = marketplace_client.marketplace_agreements.get(
offer_type="virtualmachine",
publisher_id=gallery.publisher,
offer_id=gallery.offer,
publisher_id=marketplace.publisher,
offer_id=marketplace.offer,
plan_id=image_info.plan.name,
)
except Exception as identifier:
Expand All @@ -1250,8 +1250,8 @@ def _process_gallery_image_plan(
if term.accepted is False:
term.accepted = True
marketplace_client.marketplace_agreements.create(
publisher_id=gallery.publisher,
offer_id=gallery.offer,
publisher_id=marketplace.publisher,
offer_id=marketplace.offer,
plan_id=image_info.plan.name,
parameters=term,
)
Expand Down
2 changes: 1 addition & 1 deletion microsoft/runbook/azure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ environment:
core_count:
min: 2
azure:
gallery: $(gallery_image)
marketplace: $(marketplace_image)
location: $(location)
platform:
- type: azure
Expand Down
4 changes: 2 additions & 2 deletions microsoft/runbook/tiers/t1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ testcase:
- type: legacy
repo: $(v2_repo_url)
branch: $(v2_branch)
command: .\Run-LisaV2.ps1 -TestLocation '$(location)' -RGIdentifier '$(v2_rg)' -TestPlatform 'Azure' -EnableTelemetry -ARMImageName '$(gallery_image)' -XMLSecretFile '$(v2_secret_file)' -TestPriority 0 -ResourceCleanup '$(v2_rg_cleanup)' -CustomLIS '$(custom_lis)' -CustomTestParameters '$(custom_test_parameters)' -OverrideVMSize '$(override_vmsize)' -CustomKernel '$(custom_kernel)' -ExcludeTests '*DPDK*,*XDP*,^LIS-DEPLOY*,^LIS-DRIVER*' -ForceCustom -RunInParallel -TotalCountInParallel 3
command: .\Run-LisaV2.ps1 -TestLocation '$(location)' -RGIdentifier '$(v2_rg)' -TestPlatform 'Azure' -EnableTelemetry -ARMImageName '$(marketplace_image)' -XMLSecretFile '$(v2_secret_file)' -TestPriority 0 -ResourceCleanup '$(v2_rg_cleanup)' -CustomLIS '$(custom_lis)' -CustomTestParameters '$(custom_test_parameters)' -OverrideVMSize '$(override_vmsize)' -CustomKernel '$(custom_kernel)' -ExcludeTests '*DPDK*,*XDP*,^LIS-DEPLOY*,^LIS-DRIVER*' -ForceCustom -RunInParallel -TotalCountInParallel 3
# LisaV2 P0 LIS_DEPLOY, disable by default, can be enabled by set true to enable_lis
- type: legacy
enable: $(enable_lis)
repo: $(v2_repo_url)
branch: $(v2_branch)
command: .\Run-LisaV2.ps1 -TestLocation '$(location)' -RGIdentifier '$(v2_rg)' -TestPlatform 'Azure' -EnableTelemetry -ARMImageName '$(gallery_image)' -XMLSecretFile '$(v2_secret_file)' -TestPriority 0 -TestArea LIS_DEPLOY -ResourceCleanup '$(v2_rg_cleanup)' -CustomLIS '$(custom_lis)' -CustomTestParameters '$(custom_test_parameters)' -OverrideVMSize '$(override_vmsize)' -CustomKernel '$(custom_kernel)' -ForceCustom
command: .\Run-LisaV2.ps1 -TestLocation '$(location)' -RGIdentifier '$(v2_rg)' -TestPlatform 'Azure' -EnableTelemetry -ARMImageName '$(marketplace_image)' -XMLSecretFile '$(v2_secret_file)' -TestPriority 0 -TestArea LIS_DEPLOY -ResourceCleanup '$(v2_rg_cleanup)' -CustomLIS '$(custom_lis)' -CustomTestParameters '$(custom_test_parameters)' -OverrideVMSize '$(override_vmsize)' -CustomKernel '$(custom_kernel)' -ForceCustom
Loading

0 comments on commit 3a32bce

Please sign in to comment.