Skip to content

Commit

Permalink
Document testing file, add case of spurious disk
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Büchse <[email protected]>
  • Loading branch information
mbuechse committed Dec 22, 2023
1 parent 727494f commit 50f417f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
11 changes: 9 additions & 2 deletions Tests/iaas/flavor-naming/check-yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
DISKTYPE_KEY = {'n': 'network', 'h': 'hdd', 's': 'ssd', 'p': 'nvme'}


class Undefined:
def __repr__(self):
return 'undefined'


class Checker:
def __init__(self):
self.errors = 0
Expand All @@ -39,23 +44,25 @@ def check_spec(self, flavor_spec):
if not parsed:
self.emit(f"{name}: name-v2 '{name_v2}' could not be parsed")
cpu, disk, hype, hvirt, cpubrand, gpu, ibd = parsed
undefined = Undefined()
expected = {
'cpus': cpu.cpus,
'cpu-type': CPUTYPE_KEY[cpu.cputype],
'ram': cpu.ram,
'name-v1': fnmck.new_to_old(name_v2),
'disk': undefined,
}
if disk.parsed:
if disk.nrdisks != 1:
self.emit(f"flavor '{name}': name-v2 using multiple disks")
expected['disk'] = disk.disksize
expected['disk0-type'] = DISKTYPE_KEY[disk.disktype or 'n']
for key, exp_val in expected.items():
val = flavor_spec.get(key, DEFAULTS.get(key, None))
val = flavor_spec.get(key, DEFAULTS.get(key, undefined))
if val != exp_val:
self.emit(
f"flavor '{name}': field '{key}' contradicting name-v2 '{name_v2}'; "
f"found '{val}', expected '{exp_val}'"
f"found {val!r}, expected {exp_val!r}"
)


Expand Down
12 changes: 7 additions & 5 deletions Tests/testing/scs-0103-v1-flavors-wrong.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,31 @@ flavor_groups:
list:
- name: SCS-1V-4
cpus: 1
cpu-type: crowded-core
cpu-type: crowded-core # wrong: name suggests shared-core
ram: 4
name-v1: SCS-1V:4
name-v2: SCS-1V-4
- name: SCS-2V-8
cpus: 2
cpu-type: shared-core
ram: 8
name-v1: SCS-2V-8
name-v1: SCS-2V-8 # wrong: not a v1 name
name-v2: SCS-2V-8
- name: SCS-4V-16
cpus: 4
cpu-type: shared-core
ram: 12
ram: 12 # wrong: name suggests 16
name-v1: SCS-4V:16
name-v2: SCS-4V-16
- name: SCS-8V-32
cpus: 8
cpu-type: shared-core
ram: 32
disk: 128 # wrong: no disk in name
name-v1: SCS-8V:32
name-v2: SCS-8V-32
- name: SCS-1V-2
cpus: 2
cpus: 2 # wrong: name suggests 1 cpu
cpu-type: shared-core
ram: 2
name-v1: SCS-1V:2
Expand Down Expand Up @@ -88,13 +89,14 @@ flavor_groups:
cpu-type: shared-core
ram: 4
disk: 20
# wrong: name suggests disk-type ssd
name-v1: SCS-2V:4:20s
name-v2: SCS-2V-4-20s
- name: SCS-4V-16-100s
cpus: 4
cpu-type: shared-core
ram: 16
disk: 10
disk: 10 # wrong: name suggests 100
disk0-type: ssd
name-v1: SCS-4V:16:100s
name-v2: SCS-4V-16-100s
Expand Down

0 comments on commit 50f417f

Please sign in to comment.