Skip to content

Commit

Permalink
test: add a test that creating VMs until no default name generated an…
Browse files Browse the repository at this point in the history
…d checking
  • Loading branch information
yunmingyang committed Sep 2, 2024
1 parent abd4fa8 commit d4251b2
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/check-machines-create
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import contextlib
import math
import os
import re
import string
import time
import xml.etree.ElementTree as ET
from datetime import datetime
Expand Down Expand Up @@ -253,6 +254,9 @@ class TestMachinesCreate(machineslib.VirtualMachinesCase):
dialog.cancel()

def testCreateNameGeneration(self):
m = self.machine
b = self.browser

config = TestMachinesCreate.TestCreateConfig
runner = TestMachinesCreate.CreateVmRunner(self)

Expand Down Expand Up @@ -304,6 +308,38 @@ class TestMachinesCreate(machineslib.VirtualMachinesCase):
create_and_run=False),
check_env_empty=False)

# Create VMs until no default generated name
for v in string.ascii_uppercase:
vm_name = predicted_name + v
vm_path = "/tmp/" + vm_name

m.execute(f"touch {vm_path}")
m.execute(
"virt-install --connect system"
f" --name {vm_name}"
f" --os-variant {config.FEDORA_28}"
f" --disk {vm_path}"
" --memory 1 --wait -1 --print-xml > /tmp/xml;"
" virsh define /tmp/xml")
b.wait_visible(f"#vm-{vm_name}-system-name")

self.addCleanup(self.machine.execute, f"virsh undefine {vm_name}")

b.click("#create-new-vm")
b.wait_visible("#create-vm-dialog")
b.wait_attr("#vm-name", "placeholder", "Unique name")

b.click("#os-select-group > div button")
b.click(f"#os-select li:contains('{config.FEDORA_28}') button")
b.wait_attr("#os-select-group input", "value", config.FEDORA_28)

b.click("#create-and-edit")

b.wait_visible("#create-vm-dialog")
b.wait_text("#vm-name-helper", "Name must not be empty")
b.wait_visible("#create-and-run:[aria-disabled=true]")
b.wait_visible("#create-and-edit:[aria-disabled=true]")

def testCreateCloudBaseImage(self):
runner = TestMachinesCreate.CreateVmRunner(self)
config = TestMachinesCreate.TestCreateConfig
Expand Down

0 comments on commit d4251b2

Please sign in to comment.