Replies: 4 comments 4 replies
-
unit tests are by definition meant to test the smallest unit of code so you're better off mocking your use of ZFS in your tests. edit: I realise not everyone understands what mocking is; https://trepo.tuni.fi/bitstream/handle/123456789/24806/%C3%85hman.pdf?sequence=4&isAllowed=y a few pages in you'll find the table of contents of how you mock kernel level code. you essentially fake the existence of the kernel and return whatever type of data structure the calling code requires through stub methods. it's a handy way to run unit tests on the actual kernel without having to boot it. and for userland code, |
Beta Was this translation helpful? Give feedback.
-
Thank you, bghira! I'm not actually in a position to mock kernel code but I will read that presentation. I'm running a series of unit and functional tests against ZFS, I'm not testing ZFS code or other kernel code at this time. I'd like to be able to move the testing I run for pre-commit into a container-like environment and I think WSL is a great target for that if I can get it to work. So the problem I'm looking for help with isn't the testing side, so much as on how to deploy a Ubuntu system with a statically linked kernel that can run ZFS in WSL. The showstopper problem is that I can't create a zpool. It is probably just an issue with configuration, but perhaps it is just not possible? These things are working:
These things are not working:
What I would see as a good outcome of this discussion is to understand what I'm doing wrong in configuration or deployment, and then if feasible add an error check that catches the problem and throws a more helpful error message. |
Beta Was this translation helpful? Give feedback.
-
The loadable kernel module version is actually making more progress than I realized. Here is some strace output: Open up the target as a block device (it's a file): openat(AT_FDCWD, "/root/vdev1.img", O_RDONLY|O_DIRECT|O_CLOEXEC) = 6
ioctl(6, BLKSSZGET, 0x7fff7b84d80c) = -1 ENOTTY (Inappropriate ioctl for device)
close(6) = 0
stat("/root/vdev1.img", {st_mode=S_IFREG|0644, st_size=73728000, ...}) = 0 Now it will attempt to access as a regular file: openat(AT_FDCWD, "/root/vdev1.img", O_RDONLY|O_DIRECT) = 6
ioctl(6, SG_IO, {interface_id='S', dxfer_direction=SG_DXFER_FROM_DEV, cmd_len=6, cmdp="\x12\x00\x00\x00\x60\x00", mx_sb_len=32,
iovec_count=0, dxfer_len=96, timeout=10, flags=0, dxferp="\x1d\x80\x61\x4b\x49\x56\x00\x00\x80\xdf\x5b\x4c\x49\x56\x00\x00\x30\xd9\x84\x7b\xff\x7f\x00\x00\x78\xef\x70\x63\x70\x7f\x00\x00"..., status=0, masked_status=0, msg_status=0, sb_len_wr=0, sbp="", host_status=0, driver_status=0, resid=0, duration=0, info=0}) = -1 ENOTTY (Inappropriate ioctl for device)
close(6) = 0
openat(AT_FDCWD, "/root/vdev1.img", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0644, st_size=73728000, ...}) = 0
mmap(NULL, 466944, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7062aeb000
sched_getparam(137, [0]) = 0
sched_getscheduler(137) = 0 (SCHED_OTHER)
rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], [], 8) = 0
mmap(NULL, 37056, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f7062ae1000
mprotect(0x7f7062ae2000, 32960, PROT_READ|PROT_WRITE) = 0
clone(child_stack=0x7f7062ae6ff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tid=[138], tls=0x7f7062ae97c0, child_tidptr=0x7f7062ae9a90) = 138
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
futex(0x7f7063036200, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7fff7b84c3a8, FUTEX_WAIT_PRIVATE, 4, NULL) = -1 EAGAIN (Resource temporarily unavailable)
munmap(0x7f7062aeb000, 466944) = 0
close(6) = 0
openat(AT_FDCWD, "/testpool", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory) trimmed out several missed loads of locale messages openat(AT_FDCWD, "/usr/share/locale-langpack/C/LC_MESSAGES/zfs-linux-user.mo", O_RDONLY) = -1 ENOENT (No such file or directory)ioctl(3, _IOC(_IOC_NONE, 0x5a, 0, 0), 0x7fff7b84b1d0) = -1 ENOENT (No such file or directory)
write(2, "cannot create 'testpool': no suc"..., 50cannot create 'testpool': no such pool or dataset
) = 50
close(3) = 0
close(4) = 0
close(5) = 0
exit_group(1) = ?
+++ exited with 1 +++ |
Beta Was this translation helpful? Give feedback.
-
I used exactly the same build script I used to build on WSL2 Ubuntu 20.04 to build on Hyper-V Ubuntu 20.04 and everything worked fine. |
Beta Was this translation helpful? Give feedback.
-
I'm trying to build a statically linked kernel for Windows 10 WSL, following a pattern I've seen successfully used here. I'm building from linux 5.13.9 and zfs 2.1.0.
The kernel builds fine as a built-in, and I can also build the loadable modules, but I think I am missing some system element to activate the module. For example, on a reference Ubuntu 20.04 with zfs 0.8.3-3 system, I can see that the (dynamically loaded) modules are operating:
# ls /sys/module/zfs coresize features.pool initsize notes properties.dataset refcnt srcversion uevent features.kernel holders initstate parameters properties.pool sections taint version
(version info for my reference system):
# zpool --version zfs-0.8.3-3 zfs-kmod-0.8.3-3
On my Windows 10 WSL session the same module:
# ls /sys/module/zfs parameters uevent version
(version info for the statically linked WSL environment):
# zpool --version zfs-2.1.0-1 zfs-kmod-2.1.0-1
I tried various things, the biggest stumbling block of all is that I can't create a zpool:
Is there some guide for configuring the environment for a non-ZFS-root scenario? I can't/won't have ZFS root volumes in this environment, at least not on this build. My sole purpose for even trying this is for a testing environment. I'd like to be able to start up a WSL environment, run several unit tests for a code base that uses ZFS, and then shut down, no data to be retained.
Thank you!
Update:
The zfs module is definitely being loaded at kernel boot because it printk's:
2# dmesg | grep ZFS [ 2.470483] ZFS: Loaded module v2.1.0-1, ZFS pool version 5000, ZFS filesystem version 5
Update:
ztest seems to run:
Beta Was this translation helpful? Give feedback.
All reactions