Bug#929728: systemd autopkgtest 'storage' fails adding/rmmoding scsi_debug

2019-06-27 Thread Dan Streetman
ack - let me redo this a bit and open a MR in salsa.

On Thu, Jun 27, 2019 at 10:45 AM Martin Pitt  wrote:
>
> Hello,
>
> rmmod failure due to "busy" is annoying indeed, and a bit hard to fix, thus
> your approach with removing the individual hosts instead seems fine.
>
> If the module isn't available though, I'd consider this a bad testbed.
> autopkgtest's testbed VM construction scripts (VM, container, cloud) all
> install the linux-image-extra bits to make sure that the module exists. If 
> this
> silently gets skipped, it could then be that this functionality just never 
> gets
> tested, so I'm not too happy about that part.
>
> Thanks,
>
> Martin



Bug#929728: systemd autopkgtest 'storage' fails adding/rmmoding scsi_debug

2019-06-27 Thread Martin Pitt
Hello,

rmmod failure due to "busy" is annoying indeed, and a bit hard to fix, thus
your approach with removing the individual hosts instead seems fine.

If the module isn't available though, I'd consider this a bad testbed.
autopkgtest's testbed VM construction scripts (VM, container, cloud) all
install the linux-image-extra bits to make sure that the module exists. If this
silently gets skipped, it could then be that this functionality just never gets
tested, so I'm not too happy about that part.

Thanks,

Martin



Bug#929728: systemd autopkgtest 'storage' fails adding/rmmoding scsi_debug

2019-06-05 Thread Michael Biebl
Hi Dan

Am 29.05.19 um 18:02 schrieb Dan Streetman:
> Package: systemd
> Version: 241-5
> Severity: normal
> Tags: patch
> User: ubuntu-de...@lists.ubuntu.com
> Usertags: origin-ubuntu eoan ubuntu-patch
> 
> Dear Maintainer,
> 
> 'storage' test fails on some archs/releases trying to modprobe and/or rmmod 
> scsi_debug.
> 
> -- Package-specific info:
> 
> 
>   * d/t/storage:
> - fix handling of scsi_debug module, test drives (LP: #1829347)
> 

If you submit a merge request via
https://salsa.debian.org/systemd-team/systemd it makes it a bit easier
to review and apply the changes.


Since Martin is our autopkgtest expert I'd prefer if he reviews this patch.

Regards,
Michael

-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?



signature.asc
Description: OpenPGP digital signature


Bug#929728: systemd autopkgtest 'storage' fails adding/rmmoding scsi_debug

2019-05-29 Thread Dan Streetman
On Wed, May 29, 2019 at 12:08 PM Michael Biebl  wrote:
>
> Am 29.05.19 um 18:02 schrieb Dan Streetman:
> > Package: systemd
> > Version: 241-5
> > Severity: normal
> > Tags: patch
> > User: ubuntu-de...@lists.ubuntu.com
> > Usertags: origin-ubuntu eoan ubuntu-patch
> >
> > Dear Maintainer,
> >
> > 'storage' test fails on some archs/releases trying to modprobe and/or rmmod 
> > scsi_debug.
> >
>
> I've never seen this failure. Can you eloborate on the conditions when
> this happens?

a couple examples - search for scsi_debug:
https://objectstorage.prodstack4-5.canonical.com/v1/AUTH_77e2ada1e7a84929a74ba3b87153c0ac/autopkgtest-eoan/eoan/amd64/s/systemd/20190529_064803_7dbf0@/log.gz
https://objectstorage.prodstack4-5.canonical.com/v1/AUTH_77e2ada1e7a84929a74ba3b87153c0ac/autopkgtest-cosmic/cosmic/amd64/s/systemd/20190216_115842_cf8d3@/log.gz



>
>
> --
> Why is it that all of the instruments seeking intelligent life in the
> universe are pointed away from Earth?
>



Bug#929728: systemd autopkgtest 'storage' fails adding/rmmoding scsi_debug

2019-05-29 Thread Michael Biebl
Am 29.05.19 um 18:02 schrieb Dan Streetman:
> Package: systemd
> Version: 241-5
> Severity: normal
> Tags: patch
> User: ubuntu-de...@lists.ubuntu.com
> Usertags: origin-ubuntu eoan ubuntu-patch
> 
> Dear Maintainer,
> 
> 'storage' test fails on some archs/releases trying to modprobe and/or rmmod 
> scsi_debug.
> 

I've never seen this failure. Can you eloborate on the conditions when
this happens?


-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?



signature.asc
Description: OpenPGP digital signature


Bug#929728: systemd autopkgtest 'storage' fails adding/rmmoding scsi_debug

2019-05-29 Thread Dan Streetman
Package: systemd
Version: 241-5
Severity: normal
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu eoan ubuntu-patch

Dear Maintainer,

'storage' test fails on some archs/releases trying to modprobe and/or rmmod 
scsi_debug.

-- Package-specific info:


  * d/t/storage:
- fix handling of scsi_debug module, test drives (LP: #1829347)


Thanks for considering the patch.


-- System Information:
Debian Release: buster/sid
  APT prefers disco-updates
  APT policy: (500, 'disco-updates'), (500, 'disco-security'), (500, 'disco'), 
(100, 'disco-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.0.0-13-generic (SMP w/24 CPU cores)
Kernel taint flags: TAINT_WARN
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US 
(charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages systemd is related to:
pn  dracut   
ii  initramfs-tools  0.131ubuntu19
ii  udev 240-6ubuntu5
diff -Nru systemd-241/debian/tests/storage systemd-241/debian/tests/storage
--- systemd-241/debian/tests/storage2019-05-24 16:58:59.0 -0400
+++ systemd-241/debian/tests/storage2019-05-29 11:52:19.0 -0400
@@ -12,40 +12,69 @@
 from glob import glob
 
 
-@unittest.skipIf(os.path.isdir('/sys/module/scsi_debug'),
- 'The scsi_debug module is already loaded')
+SCSI_DEBUG_DIR='/sys/bus/pseudo/drivers/scsi_debug'
+
 class FakeDriveTestBase(unittest.TestCase):
 @classmethod
 def setUpClass(klass):
-# create a fake SCSI hard drive
-subprocess.check_call(['modprobe', 'scsi_debug', 'dev_size_mb=32'])
+if not os.path.isdir(SCSI_DEBUG_DIR):
+subprocess.call(['modprobe', 'scsi_debug', 'dev_size_mb=32'],
+stderr=subprocess.DEVNULL)
+# if still not available, we can't run any of our tests
+if not os.path.isdir(SCSI_DEBUG_DIR):
+klass.skipTest('scsi_debug module not loaded')
+
+def setUp(self):
+# remove any existing drives, then add back one for us to use
+self.remove_scsi_debug_drives()
+with open(os.path.join(SCSI_DEBUG_DIR, 'add_host'), 'r+') as f:
+print('Adding scsi_debug drive')
+f.write('1')
+for wait in range(10):
+f.seek(0)
+if f.read().strip() == '1':
+break
+time.sleep(0.1)
+else:
+self.skipTest('Could not add scsi_debug drive to test')
 # wait until drive got created
 sys_dirs = []
-while not sys_dirs:
-sys_dirs = 
glob('/sys/bus/pseudo/drivers/scsi_debug/adapter*/host*/target*/*:*/block')
+for tries in range(100):
+sys_dirs = glob(os.path.join(SCSI_DEBUG_DIR,
+ 'adapter*/host*/target*/*:*/block'))
+if sys_dirs:
+break
 time.sleep(0.1)
-assert len(sys_dirs) == 1
+if len(sys_dirs) < 1:
+self.skipTest('could not find scsi_debug block device')
+elif len(sys_dirs) > 1:
+self.skipTest('too many scsi_debug block devices (%s)' % 
len(sys_dirs))
 devs = os.listdir(sys_dirs[0])
 assert len(devs) == 1
-klass.device = '/dev/' + devs[0]
-
-@classmethod
-def tearDownClass(klass):
-# create a fake SCSI hard drive
-subprocess.check_call(['rmmod', 'scsi_debug'])
+self.device = '/dev/' + devs[0]
 
 def tearDown(self):
-# clear drive
-with open(self.device, 'wb') as f:
-block = b'0' * 1048576
-try:
-while True:
-f.write(block)
-except OSError:
-pass
+self.remove_scsi_debug_drives()
 subprocess.check_call(['udevadm', 'settle'])
 subprocess.check_call(['systemctl', 'daemon-reload'])
 
+def remove_scsi_debug_drives(self):
+with open(os.path.join(SCSI_DEBUG_DIR, 'add_host'), 'r+') as f:
+n = f.read().strip()
+f.seek(0)
+if n == '0':
+return
+print('Removing %s scsi_debug test drive(s)' % n)
+f.write('-%s' % n)
+for wait in range(50):
+f.seek(0)
+n = f.read().strip()
+if n == '0':
+break
+time.sleep(0.1)
+else:
+self.skipTest('Could not remove %s scsi_debug drives' % n)
+
 
 class CryptsetupTest(FakeDriveTestBase):
 def setUp(self):
@@ -215,6 +244,7 @@
 self.format_luks()
 with open('/etc/crypttab', 'w') as f:
 f.write('%s %s none luks,tmp\n' % (self.plaintext_name, 
self.device))
+self.apply('cryptsetup.target')
 
 mountpoint = '/run/crypt1.systemdtest'