| 1 |
#!/usr/bin/python3 -cimport os, sys; os.execv(os.path.dirname(sys.argv[1]) + "/../common/pywrap", sys.argv) |
| 2 |
|
| 3 |
# |
| 4 |
# Copyright (C) 2021 Red Hat, Inc. |
| 5 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 6 |
|
| 7 |
|
| 8 |
import subprocess |
| 9 |
|
| 10 |
import packagelib |
| 11 |
import storagelib |
| 12 |
import testlib |
| 13 |
|
| 14 |
PV_SIZE = 4000 # 4 GB in MB |
| 15 |
|
| 16 |
# List of images that support Stratis and create V1 pools by |
| 17 |
# default. When this gets empty, Cockpit itself can be cleaned up to |
| 18 |
# drop support for Stratis API revisions before "r8". |
| 19 |
# |
| 20 |
V1_POOL_IMAGES = ["rhel-9-9", "rhel-9-8", "rhel-9-7", "centos-9-bootc", "centos-9"] |
| 21 |
|
| 22 |
|
| 23 |
def get_stratis_stop_type_opt(execute): |
| 24 |
"""Get `stratis stop pool` required option for a pool name |
| 25 |
|
| 26 |
The CLI changed in an incompatible way in Fedora 40, it needs an extra --name option |
| 27 |
which cannot be provided in earlier versions. |
| 28 |
""" |
| 29 |
try: |
| 30 |
if '--name' in execute("stratis pool stop --help"): |
| 31 |
return "--name" |
| 32 |
except subprocess.CalledProcessError: |
| 33 |
# on RHEL 8 this fails with "error: invalid choice" |
| 34 |
pass |
| 35 |
return "" |
| 36 |
|
| 37 |
|
| 38 |
def create_pool_key(machine, keyname, passphrase): |
| 39 |
# this is a bit complicated, see https://bugzilla.redhat.com/show_bug.cgi?id=2246923 |
| 40 |
machine.execute(f"echo -n '{passphrase}' | stratis key set --keyfile-path /dev/stdin {keyname}") |
| 41 |
|
| 42 |
|
| 43 |
def create_legacy_pool(machine, disks, name="pool0", keydesc=None, tang=None): |
| 44 |
keydesc_opt = "--key-desc " + keydesc if keydesc else "" |
| 45 |
clevis_opt = "--clevis tang --trust-url --tang-url " + tang if tang else "" |
| 46 |
machine.execute(f"yes | stratisd-tools stratis-legacy-pool {keydesc_opt} {clevis_opt} {name} {' '.join(disks)}") |
| 47 |
testlib.wait(lambda: name in machine.execute("stratis pool list")) |
| 48 |
|
| 49 |
|
| 50 |
@testlib.skipImage("No Stratis", "debian-*", "ubuntu-*", "arch") |
| 51 |
@testlib.skipImage("stratis not installed", "*-bootc") |
| 52 |
@testlib.skipImage("commit 817c957899a4 removed Statis 2 support", "rhel-8-*") |
| 53 |
@testlib.nondestructive |
| 54 |
class TestStorageStratis(storagelib.StorageCase): |
| 55 |
def setUp(self): |
| 56 |
super().setUp() |
| 57 |
exe = self.machine.execute |
| 58 |
|
| 59 |
exe("systemctl start stratisd") |
| 60 |
self.addCleanup(exe, "systemctl stop stratisd") |
| 61 |
|
| 62 |
self.stop_type_opt = get_stratis_stop_type_opt(exe) |
| 63 |
|
| 64 |
def tearDown(self): |
| 65 |
# we need to clean up stratis *first*, before add_loopback_disk()'s addCleanup() handlers |
| 66 |
# tearDown() runs before addCleanup() |
| 67 |
exe = self.machine.execute |
| 68 |
exe("mount | grep mapper/stratis | awk '{print $1}' | xargs --no-run-if-empty umount") |
| 69 |
exe(f"stratis report | jq -r '.pools[] | .name' | xargs -n1 --no-run-if-empty stratis pool stop {self.stop_type_opt}") |
| 70 |
exe("stratis report | jq -r '.pools[] | .name' | xargs -n1 --no-run-if-empty stratis pool destroy") |
| 71 |
exe("dmsetup ls | cut -f1 | grep ^stratis | xargs -n1 --no-run-if-empty dmsetup remove --force") |
| 72 |
|
| 73 |
super().tearDown() |
| 74 |
|
| 75 |
def testBasic(self, legacy=False): |
| 76 |
m = self.machine |
| 77 |
b = self.browser |
| 78 |
|
| 79 |
self.login_and_go("/storage") |
| 80 |
|
| 81 |
# use fixed names, to avoid grabbing loop1 and loop12 (which losetup sometimes likes to do) |
| 82 |
# as that clashes with :contains(loop1) below; also, fix names for pixel test |
| 83 |
dev_1 = self.add_loopback_disk(PV_SIZE, name="loop10") |
| 84 |
dev_2 = self.add_loopback_disk(PV_SIZE, name="loop11") |
| 85 |
dev_3 = self.add_loopback_disk(PV_SIZE, name="loop12") |
| 86 |
dev_4 = self.add_loopback_disk(PV_SIZE, name="loop13") |
| 87 |
dev_5 = self.add_loopback_disk(PV_SIZE, name="loop14") |
| 88 |
b.wait_visible(self.card_row("Storage", name=dev_1)) |
| 89 |
b.wait_visible(self.card_row("Storage", name=dev_2)) |
| 90 |
b.wait_visible(self.card_row("Storage", name=dev_3)) |
| 91 |
b.wait_visible(self.card_row("Storage", name=dev_4)) |
| 92 |
b.wait_visible(self.card_row("Storage", name=dev_5)) |
| 93 |
|
| 94 |
# Create a pool |
| 95 |
if not legacy: |
| 96 |
self.dialog_open_with_retry(trigger=lambda: self.click_devices_dropdown("Create Stratis pool"), |
| 97 |
expect=lambda: (self.dialog_is_present('disks', dev_1) and |
| 98 |
self.dialog_is_present('disks', dev_2) and |
| 99 |
self.dialog_check({"name": "pool0"}))) |
| 100 |
self.dialog_set_val("disks", {dev_1: True, dev_2: True}) |
| 101 |
b.assert_pixels("#dialog", "create-pool") |
| 102 |
self.dialog_apply() |
| 103 |
self.dialog_wait_close() |
| 104 |
else: |
| 105 |
create_legacy_pool(m, disks=[dev_1, dev_2]) |
| 106 |
|
| 107 |
b.wait_visible(self.card_row("Storage", name="pool0")) |
| 108 |
b.wait_not_present(self.card_row("Storage", name="pool0") + " .ct-icon-exclamation-triangle") |
| 109 |
|
| 110 |
# Check that the next name is "pool1" |
| 111 |
self.click_devices_dropdown("Create Stratis pool") |
| 112 |
self.dialog_wait_open() |
| 113 |
self.dialog_wait_val("name", "pool1") |
| 114 |
self.dialog_cancel() |
| 115 |
self.dialog_wait_close() |
| 116 |
|
| 117 |
# Stop the pool |
| 118 |
m.execute(f"stratis pool stop {self.stop_type_opt} pool0") |
| 119 |
b.wait_in_text(self.card_row("Storage", name="pool0"), "Stratis pool (stopped)") |
| 120 |
|
| 121 |
# Start it |
| 122 |
self.click_dropdown(self.card_row("Storage", name="pool0"), "Start") |
| 123 |
b.wait_in_text(self.card_row("Storage", name="pool0"), "Stratis filesystems") |
| 124 |
|
| 125 |
self.click_card_row("Storage", name="pool0") |
| 126 |
b.wait_text(self.card_desc("Stratis pool", "Name"), "pool0") |
| 127 |
b.wait_in_text(self.card_desc("Stratis pool", "Usage"), "8 GB") |
| 128 |
b.wait_not_present('.pf-v6-c-alert') |
| 129 |
|
| 130 |
udisk_contains_stratis_private = "physical-originsub" in m.execute("udisksctl dump") |
| 131 |
|
| 132 |
# Create two filesystems |
| 133 |
b.click(self.card_button("Stratis filesystems", "Create new filesystem")) |
| 134 |
self.dialog_wait_open() |
| 135 |
self.dialog_set_val('name', 'fsys1') |
| 136 |
self.dialog_set_val('mount_point', '/run/fsys1') |
| 137 |
if not legacy: |
| 138 |
b.assert_pixels("#dialog", "create-fsys") |
| 139 |
self.dialog_apply() |
| 140 |
self.dialog_wait_close() |
| 141 |
self.addCleanupMount("/run/fsys1") |
| 142 |
|
| 143 |
b.wait_text(self.card_row_col("Stratis filesystems", 1, 1), "fsys1") |
| 144 |
b.wait_text(self.card_row_col("Stratis filesystems", 1, 3), "/run/fsys1") |
| 145 |
|
| 146 |
self.assertEqual(self.inode(m.execute("findmnt -n -o SOURCE /run/fsys1").strip()), |
| 147 |
self.inode("/dev/stratis/pool0/fsys1")) |
| 148 |
|
| 149 |
b.click(self.card_button("Stratis filesystems", "Create new filesystem")) |
| 150 |
self.dialog({'name': 'fsys2', |
| 151 |
'mount_point': '/run/fsys2'}) |
| 152 |
self.addCleanupMount("/run/fsys2") |
| 153 |
b.wait_text(self.card_row_col("Stratis filesystems", 2, 1), "fsys2") |
| 154 |
b.wait_text(self.card_row_col("Stratis filesystems", 2, 3), "/run/fsys2") |
| 155 |
if not legacy: |
| 156 |
b.assert_pixels(self.card("Stratis filesystems"), "fsys-rows") |
| 157 |
self.assertEqual(self.inode(m.execute("findmnt -n -o SOURCE /run/fsys2").strip()), |
| 158 |
self.inode("/dev/stratis/pool0/fsys2")) |
| 159 |
m.write("/run/fsys2/FILE", "Hello Stratis!") |
| 160 |
|
| 161 |
# Check that they have entries in fstab |
| 162 |
self.assertNotEqual(m.execute("grep /run/fsys1 /etc/fstab"), "") |
| 163 |
self.assertNotEqual(m.execute("grep /run/fsys2 /etc/fstab"), "") |
| 164 |
|
| 165 |
# Rename one filesystem |
| 166 |
self.click_card_row("Stratis filesystems", 1) |
| 167 |
b.click(self.card_desc_action("Stratis filesystem", "Name")) |
| 168 |
self.dialog({'name': "fsys1-renamed"}) |
| 169 |
b.wait_text(self.card_desc("Stratis filesystem", "Name"), "fsys1-renamed") |
| 170 |
b.click(self.card_parent_link()) |
| 171 |
b.wait_text(self.card_row_col("Stratis filesystems", 1, 1), "fsys1-renamed") |
| 172 |
|
| 173 |
# Destroy one filesystem |
| 174 |
self.click_card_row("Stratis filesystems", 1) |
| 175 |
self.click_card_dropdown("Stratis filesystem", "Delete") |
| 176 |
self.dialog_wait_open() |
| 177 |
if not legacy: |
| 178 |
b.assert_pixels("#dialog", "delete-fsys") |
| 179 |
self.dialog_apply() |
| 180 |
self.dialog_wait_close() |
| 181 |
b.wait_visible(self.card("Stratis filesystems")) |
| 182 |
b.wait_not_present(self.card_row("Stratis filesystems", name="fsys1-renamed")) |
| 183 |
|
| 184 |
# Unmount and remount the other filesystem |
| 185 |
self.click_dropdown(self.card_row("Stratis filesystems", 1), "Unmount") |
| 186 |
self.confirm() |
| 187 |
b.wait_text(self.card_row_col("Stratis filesystems", 1, 3), "/run/fsys2 (not mounted)") |
| 188 |
self.click_dropdown(self.card_row("Stratis filesystems", 1), "Mount") |
| 189 |
self.dialog({}) |
| 190 |
b.wait_text(self.card_row_col("Stratis filesystems", 1, 3), "/run/fsys2") |
| 191 |
|
| 192 |
# Make a copy of the filesystem |
| 193 |
self.click_dropdown(self.card_row("Stratis filesystems", 1), "Snapshot") |
| 194 |
self.dialog_wait_open() |
| 195 |
self.dialog_set_val('name', 'fsys2-copy') |
| 196 |
self.dialog_set_val('mount_point', '/run/fsys2-copy') |
| 197 |
self.dialog_set_val('at_boot', 'never') |
| 198 |
if not legacy: |
| 199 |
b.assert_pixels("#dialog", "copy-fsys") |
| 200 |
self.dialog_apply() |
| 201 |
self.dialog_wait_close() |
| 202 |
b.wait_text(self.card_row_col("Stratis filesystems", 2, 1), "fsys2-copy") |
| 203 |
b.wait_text(self.card_row_col("Stratis filesystems", 2, 3), "/run/fsys2-copy") |
| 204 |
|
| 205 |
self.assertEqual("Hello Stratis!", m.execute("cat /run/fsys2-copy/FILE")) |
| 206 |
|
| 207 |
# Delete the copy |
| 208 |
self.click_card_row("Stratis filesystems", 2) |
| 209 |
self.click_card_dropdown("Stratis filesystem", "Delete") |
| 210 |
self.confirm() |
| 211 |
b.wait_visible(self.card("Stratis filesystems")) |
| 212 |
b.wait_not_present(self.card_row("Stratis filesystems", name="fsys2-copy")) |
| 213 |
|
| 214 |
# Make an unmounted copy of the filesystem |
| 215 |
self.click_dropdown(self.card_row("Stratis filesystems", 1), "Snapshot") |
| 216 |
self.dialog_wait_open() |
| 217 |
self.dialog_set_val('name', 'fsys2-copy') |
| 218 |
self.dialog_set_val('at_boot', 'never') |
| 219 |
self.dialog_apply_secondary() |
| 220 |
self.dialog_wait_close() |
| 221 |
b.wait_text(self.card_row_col("Stratis filesystems", 2, 1), "fsys2-copy") |
| 222 |
b.wait_text(self.card_row_col("Stratis filesystems", 2, 3), "(not mounted)") |
| 223 |
|
| 224 |
# Delete the copy |
| 225 |
self.click_card_row("Stratis filesystems", 2) |
| 226 |
self.click_card_dropdown("Stratis filesystem", "Delete") |
| 227 |
self.confirm() |
| 228 |
b.wait_visible(self.card("Stratis filesystems")) |
| 229 |
b.wait_not_present(self.card_row("Stratis filesystems", name="fsys2-copy")) |
| 230 |
|
| 231 |
# Create an unmounted filesystem |
| 232 |
b.click(self.card_button("Stratis filesystems", "Create new filesystem")) |
| 233 |
self.dialog_wait_open() |
| 234 |
self.dialog_set_val('name', 'fsys-unmounted') |
| 235 |
self.dialog_apply_secondary() |
| 236 |
self.dialog_wait_close() |
| 237 |
|
| 238 |
b.wait_text(self.card_row_col("Stratis filesystems", 1, 1), "fsys-unmounted") |
| 239 |
b.wait_text(self.card_row_col("Stratis filesystems", 1, 3), "(not mounted)") |
| 240 |
|
| 241 |
# Delete the unmounted filesystem |
| 242 |
self.click_card_row("Stratis filesystems", 1) |
| 243 |
self.click_card_dropdown("Stratis filesystem", "Delete") |
| 244 |
self.confirm() |
| 245 |
b.wait_visible(self.card("Stratis filesystems")) |
| 246 |
b.wait_not_present(self.card_row("Stratis filesystems", name="fsys-unmounted")) |
| 247 |
|
| 248 |
# Add a data blockdev |
| 249 |
b.click(self.card_button("Stratis pool", "Add block device")) |
| 250 |
self.dialog_wait_open() |
| 251 |
self.dialog_apply() |
| 252 |
self.dialog_wait_error("disks", "At least one") |
| 253 |
self.dialog_set_val('disks', {dev_3: True}) |
| 254 |
if not legacy: |
| 255 |
b.assert_pixels("#dialog", "add-disk") |
| 256 |
self.dialog_apply() |
| 257 |
self.dialog_wait_close() |
| 258 |
|
| 259 |
b.wait_visible(self.card_row("Stratis pool", name=dev_3)) |
| 260 |
b.wait_in_text(self.card_desc("Stratis pool", "Usage"), "12 GB") |
| 261 |
|
| 262 |
# Add a cache blockdev |
| 263 |
b.click(self.card_button("Stratis pool", "Add block device")) |
| 264 |
self.dialog({'tier': "cache", |
| 265 |
'disks': {dev_4: True}}) |
| 266 |
b.wait_in_text(self.card_row("Stratis pool", name=dev_4), "cache") |
| 267 |
|
| 268 |
# Add a second cache blockdev, this uses a different code path |
| 269 |
b.click(self.card_button("Stratis pool", "Add block device")) |
| 270 |
self.dialog({'tier': "cache", |
| 271 |
'disks': {dev_5: True}}) |
| 272 |
b.wait_in_text(self.card_row("Stratis pool", name=dev_5), "cache") |
| 273 |
|
| 274 |
# Rename the pool |
| 275 |
b.click(self.card_desc_action("Stratis pool", "Name")) |
| 276 |
self.dialog({'name': "pool0-renamed"}) |
| 277 |
b.wait_text(self.card_desc("Stratis pool", "Name"), "pool0-renamed") |
| 278 |
|
| 279 |
# Create another filesystem |
| 280 |
b.click(self.card_button("Stratis filesystems", "Create new filesystem")) |
| 281 |
self.dialog({'name': 'fsys3', |
| 282 |
'mount_point': '/run/fsys3'}) |
| 283 |
b.wait_text(self.card_row_col("Stratis filesystems", 2, 1), "fsys3") |
| 284 |
b.wait_text(self.card_row_col("Stratis filesystems", 2, 3), "/run/fsys3") |
| 285 |
self.assertEqual(self.inode(m.execute("findmnt -n -o SOURCE /run/fsys3").strip()), |
| 286 |
self.inode("/dev/stratis/pool0-renamed/fsys3")) |
| 287 |
|
| 288 |
# Destroy the pool |
| 289 |
self.click_card_dropdown("Stratis pool", "Delete") |
| 290 |
self.dialog_wait_open() |
| 291 |
if not legacy: |
| 292 |
b.assert_pixels('#dialog', "delete-pool") |
| 293 |
self.dialog_apply() |
| 294 |
self.dialog_wait_close() |
| 295 |
b.wait_visible(self.card("Storage")) |
| 296 |
b.wait_not_present(self.card_row("Storage", name="pool0-renamed")) |
| 297 |
|
| 298 |
# Check that the entries have disappeared from fstab |
| 299 |
self.assertEqual(m.execute("grep /run/fsys1 /etc/fstab || true"), "") |
| 300 |
self.assertEqual(m.execute("grep /run/fsys2 /etc/fstab || true"), "") |
| 301 |
self.assertEqual(m.execute("grep /run/fsys3 /etc/fstab || true"), "") |
| 302 |
|
| 303 |
m.execute("! findmnt /run/fsys1") |
| 304 |
m.execute("! findmnt /run/fsys2") |
| 305 |
m.execute("! findmnt /run/fsys2-copy") |
| 306 |
m.execute("! findmnt /run/fsys3") |
| 307 |
|
| 308 |
# https://bugzilla.redhat.com/show_bug.cgi?id=2183084 |
| 309 |
# Do this assertion in the end so that the previous checks still run. |
| 310 |
# After the stratis pool is deleted we can't check this, so use the value from earlier. |
| 311 |
self.assertFalse(udisk_contains_stratis_private) |
| 312 |
|
| 313 |
@testlib.skipImage("Stratis too old for legacy tests", *V1_POOL_IMAGES) |
| 314 |
def testBasicLegacy(self): |
| 315 |
self.testBasic(legacy=True) |
| 316 |
|
| 317 |
@testlib.skipImage("Stratis too old", "rhel-8-*") |
| 318 |
def testAlerts(self): |
| 319 |
m = self.machine |
| 320 |
b = self.browser |
| 321 |
|
| 322 |
self.login_and_go("/storage") |
| 323 |
|
| 324 |
dev_1 = self.add_loopback_disk(PV_SIZE) |
| 325 |
dev_2 = self.add_loopback_disk(PV_SIZE) |
| 326 |
b.wait_visible(self.card_row("Storage", name=dev_1)) |
| 327 |
b.wait_visible(self.card_row("Storage", name=dev_2)) |
| 328 |
|
| 329 |
# Create an encrypted V1 pool with two block devices |
| 330 |
|
| 331 |
if m.image not in V1_POOL_IMAGES: |
| 332 |
create_pool_key(m, "pool0", "foodeeboodeebar") |
| 333 |
create_legacy_pool(m, disks=[dev_1, dev_2], keydesc="pool0") |
| 334 |
m.execute("stratis key unset pool0") |
| 335 |
else: |
| 336 |
self.click_devices_dropdown("Create Stratis pool") |
| 337 |
self.dialog_wait_open() |
| 338 |
self.dialog_set_val("encrypt_pass.on", val=True) |
| 339 |
self.dialog_set_val("passphrase", "foodeeboodeebar") |
| 340 |
self.dialog_set_val("passphrase2", "foodeeboodeebar") |
| 341 |
self.dialog_set_val("disks", {dev_1: True}) |
| 342 |
self.dialog_set_val("disks", {dev_2: True}) |
| 343 |
self.dialog_apply() |
| 344 |
self.dialog_wait_close() |
| 345 |
|
| 346 |
b.wait_visible(self.card_row("Storage", name="pool0")) |
| 347 |
b.wait_not_present(self.card_row("Storage", name="pool0") + " .ct-icon-exclamation-triangle") |
| 348 |
|
| 349 |
# Check that there is no alert on the details page |
| 350 |
self.click_card_row("Storage", name="pool0") |
| 351 |
b.wait_visible(self.card("Encrypted Stratis pool")) |
| 352 |
b.wait_not_present('.pf-v6-c-alert') |
| 353 |
|
| 354 |
m.execute(f""" |
| 355 |
JSON=$(sudo cryptsetup token export --token-id=1 {dev_1} \ |
| 356 |
| jq '.key_description = "stratis-1-key-no-other-is-the-same"') |
| 357 |
sudo cryptsetup token remove --token-id=1 {dev_1} |
| 358 |
echo $JSON | sudo cryptsetup token import --token-id=1 {dev_1} |
| 359 |
systemctl restart stratisd |
| 360 |
""") |
| 361 |
|
| 362 |
b.go('#/') |
| 363 |
b.wait_visible(self.card_row("Storage", name="pool0") + " .ct-icon-exclamation-triangle") |
| 364 |
|
| 365 |
self.click_card_row("Storage", name="pool0") |
| 366 |
b.wait_visible('.pf-v6-c-alert:contains("This pool is in a degraded state")') |
| 367 |
|
| 368 |
b.click(self.card_button("Stratis filesystems", "Create new filesystem")) |
| 369 |
self.dialog_wait_open() |
| 370 |
self.dialog_set_val("name", "fsys1") |
| 371 |
self.dialog_set_val("mount_point", "/run/fsys1") |
| 372 |
self.dialog_apply() |
| 373 |
self.dialog_wait_alert("Pool is in state NoRequests where this action cannot be performed until the issue is resolved manually") |
| 374 |
|
| 375 |
@testlib.nondestructive |
| 376 |
def testCli(self): |
| 377 |
m = self.machine |
| 378 |
b = self.browser |
| 379 |
|
| 380 |
self.login_and_go("/storage") |
| 381 |
|
| 382 |
dev_1 = self.add_loopback_disk(PV_SIZE) |
| 383 |
dev_2 = self.add_loopback_disk(PV_SIZE) |
| 384 |
b.wait_visible(self.card_row("Storage", name=dev_1)) |
| 385 |
b.wait_visible(self.card_row("Storage", name=dev_2)) |
| 386 |
|
| 387 |
# Create a pool outside of Cockpit |
| 388 |
m.execute(f"stratis pool create TEST1 {dev_1} {dev_2}") |
| 389 |
b.wait_visible(self.card_row("Storage", name="TEST1")) |
| 390 |
b.wait_in_text(self.card_row("Storage", name=dev_1), "Stratis block device") |
| 391 |
b.wait_in_text(self.card_row("Storage", name=dev_1), "TEST1") |
| 392 |
b.wait_in_text(self.card_row("Storage", name=dev_2), "Stratis block device") |
| 393 |
b.wait_in_text(self.card_row("Storage", name=dev_1), "TEST1") |
| 394 |
|
| 395 |
# Create two filesystems outside of Cockpit |
| 396 |
m.execute("stratis filesystem create TEST1 fsys1") |
| 397 |
b.wait_visible(self.card_row("Storage", name="fsys1")) |
| 398 |
m.execute("stratis filesystem create TEST1 fsys2") |
| 399 |
b.wait_visible(self.card_row("Storage", name="fsys2")) |
| 400 |
|
| 401 |
mount = f"{self.vm_tmpdir}/fsys1" |
| 402 |
|
| 403 |
# Mount externally, adjust fstab with Cockpit |
| 404 |
self.click_card_row("Storage", name="fsys1") |
| 405 |
m.execute(f"mkdir {mount}; mount /dev/stratis/TEST1/fsys1 {mount}") |
| 406 |
b.click(self.card_button("Stratis filesystem", f"Mount automatically on {mount} on boot")) |
| 407 |
b.wait_not_present(self.card_button("Stratis filesystem", f"Mount automatically on {mount} on boot")) |
| 408 |
self.assertIn("stratis-fstab-setup", m.execute(f"grep {mount} /etc/fstab")) |
| 409 |
|
| 410 |
# Unmount externally, adjust fstab with Cockpit |
| 411 |
m.execute(f"umount {mount}") |
| 412 |
b.click(self.card_button("Stratis filesystem", "Do not mount automatically on boot")) |
| 413 |
b.wait_not_present(self.card_button("Stratis filesystem", "Do not mount automatically on boot")) |
| 414 |
self.assertIn("noauto", m.execute(f"grep {mount} /etc/fstab")) |
| 415 |
|
| 416 |
# Destroy them outside of Cockpit |
| 417 |
b.click(self.card_parent_link()) |
| 418 |
b.wait_visible(self.card("Stratis filesystems")) |
| 419 |
m.execute("stratis filesystem destroy TEST1 fsys1") |
| 420 |
b.wait_not_present(self.card_row("Stratis filesystems", name="fsys1")) |
| 421 |
m.execute("stratis filesystem destroy TEST1 fsys2") |
| 422 |
b.wait_not_present(self.card_row("Stratis filesystems", name="fsys2")) |
| 423 |
|
| 424 |
# Destroy the pool outside of Cockpit |
| 425 |
m.execute("stratis pool destroy TEST1") |
| 426 |
b.wait_in_text("main", "Not found") |
| 427 |
|
| 428 |
b.go("#/") |
| 429 |
b.wait_visible(self.card("Storage")) |
| 430 |
b.wait_not_present(self.card_row("Storage", name="TEST1")) |
| 431 |
|
| 432 |
def testOverprovisioning(self, legacy=False): |
| 433 |
b = self.browser |
| 434 |
|
| 435 |
self.login_and_go("/storage") |
| 436 |
|
| 437 |
dev_1 = self.add_loopback_disk(PV_SIZE) |
| 438 |
b.wait_visible(self.card_row("Storage", name=dev_1)) |
| 439 |
|
| 440 |
# Create a pool with overprov off |
| 441 |
if not legacy: |
| 442 |
self.dialog_with_retry(trigger=lambda: self.click_devices_dropdown("Create Stratis pool"), |
| 443 |
expect=lambda: (self.dialog_is_present('disks', dev_1) and |
| 444 |
self.dialog_check({"name": "pool0"})), |
| 445 |
values={ |
| 446 |
"disks": {dev_1: True}, |
| 447 |
"overprov.on": False |
| 448 |
}) |
| 449 |
else: |
| 450 |
create_legacy_pool(self.machine, disks=[dev_1]) |
| 451 |
self.machine.execute("stratis pool overprovision pool0 no") |
| 452 |
|
| 453 |
self.click_card_row("Storage", name="pool0") |
| 454 |
|
| 455 |
overprov_toggle = "input[aria-label='Allow overprovisioning']" |
| 456 |
b.wait_visible(f"{overprov_toggle}:not(:checked)") |
| 457 |
|
| 458 |
# Create filesystem with defaults. Initial virtual size |
| 459 |
# should be appropriate. |
| 460 |
|
| 461 |
b.click(self.card_button("Stratis filesystems", "Create new filesystem")) |
| 462 |
self.dialog_wait_open() |
| 463 |
self.dialog_wait_val('set_custom_size.enabled', val=True) |
| 464 |
self.dialog_set_val('name', 'fsys1') |
| 465 |
self.dialog_apply_secondary() |
| 466 |
self.dialog_wait_close() |
| 467 |
|
| 468 |
# Snapshot should be disabled now |
| 469 |
|
| 470 |
self.check_dropdown_action_disabled(self.card_row("Stratis filesystems", name="fsys1"), "Snapshot", "Not enough free space") |
| 471 |
|
| 472 |
# Switch overprov on |
| 473 |
|
| 474 |
b.click(overprov_toggle) |
| 475 |
b.wait_visible(f"{overprov_toggle}:checked") |
| 476 |
|
| 477 |
# Snapshot succeeds |
| 478 |
|
| 479 |
self.click_dropdown(self.card_row("Stratis filesystems", name="fsys1"), "Snapshot") |
| 480 |
self.dialog_wait_open() |
| 481 |
self.dialog_set_val('name', 'snap1') |
| 482 |
self.dialog_apply_secondary() |
| 483 |
self.dialog_wait_close() |
| 484 |
|
| 485 |
# Filesystem creation does not ask for file size by default |
| 486 |
|
| 487 |
b.click(self.card_button("Stratis filesystems", "Create new filesystem")) |
| 488 |
self.dialog_wait_open() |
| 489 |
self.dialog_wait_val('set_custom_size.enabled', val=False) |
| 490 |
self.dialog_cancel() |
| 491 |
self.dialog_wait_close() |
| 492 |
|
| 493 |
# Turning overprov off should be disabled now |
| 494 |
|
| 495 |
b.wait_visible(overprov_toggle + "[disabled]") |
| 496 |
|
| 497 |
# Delete snapshot |
| 498 |
|
| 499 |
self.click_dropdown(self.card_row("Stratis filesystems", name="snap1"), "Delete") |
| 500 |
self.confirm() |
| 501 |
|
| 502 |
# Switch overprov off |
| 503 |
|
| 504 |
b.click(overprov_toggle) |
| 505 |
b.wait_visible(f"{overprov_toggle}:not(:checked)") |
| 506 |
|
| 507 |
@testlib.skipImage("Stratis too old for legacy tests", *V1_POOL_IMAGES) |
| 508 |
def testOverprovisioningLegacy(self): |
| 509 |
self.testOverprovisioning(legacy=True) |
| 510 |
|
| 511 |
def testFilesystemSizes(self, legacy=False): |
| 512 |
b = self.browser |
| 513 |
|
| 514 |
self.login_and_go("/storage") |
| 515 |
|
| 516 |
dev_1 = self.add_loopback_disk(PV_SIZE) |
| 517 |
b.wait_visible(self.card_row("Storage", name=dev_1)) |
| 518 |
|
| 519 |
# Create a pool |
| 520 |
if not legacy: |
| 521 |
self.dialog_with_retry(trigger=lambda: self.click_devices_dropdown("Create Stratis pool"), |
| 522 |
expect=lambda: (self.dialog_is_present('disks', dev_1) and |
| 523 |
self.dialog_check({"name": "pool0"})), |
| 524 |
values={"disks": {dev_1: True}}) |
| 525 |
else: |
| 526 |
create_legacy_pool(self.machine, disks=[dev_1]) |
| 527 |
|
| 528 |
self.click_card_row("Storage", name="pool0") |
| 529 |
|
| 530 |
# Create filesystem with initial virtual size and a limit |
| 531 |
|
| 532 |
b.click(self.card_button("Stratis filesystems", "Create new filesystem")) |
| 533 |
self.dialog_wait_open() |
| 534 |
self.dialog_set_val('name', 'fsys1') |
| 535 |
self.dialog_set_val('set_custom_size.enabled', val=True) |
| 536 |
self.dialog_set_val('size', 800) |
| 537 |
self.dialog_set_val('set_custom_limit.enabled', val=True) |
| 538 |
self.dialog_set_val('limit', 1600) |
| 539 |
self.dialog_apply_secondary() |
| 540 |
self.dialog_wait_close() |
| 541 |
|
| 542 |
self.click_card_row("Stratis filesystems", name="fsys1") |
| 543 |
|
| 544 |
b.wait_text(self.card_desc("Stratis filesystem", "Virtual size"), "800 MB") |
| 545 |
b.wait_text(self.card_desc("Stratis filesystem", "Virtual size limit"), "1.60 GB") |
| 546 |
|
| 547 |
# Raise the limit |
| 548 |
|
| 549 |
b.click(self.card_desc_action("Stratis filesystem", "Virtual size limit")) |
| 550 |
self.dialog_wait_open() |
| 551 |
self.dialog_wait_val('size_options.custom_limit', val=True) |
| 552 |
self.dialog_wait_val('limit', 1600) |
| 553 |
self.dialog_set_val('limit', 3200) |
| 554 |
self.dialog_apply() |
| 555 |
self.dialog_wait_close() |
| 556 |
|
| 557 |
b.wait_text(self.card_desc("Stratis filesystem", "Virtual size limit"), "3.20 GB") |
| 558 |
|
| 559 |
# Remove limit |
| 560 |
|
| 561 |
b.click(self.card_desc_action("Stratis filesystem", "Virtual size limit")) |
| 562 |
self.dialog_wait_open() |
| 563 |
self.dialog_set_val('size_options.custom_limit', val=False) |
| 564 |
self.dialog_apply() |
| 565 |
self.dialog_wait_close() |
| 566 |
|
| 567 |
b.wait_text(self.card_desc("Stratis filesystem", "Virtual size limit"), "none") |
| 568 |
|
| 569 |
@testlib.skipImage("Stratis too old for legacy tests", *V1_POOL_IMAGES) |
| 570 |
def testFilesystemSizesLegacy(self): |
| 571 |
self.testFilesystemSizes(legacy=True) |
| 572 |
|
| 573 |
|
| 574 |
@testlib.skipImage("No Stratis", "debian-*", "ubuntu-*", "arch") |
| 575 |
@testlib.skipImage("stratis not installed", "*-bootc") |
| 576 |
@testlib.skipImage("commit 817c957899a4 removed Statis 2 support", "rhel-8-*") |
| 577 |
class TestStorageStratisReboot(storagelib.StorageCase): |
| 578 |
def setUp(self): |
| 579 |
super().setUp() |
| 580 |
exe = self.machine.execute |
| 581 |
|
| 582 |
if self.image == "arch": |
| 583 |
# Arch Linux does not enable systemd units by default |
| 584 |
exe("systemctl enable --now stratisd") |
| 585 |
self.addCleanup(self.machine.execute, "systemctl disable --now stratisd") |
| 586 |
|
| 587 |
# these tests reboot |
| 588 |
self.allow_restart_journal_messages() |
| 589 |
|
| 590 |
def testEncrypted(self, legacy=False): |
| 591 |
m = self.machine |
| 592 |
b = self.browser |
| 593 |
|
| 594 |
self.login_and_go("/storage") |
| 595 |
|
| 596 |
dev_1 = "/dev/sda" |
| 597 |
m.add_disk("4G", serial="DISK1") |
| 598 |
b.wait_visible(self.card_row("Storage", name=dev_1)) |
| 599 |
|
| 600 |
dev_2 = "/dev/sdb" |
| 601 |
m.add_disk("4G", serial="DISK2") |
| 602 |
b.wait_visible(self.card_row("Storage", name=dev_2)) |
| 603 |
|
| 604 |
dev_3 = "/dev/sdc" |
| 605 |
m.add_disk("4G", serial="DISK3") |
| 606 |
b.wait_visible(self.card_row("Storage", name=dev_3)) |
| 607 |
|
| 608 |
passphrase = "foodeeboodeebar" |
| 609 |
|
| 610 |
# Create an encrypted pool with a filesystem, but don't mount |
| 611 |
# it. Cockpit will chose a key description for the pool and |
| 612 |
# we occupy its first choice in order to force Cockpit to use |
| 613 |
# something else. |
| 614 |
create_pool_key(m, "pool0", "not-the-passphrase") |
| 615 |
if not legacy: |
| 616 |
self.dialog_open_with_retry(trigger=lambda: self.click_devices_dropdown("Create Stratis pool"), |
| 617 |
expect=lambda: (self.dialog_is_present('disks', dev_1) and |
| 618 |
self.dialog_check({"name": "pool0"}))) |
| 619 |
self.dialog_set_val("encrypt_pass.on", val=True) |
| 620 |
self.dialog_set_val("passphrase", passphrase) |
| 621 |
self.dialog_set_val("passphrase2", passphrase) |
| 622 |
self.dialog_set_val("disks", {dev_1: True}) |
| 623 |
b.assert_pixels("#dialog", "create-encrypted-pool", |
| 624 |
# The small checkbox ticks render inconsistently |
| 625 |
ignore=["input[type=checkbox]"]) |
| 626 |
self.dialog_apply() |
| 627 |
self.dialog_wait_close() |
| 628 |
else: |
| 629 |
create_pool_key(m, "pool0.1", passphrase) |
| 630 |
create_legacy_pool(m, disks=[dev_1], keydesc="pool0.1") |
| 631 |
m.execute("stratis key unset pool0.1") |
| 632 |
m.execute("stratis key unset pool0") |
| 633 |
|
| 634 |
v1_pool = legacy or m.image in V1_POOL_IMAGES |
| 635 |
|
| 636 |
self.click_card_row("Storage", name="pool0") |
| 637 |
b.wait_visible(self.card("Encrypted Stratis pool")) |
| 638 |
|
| 639 |
b.click(self.card_button("Stratis filesystems", "Create new filesystem")) |
| 640 |
self.dialog({'name': 'fsys1', |
| 641 |
'mount_point': '/run/fsys1', |
| 642 |
'at_boot': 'local'}, |
| 643 |
secondary=True) |
| 644 |
b.wait_text(self.card_row_col("Stratis filesystems", 1, 1), "fsys1") |
| 645 |
b.wait_text(self.card_row_col("Stratis filesystems", 1, 3), "/run/fsys1 (not mounted)") |
| 646 |
|
| 647 |
# Check that it has an entry in fstab and that it is "noauto" |
| 648 |
self.assertIn("noauto", m.execute("grep /run/fsys1 /etc/fstab")) |
| 649 |
|
| 650 |
# Add a data blockdev |
| 651 |
b.click(self.card_button("Encrypted Stratis pool", "Add block device")) |
| 652 |
self.dialog_wait_open() |
| 653 |
self.dialog_set_val('disks', {dev_2: True}) |
| 654 |
self.dialog_apply() |
| 655 |
if v1_pool: |
| 656 |
self.dialog_wait_error("pool_passphrase", "Passphrase cannot be empty") |
| 657 |
self.dialog_set_val('pool_passphrase', passphrase) |
| 658 |
self.dialog_apply() |
| 659 |
self.dialog_wait_close() |
| 660 |
b.wait_in_text(self.card_row("Encrypted Stratis pool", name=dev_2), "data") |
| 661 |
|
| 662 |
# Change the passphrase |
| 663 |
if v1_pool: |
| 664 |
b.wait_visible(self.card_desc("Encryption tokens", "Passphrase") + " button:contains('Remove'):disabled") |
| 665 |
b.click(self.card_desc("Encryption tokens", "Passphrase") + " button:contains('Change')") |
| 666 |
else: |
| 667 |
self.click_dropdown(self.card_row("Encryption tokens", index=1), "Change") |
| 668 |
self.dialog({'old_passphrase': passphrase, |
| 669 |
'new_passphrase': "boodeefoodeebar", |
| 670 |
'new_passphrase2': "boodeefoodeebar"}) |
| 671 |
# do it again, with the old passphrase in the keyring |
| 672 |
create_pool_key(m, "pool0", "boodeefoodeebar") |
| 673 |
if v1_pool: |
| 674 |
b.click(self.card_desc("Encryption tokens", "Passphrase") + " button:contains('Change')") |
| 675 |
else: |
| 676 |
self.click_dropdown(self.card_row("Encryption tokens", index=1), "Change") |
| 677 |
self.dialog({'new_passphrase': passphrase, |
| 678 |
'new_passphrase2': passphrase}) |
| 679 |
m.execute("stratis key unset pool0") |
| 680 |
|
| 681 |
if not v1_pool: |
| 682 |
# Add a second passphrase |
| 683 |
b.wait_text(self.card_row_col("Encryption tokens", 1, 2), "Passphrase") |
| 684 |
b.click(self.card_button("Encryption tokens", "Add passphrase")) |
| 685 |
self.dialog({'pool_passphrase': passphrase, |
| 686 |
'passphrase': "boodeefoodeebar", |
| 687 |
'passphrase2': "boodeefoodeebar"}) |
| 688 |
b.wait_text(self.card_row_col("Encryption tokens", 2, 2), "Passphrase") |
| 689 |
# And remove it again |
| 690 |
self.click_dropdown(self.card_row("Encryption tokens", index=2), "Remove") |
| 691 |
self.confirm() |
| 692 |
|
| 693 |
# Add a cache blockdev |
| 694 |
b.click(self.card_button("Encrypted Stratis pool", "Add block device")) |
| 695 |
self.dialog_wait_open() |
| 696 |
self.dialog_set_val('tier', "cache") |
| 697 |
self.dialog_set_val('disks', {dev_3: True}) |
| 698 |
if v1_pool: |
| 699 |
self.dialog_set_val('pool_passphrase', passphrase) |
| 700 |
self.dialog_apply() |
| 701 |
self.dialog_wait_close() |
| 702 |
b.wait_in_text(self.card_row("Encrypted Stratis pool", name=dev_3), "cache") |
| 703 |
|
| 704 |
self.reboot() |
| 705 |
m.start_cockpit() |
| 706 |
b.relogin() |
| 707 |
b.enter_page("/storage") |
| 708 |
|
| 709 |
b.wait_visible(self.card("Stratis pool")) |
| 710 |
b.wait_in_text(self.card("Stratis pool"), "DISK1") |
| 711 |
b.wait_in_text(self.card("Stratis pool"), "DISK2") |
| 712 |
|
| 713 |
# Unlock the pool |
| 714 |
b.click(self.card_button("Stratis pool", "Start")) |
| 715 |
self.dialog_wait_open() |
| 716 |
self.dialog_set_val('passphrase', "wrong-passphrase") |
| 717 |
self.dialog_apply() |
| 718 |
with b.wait_timeout(60): |
| 719 |
b.wait_visible("#dialog .pf-v6-c-alert.pf-m-danger") |
| 720 |
self.dialog_set_val('passphrase', passphrase) |
| 721 |
self.dialog_apply() |
| 722 |
self.dialog_wait_close() |
| 723 |
b.wait_text(self.card_desc("Encrypted Stratis pool", "Name"), "pool0") |
| 724 |
|
| 725 |
# Mount the filesystem |
| 726 |
b.wait_text(self.card_row_col("Stratis filesystems", 1, 3), "/run/fsys1 (not mounted)") |
| 727 |
self.click_dropdown(self.card_row("Stratis filesystems", 1), "Mount") |
| 728 |
self.dialog({}) |
| 729 |
b.wait_text(self.card_row_col("Stratis filesystems", 1, 3), "/run/fsys1") |
| 730 |
|
| 731 |
# Reboot (this requires the passphrase) |
| 732 |
self.setup_systemd_password_agent(passphrase) |
| 733 |
self.reboot() |
| 734 |
m.start_cockpit() |
| 735 |
b.relogin() |
| 736 |
b.enter_page("/storage") |
| 737 |
b.wait_text(self.card_desc("Encrypted Stratis pool", "Name"), "pool0") |
| 738 |
|
| 739 |
# Filesystem should be mounted now |
| 740 |
b.wait_text(self.card_row_col("Stratis filesystems", 1, 3), "/run/fsys1") |
| 741 |
|
| 742 |
# Destroy the pool |
| 743 |
self.click_card_dropdown("Encrypted Stratis pool", "Delete") |
| 744 |
self.confirm() |
| 745 |
b.wait_visible(self.card("Storage")) |
| 746 |
b.wait_not_present(self.card_row("Storage", name="pool0")) |
| 747 |
|
| 748 |
# Check that the entry has disappeared from fstab |
| 749 |
self.assertEqual(m.execute("grep /run/fsys1 /etc/fstab || true"), "") |
| 750 |
|
| 751 |
@testlib.skipImage("Stratis too old for legacy tests", *V1_POOL_IMAGES) |
| 752 |
def testEncryptedLegacy(self): |
| 753 |
self.testEncrypted(legacy=True) |
| 754 |
|
| 755 |
def testReboot(self, legacy=False): |
| 756 |
m = self.machine |
| 757 |
b = self.browser |
| 758 |
|
| 759 |
self.login_and_go("/storage") |
| 760 |
|
| 761 |
dev_1 = "/dev/sda" |
| 762 |
m.add_disk("4G", serial="DISK1") |
| 763 |
b.wait_visible(self.card_row("Storage", name=dev_1)) |
| 764 |
|
| 765 |
# Create a pool |
| 766 |
if not legacy: |
| 767 |
self.dialog_with_retry(trigger=lambda: self.click_devices_dropdown("Create Stratis pool"), |
| 768 |
expect=lambda: (self.dialog_is_present('disks', dev_1) and |
| 769 |
self.dialog_check({"name": "pool0"})), |
| 770 |
values={"disks": {dev_1: True}}) |
| 771 |
else: |
| 772 |
create_legacy_pool(m, disks=[dev_1]) |
| 773 |
self.click_card_row("Storage", name="pool0") |
| 774 |
|
| 775 |
# Create a filesystems |
| 776 |
b.click(self.card_button("Stratis filesystems", "Create new filesystem")) |
| 777 |
self.dialog({'name': 'fsys1', |
| 778 |
'mount_point': '/run/fsys1'}) |
| 779 |
b.wait_text(self.card_row_col("Stratis filesystems", 1, 1), "fsys1") |
| 780 |
b.wait_text(self.card_row_col("Stratis filesystems", 1, 3), "/run/fsys1") |
| 781 |
|
| 782 |
self.reboot() |
| 783 |
m.start_cockpit() |
| 784 |
b.relogin() |
| 785 |
b.enter_page("/storage") |
| 786 |
|
| 787 |
# Filesystem should be mounted now |
| 788 |
b.wait_text(self.card_row_col("Stratis filesystems", 1, 1), "fsys1") |
| 789 |
b.wait_text(self.card_row_col("Stratis filesystems", 1, 3), "/run/fsys1") |
| 790 |
|
| 791 |
@testlib.skipImage("Stratis too old for legacy tests", *V1_POOL_IMAGES) |
| 792 |
def testRebootLegacy(self): |
| 793 |
self.testReboot(legacy=True) |
| 794 |
|
| 795 |
def testAtBoot(self): |
| 796 |
m = self.machine |
| 797 |
b = self.browser |
| 798 |
|
| 799 |
self.login_and_go("/storage") |
| 800 |
|
| 801 |
dev_1 = "/dev/sda" |
| 802 |
m.add_disk("4G", serial="DISK1") |
| 803 |
b.wait_visible(self.card_row("Storage", name=dev_1)) |
| 804 |
|
| 805 |
# Create a pool |
| 806 |
self.dialog_with_retry(trigger=lambda: self.click_devices_dropdown("Create Stratis pool"), |
| 807 |
expect=lambda: (self.dialog_is_present('disks', dev_1) and |
| 808 |
self.dialog_check({"name": "pool0"})), |
| 809 |
values={"disks": {dev_1: True}}) |
| 810 |
self.click_card_row("Storage", name="pool0") |
| 811 |
|
| 812 |
def create(at_boot): |
| 813 |
b.click(self.card_button("Stratis filesystems", "Create new filesystem")) |
| 814 |
self.dialog({'name': 'fsys1', |
| 815 |
'mount_point': f'{self.mnt_dir}/foo', |
| 816 |
'at_boot': at_boot}) |
| 817 |
b.wait_text(self.card_row_col("Stratis filesystems", 1, 1), "fsys1") |
| 818 |
b.wait_text(self.card_row_col("Stratis filesystems", 1, 3), f"{self.mnt_dir}/foo") |
| 819 |
|
| 820 |
def destroy(): |
| 821 |
self.click_card_row("Stratis filesystems", 1) |
| 822 |
self.click_card_dropdown("Stratis filesystem", "Delete") |
| 823 |
self.dialog_wait_open() |
| 824 |
self.dialog_apply_with_retry("Device or resource busy") |
| 825 |
b.wait_visible(self.card("Stratis filesystems")) |
| 826 |
b.wait_not_present(self.card_row("Stratis filesystems", name="fsys1")) |
| 827 |
|
| 828 |
create("local") |
| 829 |
self.assertNotIn("noauto", m.execute(f"findmnt --fstab -n -o OPTIONS {self.mnt_dir}/foo")) |
| 830 |
destroy() |
| 831 |
|
| 832 |
create("nofail") |
| 833 |
self.assertIn("nofail", m.execute(f"findmnt --fstab -n -o OPTIONS {self.mnt_dir}/foo")) |
| 834 |
destroy() |
| 835 |
|
| 836 |
create("netdev") |
| 837 |
self.assertIn("_netdev", m.execute(f"findmnt --fstab -n -o OPTIONS {self.mnt_dir}/foo")) |
| 838 |
destroy() |
| 839 |
|
| 840 |
create("never") |
| 841 |
self.assertIn("x-cockpit-never-auto", m.execute(f"findmnt --fstab -n -o OPTIONS {self.mnt_dir}/foo")) |
| 842 |
self.assertIn("noauto", m.execute(f"findmnt --fstab -n -o OPTIONS {self.mnt_dir}/foo")) |
| 843 |
destroy() |
| 844 |
|
| 845 |
@testlib.skipImage("Stratis too old", "rhel-8-*") |
| 846 |
def testPoolResize(self, legacy=False): |
| 847 |
m = self.machine |
| 848 |
b = self.browser |
| 849 |
|
| 850 |
self.login_and_go("/storage") |
| 851 |
|
| 852 |
dev = "/dev/sda" |
| 853 |
m.add_disk("4G", serial="DISK1") |
| 854 |
b.wait_visible(self.card_row("Storage", name=dev)) |
| 855 |
|
| 856 |
# Create a logical volume that we will later grow |
| 857 |
m.execute(f"vgcreate vgroup0 {dev}; lvcreate vgroup0 -n lvol0 -L 1500000256b") |
| 858 |
b.wait_visible(self.card_row("Storage", name="lvol0")) |
| 859 |
|
| 860 |
# Create a pool |
| 861 |
if not legacy: |
| 862 |
self.dialog_with_retry(trigger=lambda: self.click_devices_dropdown("Create Stratis pool"), |
| 863 |
expect=lambda: self.dialog_is_present('disks', "/dev/vgroup0/lvol0"), |
| 864 |
values={"disks": {"/dev/vgroup0/lvol0": True}}) |
| 865 |
else: |
| 866 |
create_legacy_pool(m, disks=["/dev/vgroup0/lvol0"]) |
| 867 |
|
| 868 |
b.wait_in_text(self.card_row("Storage", name="pool0"), "1.5 GB") |
| 869 |
|
| 870 |
# Grow the logical volume in Cockpit, the pool should grow automatically |
| 871 |
self.click_card_row("Storage", name="lvol0") |
| 872 |
b.click(self.card_button("LVM2 logical volume", "Grow")) |
| 873 |
self.dialog({"size": 1600}) |
| 874 |
b.go("#/") |
| 875 |
b.wait_in_text(self.card_row("Storage", name="pool0"), "1.6 GB") |
| 876 |
|
| 877 |
# Grow the logical volume from outside of Cockpit, the pool should complain |
| 878 |
m.execute("lvresize vgroup0/lvol0 -L +100000256b") |
| 879 |
b.wait_visible(self.card_row("Storage", name="pool0") + ' .ct-icon-exclamation-triangle') |
| 880 |
self.click_card_row("Storage", name="pool0") |
| 881 |
b.wait_visible('.pf-v6-c-alert:contains("This pool does not use all the space")') |
| 882 |
b.click('button:contains("Grow the pool")') |
| 883 |
b.wait_not_present('.pf-v6-c-alert') |
| 884 |
b.wait_in_text(self.card_desc("Stratis pool", "Usage"), "1.7 GB") |
| 885 |
|
| 886 |
b.go("#/") |
| 887 |
|
| 888 |
# Grow the logical volume from outside of Cockpit, the logical volume should also complain |
| 889 |
m.execute("lvresize vgroup0/lvol0 -L +100000256b") |
| 890 |
b.wait_visible(self.card_row("Storage", name="lvol0") + " .ct-icon-exclamation-triangle") |
| 891 |
self.click_card_row("Storage", name="lvol0") |
| 892 |
# First shrink the volume to test whether Cockpit can figure out the right size for that |
| 893 |
b.click(self.card_button("LVM2 logical volume", "Shrink volume")) |
| 894 |
b.wait_in_text(self.card_desc("LVM2 logical volume", "Size"), "1.70 GB") |
| 895 |
b.wait_not_present(self.card_button("LVM2 logical volume", "Shrink volume")) |
| 896 |
# Then enlarge the volume from the outside again and grow the blockdev |
| 897 |
m.execute("lvresize vgroup0/lvol0 -L +100000256b") |
| 898 |
b.click(self.card_button("LVM2 logical volume", "Grow content")) |
| 899 |
b.wait_not_present(self.card_button("LVM2 logical volume", "Grow content")) |
| 900 |
b.go("#/") |
| 901 |
b.wait_in_text(self.card_row("Storage", name="pool0"), "1.8 GB") |
| 902 |
|
| 903 |
@testlib.skipImage("Stratis too old for legacy tests", *V1_POOL_IMAGES) |
| 904 |
def testPoolResizeLegacy(self): |
| 905 |
self.testPoolResize(legacy=True) |
| 906 |
|
| 907 |
|
| 908 |
@testlib.skipImage("No Stratis", "debian-*", "ubuntu-*", "arch") |
| 909 |
@testlib.skipOstree("no package installation on OSTree") |
| 910 |
class TestStoragePackagesStratis(packagelib.PackageCase, storagelib.StorageCase): |
| 911 |
|
| 912 |
def testStratisOndemandInstallation(self): |
| 913 |
m = self.machine |
| 914 |
b = self.browser |
| 915 |
|
| 916 |
# RHEL 8 should not offer installation of Stratis from Cockpit |
| 917 |
# itself. |
| 918 |
# |
| 919 |
ondemand_stratis = "rhel-8" not in m.image |
| 920 |
|
| 921 |
m.execute("systemctl stop stratisd && dnf remove -y stratisd stratis") |
| 922 |
if ondemand_stratis: |
| 923 |
self.addPackageSet("stratis") |
| 924 |
self.enableRepo() |
| 925 |
|
| 926 |
self.login_and_go("/storage") |
| 927 |
|
| 928 |
dev_1 = "/dev/sda" |
| 929 |
m.add_disk("4G", serial="DISK1") |
| 930 |
b.wait_visible(self.card_row("Storage", name=dev_1)) |
| 931 |
|
| 932 |
if ondemand_stratis: |
| 933 |
self.click_devices_dropdown("Create Stratis pool") |
| 934 |
self.dialog_wait_open() |
| 935 |
b.wait_in_text("#dialog", "The stratisd package must be installed") |
| 936 |
self.dialog_apply() |
| 937 |
with b.wait_timeout(60): |
| 938 |
self.dialog_wait_val("name", "pool0") |
| 939 |
self.dialog_set_val("disks", {dev_1: True}) |
| 940 |
self.dialog_apply() |
| 941 |
self.dialog_wait_close() |
| 942 |
b.wait_visible(self.card_row("Storage", name="pool0")) |
| 943 |
else: |
| 944 |
dropdown_toggle = self.dropdown_toggle(self.card_header("Storage")) |
| 945 |
raid_action = self.dropdown_action("Create MDRAID device") |
| 946 |
stratis_action = self.dropdown_action("Create Stratis pool") |
| 947 |
b.click(dropdown_toggle) |
| 948 |
b.wait_visible(raid_action) |
| 949 |
b.wait_not_present(stratis_action) |
| 950 |
|
| 951 |
|
| 952 |
@testlib.skipImage("No Stratis", "debian-*", "ubuntu-*", "arch") |
| 953 |
@testlib.skipImage("stratis not installed", "*-bootc") |
| 954 |
@testlib.skipImage("Stratis too old", "rhel-8-*") |
| 955 |
class TestStorageStratisNBDE(packagelib.PackageCase, storagelib.StorageCase): |
| 956 |
provision = { |
| 957 |
"0": {"address": "10.111.112.1/20", "memory_mb": 2048}, |
| 958 |
"tang": {"address": "10.111.112.5/20"} |
| 959 |
} |
| 960 |
|
| 961 |
def setUp(self): |
| 962 |
super().setUp() |
| 963 |
|
| 964 |
if self.image == "arch": |
| 965 |
# Arch Linux does not enable systemd units by default |
| 966 |
self.machine.execute("systemctl enable --now stratisd") |
| 967 |
self.addCleanup(self.machine.execute, "systemctl disable --now stratisd") |
| 968 |
|
| 969 |
self.stop_type_opt = get_stratis_stop_type_opt(self.machine.execute) |
| 970 |
|
| 971 |
def testBasic(self, legacy=False): |
| 972 |
m = self.machine |
| 973 |
b = self.browser |
| 974 |
|
| 975 |
tang_m = self.machines["tang"] |
| 976 |
tang_m.execute("systemctl start tangd.socket") |
| 977 |
tang_m.execute("firewall-cmd --add-port 80/tcp") |
| 978 |
|
| 979 |
self.login_and_go("/storage") |
| 980 |
|
| 981 |
dev_1 = "/dev/sda" |
| 982 |
m.add_disk("4G", serial="DISK1") |
| 983 |
b.wait_visible(self.card_row("Storage", name=dev_1)) |
| 984 |
|
| 985 |
dev_2 = "/dev/sdb" |
| 986 |
m.add_disk("5G", serial="DISK2") |
| 987 |
b.wait_visible(self.card_row("Storage", name=dev_2)) |
| 988 |
|
| 989 |
# Create an encrypted pool with both a passphrase and a keyserver |
| 990 |
if not legacy: |
| 991 |
self.dialog_open_with_retry(trigger=lambda: self.click_devices_dropdown("Create Stratis pool"), |
| 992 |
expect=lambda: (self.dialog_is_present('disks', dev_1) and |
| 993 |
self.dialog_check({"name": "pool0"}))) |
| 994 |
self.dialog_set_val("encrypt_pass.on", val=True) |
| 995 |
self.dialog_set_val("passphrase", "foodeeboodeebar") |
| 996 |
self.dialog_set_val("passphrase2", "foodeeboodeebar") |
| 997 |
self.dialog_set_val("encrypt_tang.on", val=True) |
| 998 |
self.dialog_set_val("tang_url", "10.111.112.5") |
| 999 |
self.dialog_set_val("disks", {dev_1: True}) |
| 1000 |
self.dialog_apply() |
| 1001 |
b.wait_in_text("#dialog", "Check the key hash") |
| 1002 |
b.wait_in_text("#dialog", tang_m.execute("tang-show-keys").strip()) |
| 1003 |
self.dialog_apply() |
| 1004 |
with b.wait_timeout(60): |
| 1005 |
self.dialog_wait_close() |
| 1006 |
else: |
| 1007 |
create_pool_key(m, "pool0", "foodeeboodeebar") |
| 1008 |
create_legacy_pool(m, disks=[dev_1], keydesc="pool0", tang="10.111.112.5") |
| 1009 |
m.execute("stratis key unset pool0") |
| 1010 |
|
| 1011 |
v1_pool = legacy or m.image in V1_POOL_IMAGES |
| 1012 |
|
| 1013 |
self.click_card_row("Storage", name="pool0") |
| 1014 |
if v1_pool: |
| 1015 |
b.wait_visible(self.card_desc("Encryption tokens", "Passphrase")) |
| 1016 |
b.wait_in_text(self.card_desc("Encryption tokens", "Keyserver"), "10.111.112.5") |
| 1017 |
else: |
| 1018 |
b.wait_visible(self.card_row("Encryption tokens", location="passphrase")) |
| 1019 |
b.wait_visible(self.card_row("Encryption tokens", location="10.111.112.5")) |
| 1020 |
|
| 1021 |
if not legacy: |
| 1022 |
b.assert_pixels(self.card("Encrypted Stratis pool"), "header", |
| 1023 |
ignore=['.pf-v6-c-description-list__group:contains("UUID")']) |
| 1024 |
|
| 1025 |
# Remove passphrase |
| 1026 |
if v1_pool: |
| 1027 |
b.click(self.card_desc("Encryption tokens", "Passphrase") + " button:contains('Remove')") |
| 1028 |
self.confirm() |
| 1029 |
b.wait_visible(self.card_desc("Encryption tokens", "Passphrase") + " button:contains('Add passphrase')") |
| 1030 |
b.wait_visible(self.card_desc("Encryption tokens", "Keyserver") + " button:contains('Remove'):disabled") |
| 1031 |
else: |
| 1032 |
self.click_dropdown(self.card_row("Encryption tokens", index=1), "Remove") |
| 1033 |
self.confirm() |
| 1034 |
row = self.card_row("Encryption tokens", location="10.111.112.5") |
| 1035 |
b.wait_visible(row) |
| 1036 |
b.click(self.dropdown_toggle(row)) |
| 1037 |
b.wait_visible(self.dropdown_action("Remove") + "[disabled]") |
| 1038 |
b.click(self.dropdown_toggle(row)) |
| 1039 |
|
| 1040 |
# Stop the pool and start it again. This should not ask |
| 1041 |
# for the passphrase (since there isn't any) |
| 1042 |
m.execute(f"stratis pool stop {self.stop_type_opt} pool0") |
| 1043 |
b.wait_visible(self.card("Stratis pool")) |
| 1044 |
tang_m.execute("systemctl stop tangd.socket") |
| 1045 |
b.click(self.card_button("Stratis pool", "Start")) |
| 1046 |
self.dialog_wait_open() |
| 1047 |
# stratis' error message for unreachable tang server is very poor: |
| 1048 |
# https://bugzilla.redhat.com/show_bug.cgi?id=2246920 Version < 3.6.0 said |
| 1049 |
# "Error communicating with server 10.111.112.5", check this again after fixing |
| 1050 |
b.wait_in_text("#dialog", "Error") |
| 1051 |
self.dialog_cancel() |
| 1052 |
self.dialog_wait_close() |
| 1053 |
|
| 1054 |
tang_m.execute("systemctl start tangd.socket") |
| 1055 |
b.click(self.card_button("Stratis pool", "Start")) |
| 1056 |
b.wait_visible(self.card("Encrypted Stratis pool")) |
| 1057 |
|
| 1058 |
# Put passphrase back and do the stopping starting again, but |
| 1059 |
# without tangd running. This should try clevis but then fall |
| 1060 |
# back to asking for a passphrase. |
| 1061 |
|
| 1062 |
b.click(self.card_button("Encryption tokens", "Add passphrase")) |
| 1063 |
self.dialog({'passphrase': "foodeeboodeebar", |
| 1064 |
'passphrase2': "foodeeboodeebar"}) |
| 1065 |
if v1_pool: |
| 1066 |
b.wait_visible(self.card_desc("Encryption tokens", "Passphrase") + " button:contains('Remove'):not(:disabled)") |
| 1067 |
else: |
| 1068 |
b.wait_visible(self.card_row("Encryption tokens", location="passphrase")) |
| 1069 |
b.click(self.dropdown_toggle(row)) |
| 1070 |
b.wait_visible(self.dropdown_action("Remove") + ":not([disabled])") |
| 1071 |
b.click(self.dropdown_toggle(row)) |
| 1072 |
|
| 1073 |
m.execute(f"stratis pool stop {self.stop_type_opt} pool0") |
| 1074 |
tang_m.execute("systemctl stop tangd.socket") |
| 1075 |
b.click(self.card_button("Stratis pool", "Start")) |
| 1076 |
self.dialog_wait_open() |
| 1077 |
self.dialog_set_val("passphrase", "foobar") |
| 1078 |
self.dialog_cancel() |
| 1079 |
self.dialog_wait_close() |
| 1080 |
|
| 1081 |
# Finally start tang |
| 1082 |
tang_m.execute("systemctl start tangd.socket") |
| 1083 |
b.click(self.card_button("Stratis pool", "Start")) |
| 1084 |
b.wait_visible(self.card("Encrypted Stratis pool")) |
| 1085 |
|
| 1086 |
# Add a blockdevice. |
| 1087 |
|
| 1088 |
b.click(self.card_button("Encrypted Stratis pool", "Add block device")) |
| 1089 |
if v1_pool: |
| 1090 |
self.dialog({'disks': {dev_2: True}, 'pool_passphrase': "foodeeboodeebar"}) |
| 1091 |
else: |
| 1092 |
self.dialog({'disks': {dev_2: True}}) |
| 1093 |
|
| 1094 |
# Remove the keyserver and add it back |
| 1095 |
|
| 1096 |
if v1_pool: |
| 1097 |
b.click(self.card_desc("Encryption tokens", "Keyserver") + " button:contains('Remove')") |
| 1098 |
else: |
| 1099 |
self.click_dropdown(self.card_row("Encryption tokens", location="10.111.112.5"), "Remove") |
| 1100 |
self.confirm() |
| 1101 |
|
| 1102 |
if v1_pool: |
| 1103 |
b.wait_not_in_text(self.card_desc("Encryption tokens", "Keyserver"), "10.111.112.5") |
| 1104 |
else: |
| 1105 |
b.wait_not_present(self.card_row("Encryption tokens", location="10.111.112.5")) |
| 1106 |
|
| 1107 |
b.click(self.card_button("Encryption tokens", "Add keyserver")) |
| 1108 |
self.dialog_wait_open() |
| 1109 |
self.dialog_set_val("tang_url", "10.111.112.5") |
| 1110 |
self.dialog_set_val("pool_passphrase", "foodeeboodeebar") |
| 1111 |
self.dialog_apply() |
| 1112 |
b.wait_in_text("#dialog", "Check the key hash") |
| 1113 |
b.wait_in_text("#dialog", tang_m.execute("tang-show-keys").strip()) |
| 1114 |
self.dialog_apply() |
| 1115 |
with b.wait_timeout(60): |
| 1116 |
self.dialog_wait_close() |
| 1117 |
|
| 1118 |
if v1_pool: |
| 1119 |
b.wait_in_text(self.card_desc("Encryption tokens", "Keyserver"), "10.111.112.5") |
| 1120 |
else: |
| 1121 |
b.wait_visible(self.card_row("Encryption tokens", location="10.111.112.5")) |
| 1122 |
|
| 1123 |
# Remove the keyserver and add it back a second time, but try |
| 1124 |
# first with the wrong passphrase already in the keyring |
| 1125 |
|
| 1126 |
if v1_pool: |
| 1127 |
b.click(self.card_desc("Encryption tokens", "Keyserver") + " button:contains('Remove')") |
| 1128 |
else: |
| 1129 |
self.click_dropdown(self.card_row("Encryption tokens", location="10.111.112.5"), "Remove") |
| 1130 |
self.confirm() |
| 1131 |
|
| 1132 |
create_pool_key(m, "pool0", "foobar") |
| 1133 |
b.click(self.card_button("Encryption tokens", "Add keyserver")) |
| 1134 |
self.dialog_wait_open() |
| 1135 |
self.dialog_set_val("tang_url", "10.111.112.5") |
| 1136 |
self.dialog_apply() |
| 1137 |
b.wait_in_text("#dialog", "Check the key hash") |
| 1138 |
b.wait_in_text("#dialog", tang_m.execute("tang-show-keys").strip()) |
| 1139 |
self.dialog_apply() |
| 1140 |
with b.wait_timeout(60): |
| 1141 |
b.wait_in_text('#dialog', "Command failed") |
| 1142 |
m.execute("stratis key unset pool0") |
| 1143 |
create_pool_key(m, "pool0", "foodeeboodeebar") |
| 1144 |
self.dialog_apply() |
| 1145 |
with b.wait_timeout(60): |
| 1146 |
self.dialog_wait_close() |
| 1147 |
|
| 1148 |
if v1_pool: |
| 1149 |
b.wait_in_text(self.card_desc("Encryption tokens", "Keyserver"), "10.111.112.5") |
| 1150 |
else: |
| 1151 |
b.wait_visible(self.card_row("Encryption tokens", location="10.111.112.5")) |
| 1152 |
|
| 1153 |
m.execute("stratis key unset pool0") |
| 1154 |
|
| 1155 |
# Create a mounted filesystem and reboot. |
| 1156 |
|
| 1157 |
b.click(self.card_button("Stratis filesystems", "Create new filesystem")) |
| 1158 |
self.dialog({'name': 'fsys1', |
| 1159 |
'mount_point': '/run/fsys1'}) |
| 1160 |
b.wait_text(self.card_row_col("Stratis filesystems", 1, 1), "fsys1") |
| 1161 |
b.wait_text(self.card_row_col("Stratis filesystems", 1, 3), "/run/fsys1") |
| 1162 |
self.reboot() |
| 1163 |
m.start_cockpit() |
| 1164 |
b.relogin() |
| 1165 |
b.enter_page("/storage") |
| 1166 |
b.wait_visible(self.card("Stratis pool")) |
| 1167 |
b.wait_text(self.card_row_col("Stratis filesystems", 1, 1), "fsys1") # should be started after boot |
| 1168 |
b.wait_text(self.card_row_col("Stratis filesystems", 1, 3), "/run/fsys1") # should be mounted after boot |
| 1169 |
|
| 1170 |
@testlib.skipImage("Stratis too old for legacy tests", *V1_POOL_IMAGES) |
| 1171 |
def testBasicLegacy(self): |
| 1172 |
self.testBasic(legacy=True) |
| 1173 |
|
| 1174 |
@testlib.skipImage("Stratis too old", *V1_POOL_IMAGES) |
| 1175 |
def testEncryptionTokens(self): |
| 1176 |
m = self.machine |
| 1177 |
b = self.browser |
| 1178 |
|
| 1179 |
tang_m = self.machines["tang"] |
| 1180 |
tang_m.execute("systemctl start tangd.socket") |
| 1181 |
tang_m.execute("firewall-cmd --add-port 80/tcp") |
| 1182 |
|
| 1183 |
self.login_and_go("/storage") |
| 1184 |
|
| 1185 |
dev_1 = "/dev/sda" |
| 1186 |
m.add_disk("4G", serial="DISK1") |
| 1187 |
b.wait_visible(self.card_row("Storage", name=dev_1)) |
| 1188 |
|
| 1189 |
passphrase = "foodeeboodeebar" |
| 1190 |
passphrase2 = "boodeefoodeebar" |
| 1191 |
|
| 1192 |
# Create a pool with a passphrase |
| 1193 |
|
| 1194 |
self.dialog_open_with_retry(trigger=lambda: self.click_devices_dropdown("Create Stratis pool"), |
| 1195 |
expect=lambda: (self.dialog_is_present('disks', dev_1) and |
| 1196 |
self.dialog_check({"name": "pool0"}))) |
| 1197 |
self.dialog_set_val("encrypt_pass.on", val=True) |
| 1198 |
self.dialog_set_val("passphrase", passphrase) |
| 1199 |
self.dialog_set_val("passphrase2", passphrase) |
| 1200 |
self.dialog_set_val("disks", {dev_1: True}) |
| 1201 |
self.dialog_apply() |
| 1202 |
self.dialog_wait_close() |
| 1203 |
|
| 1204 |
self.click_card_row("Storage", name="pool0") |
| 1205 |
b.wait_visible(self.card("Encrypted Stratis pool")) |
| 1206 |
|
| 1207 |
# Adding a token needs the existing passphrase. |
| 1208 |
|
| 1209 |
b.click(self.card_button("Encryption tokens", "Add keyserver")) |
| 1210 |
self.dialog_wait_open() |
| 1211 |
b.wait_visible(self.dialog_field("pool_passphrase")) |
| 1212 |
b.wait_in_text("#dialog", "Please provide an existing pool passphrase.") |
| 1213 |
b.assert_pixels("#dialog", "dialog") |
| 1214 |
self.dialog_cancel() |
| 1215 |
self.dialog_wait_close() |
| 1216 |
|
| 1217 |
# When the only passphrase is already in the keyring, it must |
| 1218 |
# work. |
| 1219 |
|
| 1220 |
create_pool_key(m, "pool0", passphrase) |
| 1221 |
b.click(self.card_button("Encryption tokens", "Add keyserver")) |
| 1222 |
self.dialog_wait_open() |
| 1223 |
b.wait_in_text("#dialog", "At least one of the non-interactive unlock methods must work.") |
| 1224 |
b.wait_not_present(self.dialog_field("pool_passphrase")) |
| 1225 |
self.dialog_set_val("tang_url", "10.111.112.5") |
| 1226 |
self.dialog_apply() |
| 1227 |
b.wait_in_text("#dialog", "Check the key hash") |
| 1228 |
self.dialog_apply() |
| 1229 |
with b.wait_timeout(60): |
| 1230 |
self.dialog_wait_close() |
| 1231 |
|
| 1232 |
# A single keyserver will be mentioned explicitly |
| 1233 |
|
| 1234 |
m.execute("stratis key unset pool0") |
| 1235 |
b.click(self.card_button("Encryption tokens", "Add passphrase")) |
| 1236 |
self.dialog_wait_open() |
| 1237 |
self.dialog_set_val("passphrase", passphrase2) |
| 1238 |
self.dialog_set_val("passphrase2", passphrase2) |
| 1239 |
b.wait_visible(self.dialog_field("pool_passphrase")) |
| 1240 |
b.wait_in_text("#dialog", "If the keyserver at 10.111.112.5 is not reachable, you can provide an existing passphrase.") |
| 1241 |
self.dialog_apply() |
| 1242 |
with b.wait_timeout(60): |
| 1243 |
self.dialog_wait_close() |
| 1244 |
|
| 1245 |
# When only one passphrase is in the keyring, the other one can be provided. |
| 1246 |
|
| 1247 |
create_pool_key(m, "pool0", passphrase) |
| 1248 |
b.click(self.card_button("Encryption tokens", "Add keyserver")) |
| 1249 |
self.dialog_wait_open() |
| 1250 |
b.wait_visible(self.dialog_field("pool_passphrase")) |
| 1251 |
b.wait_in_text("#dialog", "If none of the non-interactive unlock methods works, you can provide an existing passphrase.") |
| 1252 |
self.dialog_cancel() |
| 1253 |
self.dialog_wait_close() |
| 1254 |
|
| 1255 |
# When there is only one tang, it is mentioned explicitly and it must work |
| 1256 |
|
| 1257 |
m.execute("stratis key unset pool0") |
| 1258 |
self.click_dropdown(self.card_row("Encryption tokens", index=1), "Remove") |
| 1259 |
self.confirm() |
| 1260 |
self.click_dropdown(self.card_row("Encryption tokens", location="passphrase"), "Remove") |
| 1261 |
self.confirm() |
| 1262 |
b.click(self.card_button("Encryption tokens", "Add keyserver")) |
| 1263 |
self.dialog_wait_open() |
| 1264 |
b.wait_in_text("#dialog", "The keyserver at 10.111.112.5 must be reachable.") |
| 1265 |
b.wait_not_present(self.dialog_field("pool_passphrase")) |
| 1266 |
self.dialog_set_val("tang_url", "10.111.112.5") |
| 1267 |
self.dialog_apply() |
| 1268 |
b.wait_in_text("#dialog", "Check the key hash") |
| 1269 |
self.dialog_apply() |
| 1270 |
with b.wait_timeout(60): |
| 1271 |
self.dialog_wait_close() |
| 1272 |
|
| 1273 |
# With two, one must work |
| 1274 |
|
| 1275 |
b.click(self.card_button("Encryption tokens", "Add passphrase")) |
| 1276 |
self.dialog_wait_open() |
| 1277 |
self.dialog_set_val("passphrase", passphrase) |
| 1278 |
self.dialog_set_val("passphrase2", passphrase) |
| 1279 |
b.wait_in_text("#dialog", "At least one keyserver must be reachable.") |
| 1280 |
b.wait_not_present(self.dialog_field("pool_passphrase")) |
| 1281 |
self.dialog_apply() |
| 1282 |
with b.wait_timeout(60): |
| 1283 |
self.dialog_wait_close() |
| 1284 |
|
| 1285 |
# Add TPM2 while letting Tang unlock the tokens for us |
| 1286 |
|
| 1287 |
m.execute("stratis pool bind tpm2 pool0") |
| 1288 |
b.wait_visible(self.card_row("Encryption tokens", location="tpm2")) |
| 1289 |
|
| 1290 |
b.assert_pixels(self.card("Encryption tokens"), "tokens") |
| 1291 |
|
| 1292 |
# Remove TPM2 with Cockpit |
| 1293 |
|
| 1294 |
self.click_dropdown(self.card_row("Encryption tokens", location="tpm2"), "Remove") |
| 1295 |
self.confirm() |
| 1296 |
|
| 1297 |
# Change the passphrase |
| 1298 |
|
| 1299 |
self.click_dropdown(self.card_row("Encryption tokens", location="passphrase"), "Change") |
| 1300 |
self.dialog({'old_passphrase': passphrase, |
| 1301 |
'new_passphrase': passphrase2, |
| 1302 |
'new_passphrase2': passphrase2}) |
| 1303 |
|
| 1304 |
|
| 1305 |
if __name__ == '__main__': |
| 1306 |
testlib.test_main() |