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 VM Repair tests failing for no good reason #7890

Merged
merged 16 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions src/vm-repair/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Release History
===============

1.0.9
++++++
Fixed and updated several vm-repair tests for better coverage.
Removed and updated broken image aliases pointing at images that no longer existed.

1.0.8
++++++
SELFHELP telemetry added as initiator. Extra parameters is introduced at the backend to capture the telemetry data.
Expand Down
2 changes: 1 addition & 1 deletion src/vm-repair/azext_vm_repair/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def load_arguments(self, _):
c.argument('unlock_encrypted_vm', help='Option to auto-unlock encrypted VMs using current subscription auth.')
c.argument('enable_nested', help='enable nested hyperv.')
c.argument('associate_public_ip', help='Option to create repair vm with public ip')
c.argument('distro', help='Option to create repair vm from a specific linux distro (rhel7|rhel8|suse12|ubuntu20|centos7|oracle7)')
c.argument('distro', help='Option to create repair vm from a specific linux distro (rhel7|rhel8|sles12|sles15|ubuntu20|centos7|centos8|oracle7)')
c.argument('yes', help='Option to skip prompt for associating public ip and confirm yes to it in no Tty mode')

with self.argument_context('vm repair restore') as c:
Expand Down
9 changes: 2 additions & 7 deletions src/vm-repair/azext_vm_repair/repair_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,6 @@ def _fetch_compatible_windows_os_urn(source_vm):

def _select_distro_linux(distro):
image_lookup = {
'rhel6': 'RedHat:RHEL:6.10:latest',
'rhel7': 'RedHat:rhel-raw:7-raw:latest',
'rhel8': 'RedHat:rhel-raw:8-raw:latest',
'ubuntu18': 'Canonical:UbuntuServer:18.04-LTS:latest',
Expand All @@ -503,9 +502,8 @@ def _select_distro_linux(distro):
'centos8': 'OpenLogic:CentOS:8_4:latest',
'oracle6': 'Oracle:Oracle-Linux:6.10:latest',
'oracle7': 'Oracle:Oracle-Linux:ol79:latest',
'oracle8': 'Oracle:Oracle-Linux:ol82:latest',
'sles12': 'SUSE:sles-12-sp5:gen1:latest',
'sles15': 'SUSE:sles-15-sp3:gen1:latest',
'sles15': 'SUSE:sles-15-sp6:gen1:latest',
}
if distro in image_lookup:
os_image_urn = image_lookup[distro]
Expand All @@ -521,7 +519,7 @@ def _select_distro_linux(distro):

def _select_distro_linux_Arm64(distro):
image_lookup = {
'rhel8': 'RedHat:rhel-arm64:8_8-arm64:latest',
'rhel8': 'RedHat:rhel-arm64:8_8-arm64-gen2:latest',
'rhel9': 'RedHat:rhel-arm64:9_2-arm64:latest',
'ubuntu18': 'Canonical:UbuntuServer:18_04-lts-arm64:latest',
'ubuntu20': 'Canonical:0001-com-ubuntu-server-focal:20_04-lts-arm64:latest',
Expand All @@ -542,15 +540,12 @@ def _select_distro_linux_Arm64(distro):
def _select_distro_linux_gen2(distro):
# base on the document : https://docs.microsoft.com/en-us/azure/virtual-machines/generation-2#generation-2-vm-images-in-azure-marketplace
image_lookup = {
'rhel6': 'RedHat:rhel-raw:7-raw-gen2:latest',
'rhel7': 'RedHat:rhel-raw:7-raw-gen2:latest',
'rhel8': 'RedHat:rhel-raw:8-raw-gen2:latest',
'ubuntu18': 'Canonical:UbuntuServer:18_04-lts-gen2:latest',
'ubuntu20': 'Canonical:0001-com-ubuntu-server-focal:20_04-lts-gen2:latest',
'centos6': 'OpenLogic:CentOS:7_9-gen2:latest',
'centos7': 'OpenLogic:CentOS:7_9-gen2:latest',
'centos8': 'OpenLogic:CentOS:8_4-gen2:latest',
'oracle6': 'Oracle:Oracle-Linux:ol79-gen2:latest',
'oracle7': 'Oracle:Oracle-Linux:ol79-gen2:latest',
'oracle8': 'Oracle:Oracle-Linux:ol82-gen2:latest',
'sles12': 'SUSE:sles-12-sp5:gen2:latest',
Expand Down
46 changes: 24 additions & 22 deletions src/vm-repair/azext_vm_repair/tests/latest/test_repair_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

import pytest
from azure.cli.testsdk import LiveScenarioTest, ResourceGroupPreparer
import json
import re

STATUS_SUCCESS = 'SUCCESS'


@pytest.mark.WindowsManaged
class WindowsManagedDiskCreateRestoreTest(LiveScenarioTest):

@ResourceGroupPreparer(location='westus2')
Expand Down Expand Up @@ -44,7 +46,7 @@ def test_vmrepair_WinManagedCreateRestore(self, resource_group):
source_vm = vms[0]
assert source_vm['storageProfile']['osDisk']['name'] == result['copied_disk_name']


@pytest.mark.WindowsUnmanaged
class WindowsUnmanagedDiskCreateRestoreTest(LiveScenarioTest):

@ResourceGroupPreparer(location='westus2')
Expand Down Expand Up @@ -79,10 +81,10 @@ def test_vmrepair_WinUnmanagedCreateRestore(self, resource_group):
assert source_vm['storageProfile']['osDisk']['vhd']['uri'] == result['copied_disk_uri']


@pytest.mark.linux
@pytest.mark.linuxManaged
class LinuxManagedDiskCreateRestoreTest(LiveScenarioTest):

@ResourceGroupPreparer(location='eastus')
@ResourceGroupPreparer(location='westus2')
def test_vmrepair_LinuxManagedCreateRestore(self, resource_group):
self.kwargs.update({
'vm': 'vm1'
Expand Down Expand Up @@ -114,10 +116,10 @@ def test_vmrepair_LinuxManagedCreateRestore(self, resource_group):
assert source_vm['storageProfile']['osDisk']['name'] == result['copied_disk_name']


@pytest.mark.linux
@pytest.mark.linuxUnmanaged
class LinuxUnmanagedDiskCreateRestoreTest(LiveScenarioTest):

@ResourceGroupPreparer(location='eastus')
@ResourceGroupPreparer(location='westus2')
def test_vmrepair_LinuxUnmanagedCreateRestore(self, resource_group):
self.kwargs.update({
'vm': 'vm1'
Expand Down Expand Up @@ -148,7 +150,7 @@ def test_vmrepair_LinuxUnmanagedCreateRestore(self, resource_group):
source_vm = vms[0]
assert source_vm['storageProfile']['osDisk']['vhd']['uri'] == result['copied_disk_uri']


@pytest.mark.WinManagedDiskPubIpRestore
class WindowsManagedDiskCreateRestoreTestwithpublicip(LiveScenarioTest):

@ResourceGroupPreparer(location='westus2')
Expand Down Expand Up @@ -182,7 +184,7 @@ def test_vmrepair_WinManagedCreateRestorePublicIp(self, resource_group):
source_vm = vms[0]
assert source_vm['storageProfile']['osDisk']['name'] == result['copied_disk_name']


@pytest.mark.WinUnmanagedDiskPubIpRestore
class WindowsUnmanagedDiskCreateRestoreTestwithpublicip(LiveScenarioTest):

@ResourceGroupPreparer(location='westus2')
Expand Down Expand Up @@ -216,7 +218,7 @@ def test_vmrepair_WinUnmanagedCreateRestorePublicIp(self, resource_group):
source_vm = vms[0]
assert source_vm['storageProfile']['osDisk']['vhd']['uri'] == result['copied_disk_uri']


@pytest.mark.LinuxManagedDiskPubIpRestore
class LinuxManagedDiskCreateRestoreTestwithpublicip(LiveScenarioTest):

@ResourceGroupPreparer(location='eastus')
Expand Down Expand Up @@ -250,7 +252,7 @@ def test_vmrepair_LinuxManagedCreateRestorePublicIp(self, resource_group):
source_vm = vms[0]
assert source_vm['storageProfile']['osDisk']['name'] == result['copied_disk_name']


@pytest.mark.LinuxUnmanagedDiskPubIpRestore
class LinuxUnmanagedDiskCreateRestoreTestwithpublicip(LiveScenarioTest):

@ResourceGroupPreparer(location='westus2')
Expand Down Expand Up @@ -394,7 +396,7 @@ def test_vmrepair_LinuxSinglepassKekEncryptedManagedDiskCreateRestore(self, reso
source_vm = vms[0]
assert source_vm['storageProfile']['osDisk']['name'] == result['copied_disk_name']


@pytest.mark.WindowsNoKekRestore
class WindowsSinglepassNoKekEncryptedManagedDiskCreateRestoreTest(LiveScenarioTest):

@ResourceGroupPreparer(location='westus2')
Expand Down Expand Up @@ -439,7 +441,7 @@ def test_vmrepair_WinSinglepassNoKekEncryptedManagedDiskCreateRestore(self, reso
source_vm = vms[0]
assert source_vm['storageProfile']['osDisk']['name'] == result['copied_disk_name']


@pytest.mark.LinuxNoKekRestore
class LinuxSinglepassNoKekEncryptedManagedDiskCreateRestoreTest(LiveScenarioTest):

@ResourceGroupPreparer(location='westus2')
Expand Down Expand Up @@ -486,7 +488,7 @@ def test_vmrepair_LinuxSinglepassNoKekEncryptedManagedDiskCreateRestoreTest(self
source_vm = vms[0]
assert source_vm['storageProfile']['osDisk']['name'] == result['copied_disk_name']


@pytest.mark.WindHelloWorld
class WindowsRunHelloWorldTest(LiveScenarioTest):

@ResourceGroupPreparer(location='westus2')
Expand All @@ -507,7 +509,7 @@ def test_vmrepair_WinRunHelloWorld(self, resource_group):
# Check Output
assert 'Hello World!' in result['output']


@pytest.mark.LinHelloWorld
class LinuxRunHelloWorldTest(LiveScenarioTest):

@ResourceGroupPreparer(location='westus2')
Expand All @@ -528,7 +530,7 @@ def test_vmrepair_LinuxRunHelloWorld(self, resource_group):
# Check Output
assert 'Hello World!' in result['output']


@pytest.mark.ManagedDiskGen2
class WindowsManagedDiskCreateRestoreGen2Test(LiveScenarioTest):

@ResourceGroupPreparer(location='westus2')
Expand Down Expand Up @@ -562,7 +564,7 @@ def test_vmrepair_WinManagedCreateRestoreGen2(self, resource_group):
source_vm = vms[0]
assert source_vm['storageProfile']['osDisk']['name'] == result['copied_disk_name']


@pytest.mark.linuxKekRHEL
class LinuxSinglepassKekEncryptedManagedDiskWithRHEL8DistroCreateRestoreTest(LiveScenarioTest):

@ResourceGroupPreparer(location='westus2')
Expand Down Expand Up @@ -617,7 +619,7 @@ def test_vmrepair_LinuxSinglepassKekEncryptedManagedDiskCreateRestoreRHEL8(self,
source_vm = vms[0]
assert source_vm['storageProfile']['osDisk']['name'] == result['copied_disk_name']


@pytest.mark.linuxNoKekWithSles
class LinuxSinglepassNoKekEncryptedManagedDiskWithSLES15CreateRestoreTest(LiveScenarioTest):

@ResourceGroupPreparer(location='westus2')
Expand Down Expand Up @@ -645,7 +647,7 @@ def test_vmrepair_LinuxSinglepassNoKekEncryptedManagedDiskCreateRestoreTestSLES1
# Add buffer time for encryption settings to be set
time.sleep(300)

# Test create
# Test create SUSE
result = self.cmd('vm repair create -g {rg} -n {vm} --repair-username azureadmin --repair-password !Passw0rd2018 --distro sles15 --unlock-encrypted-vm --yes -o json').get_output_in_json()
assert result['status'] == STATUS_SUCCESS, result['error_message']

Expand All @@ -664,7 +666,7 @@ def test_vmrepair_LinuxSinglepassNoKekEncryptedManagedDiskCreateRestoreTestSLES1
source_vm = vms[0]
assert source_vm['storageProfile']['osDisk']['name'] == result['copied_disk_name']


@pytest.mark.LinuxManagedPubIpOracle
class LinuxManagedDiskCreateRestoreTestwithOracle8andpublicip(LiveScenarioTest):

@ResourceGroupPreparer(location='westus2')
Expand Down Expand Up @@ -698,7 +700,7 @@ def test_vmrepair_LinuxManagedCreateRestoreOracle8PublicIp(self, resource_group)
source_vm = vms[0]
assert source_vm['storageProfile']['osDisk']['name'] == result['copied_disk_name']


@pytest.mark.WindowsResetNic
class ResetNICWindowsVM(LiveScenarioTest):

@ResourceGroupPreparer(location='westus2')
Expand Down Expand Up @@ -752,7 +754,7 @@ def test_vmrepair_RepairAndRestoreLinuxVM(self, resource_group):
class LinuxARMManagedDiskCreateRestoreTest(LiveScenarioTest):

@ResourceGroupPreparer(location='eastus')
def test_vmrepair_LinuxManagedCreateRestore(self, resource_group):
def test_vmrepair_LinuxARMManagedCreateRestore(self, resource_group):
self.kwargs.update({
'vm': 'vm1'
})
Expand Down Expand Up @@ -786,7 +788,7 @@ def test_vmrepair_LinuxManagedCreateRestore(self, resource_group):
class ResetNICWithASG(LiveScenarioTest):

@ResourceGroupPreparer(location='westus2')
def test_vmrepair_ResetNicWindowsVM(self, resource_group):
def test_vmrepair_ResetNicWithASGWindowsVM(self, resource_group):
self.kwargs.update({
'vm': 'vm1'
})
Expand Down
2 changes: 1 addition & 1 deletion src/vm-repair/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from codecs import open
from setuptools import setup, find_packages

VERSION = "1.0.8"
VERSION = "1.0.9"

CLASSIFIERS = [
'Development Status :: 4 - Beta',
Expand Down
Loading