this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

test(e2e): verify cold boot after install

Khue Doan 7cf7ebd2 8b192f62

+88 -40
+88 -40
tests/e2e/run.py
··· 130 130 raise TimeoutError(f"timed out waiting for SSH on {ip}") 131 131 132 132 133 + def machine_artifact_paths(workdir, machine): 134 + return { 135 + "disk": workdir / f"{machine['name']}.qcow2", 136 + "serial_log": workdir / f"{machine['name']}.serial.log", 137 + "qemu_log": workdir / f"{machine['name']}.qemu.log", 138 + "vars": workdir / f"{machine['name']}-OVMF_VARS.fd", 139 + } 140 + 141 + 142 + def build_qemu_cmd(machine, tap, paths, prefer_disk_boot): 143 + disk_bootindex = "1" if prefer_disk_boot else "2" 144 + net_bootindex = "2" if prefer_disk_boot else "1" 145 + 146 + return [ 147 + "qemu-system-x86_64", 148 + "-name", 149 + machine["name"], 150 + "-machine", 151 + "q35", 152 + "-m", 153 + "2048", 154 + "-smp", 155 + "2", 156 + "-display", 157 + "none", 158 + "-serial", 159 + f"file:{paths['serial_log']}", 160 + "-monitor", 161 + "none", 162 + "-drive", 163 + f"if=pflash,format=raw,readonly=on,file={os.environ['OVMF_CODE']}", 164 + "-drive", 165 + f"if=pflash,format=raw,file={paths['vars']}", 166 + "-drive", 167 + f"if=none,id=disk0,file={paths['disk']},format=qcow2", 168 + "-device", 169 + f"virtio-blk-pci,drive=disk0,bootindex={disk_bootindex}", 170 + "-netdev", 171 + f"tap,id=net0,ifname={tap},script=no,downscript=no", 172 + "-device", 173 + f"e1000,netdev=net0,mac={machine['mac']},bootindex={net_bootindex}", 174 + "-enable-kvm", 175 + "-cpu", 176 + "host", 177 + ] 178 + 179 + 180 + def start_machine(machine, tap, workdir, initialize_disk, prefer_disk_boot): 181 + paths = machine_artifact_paths(workdir, machine) 182 + if initialize_disk: 183 + shutil.copyfile(os.environ["OVMF_VARS"], paths["vars"]) 184 + run(["qemu-img", "create", "-f", "qcow2", str(paths["disk"]), "20G"]) 185 + 186 + cmd = build_qemu_cmd(machine, tap, paths, prefer_disk_boot) 187 + proc, handle = start_process(machine["name"], cmd, paths["qemu_log"]) 188 + return proc, handle 189 + 190 + 133 191 def make_dnsmasq_config(path, bridge): 134 192 lines = [ 135 193 "port=0", ··· 281 339 bridge = f"brnxe{suffix}" 282 340 taps = [f"tapn1{suffix}", f"tapn2{suffix}"] 283 341 processes = [] 342 + qemu_processes = [] 284 343 285 344 key_path, pubkey = generate_ssh_keypair(workdir) 286 345 runtime_flake = write_runtime_flake(pubkey) ··· 341 400 time.sleep(2) 342 401 343 402 for machine, tap in zip(MACHINES, taps, strict=True): 344 - disk = workdir / f"{machine['name']}.qcow2" 345 - vars_path = workdir / f"{machine['name']}-OVMF_VARS.fd" 346 - serial_log = workdir / f"{machine['name']}.serial.log" 347 - 348 - shutil.copyfile(os.environ["OVMF_VARS"], vars_path) 349 - run(["qemu-img", "create", "-f", "qcow2", str(disk), "20G"]) 350 - 351 - cmd = [ 352 - "qemu-system-x86_64", 353 - "-name", 354 - machine["name"], 355 - "-machine", 356 - "q35", 357 - "-m", 358 - "2048", 359 - "-smp", 360 - "2", 361 - "-display", 362 - "none", 363 - "-serial", 364 - f"file:{serial_log}", 365 - "-monitor", 366 - "none", 367 - "-drive", 368 - f"if=pflash,format=raw,readonly=on,file={os.environ['OVMF_CODE']}", 369 - "-drive", 370 - f"if=pflash,format=raw,file={vars_path}", 371 - "-drive", 372 - f"if=none,id=disk0,file={disk},format=qcow2", 373 - "-device", 374 - "virtio-blk-pci,drive=disk0,bootindex=2", 375 - "-netdev", 376 - f"tap,id=net0,ifname={tap},script=no,downscript=no", 377 - "-device", 378 - f"e1000,netdev=net0,mac={machine['mac']},bootindex=1", 379 - ] 380 - cmd.extend(["-enable-kvm", "-cpu", "host"]) 381 - 382 - qemu_log = workdir / f"{machine['name']}.qemu.log" 383 - qemu_proc, qemu_handle = start_process(machine["name"], cmd, qemu_log) 403 + qemu_proc, qemu_handle = start_machine( 404 + machine, 405 + tap, 406 + workdir, 407 + initialize_disk=True, 408 + prefer_disk_boot=False, 409 + ) 410 + qemu_processes.append((machine, tap, qemu_proc, qemu_handle)) 384 411 processes.append((qemu_proc, qemu_handle)) 385 412 386 413 wait_for_nixie(nixie_proc, nixie_log, timeout=7200) ··· 388 415 for machine in MACHINES: 389 416 wait_for_ssh(key_path, machine["ip"], machine["name"], timeout=1800) 390 417 log(f"verified {machine['name']} at {machine['ip']}") 418 + 419 + log("power cycling machines to verify disk boot without the installer") 420 + for _, _, qemu_proc, qemu_handle in reversed(qemu_processes): 421 + kill_process(qemu_proc) 422 + qemu_handle.close() 423 + qemu_processes = [] 424 + 425 + for machine, tap in zip(MACHINES, taps, strict=True): 426 + qemu_proc, qemu_handle = start_machine( 427 + machine, 428 + tap, 429 + workdir, 430 + initialize_disk=False, 431 + prefer_disk_boot=True, 432 + ) 433 + qemu_processes.append((machine, tap, qemu_proc, qemu_handle)) 434 + processes.append((qemu_proc, qemu_handle)) 435 + 436 + for machine in MACHINES: 437 + wait_for_ssh(key_path, machine["ip"], machine["name"], timeout=900) 438 + log(f"verified cold boot for {machine['name']} at {machine['ip']}") 391 439 392 440 log("end-to-end test passed") 393 441 return 0