Merge ~ahasenack/ubuntu/+source/autofs:cosmic-autofs-dep8-1677751 into ubuntu/+source/autofs:ubuntu/devel

Proposed by Andreas Hasenack
Status: Merged
Merge reported by: Andreas Hasenack
Merged at revision: 356af4048fd325f9db21f020aeea283f6b5bc792
Proposed branch: ~ahasenack/ubuntu/+source/autofs:cosmic-autofs-dep8-1677751
Merge into: ubuntu/+source/autofs:ubuntu/devel
Diff against target: 201 lines (+175/-0)
4 files modified
debian/changelog (+8/-0)
debian/tests/control (+7/-0)
debian/tests/nfs-mount (+25/-0)
debian/tests/smb-mount (+135/-0)
Reviewer Review Type Date Requested Status
Christian Ehrhardt  (community) Approve
Canonical Server Pending
Review via email: mp+347853@code.launchpad.net

Description of the change

Given the recent surprises I had with autofs not working and segfaulting, I thought it's time to add some dep8 tests.

This branch adds tests for samba (authenticated and anonymous) and nfs. You can check the branch out and run with autopkgtest. I run like this:
autopkgtest -o ../dep8-output -U -s --apt-pocket=proposed ./ -- qemu /var/lib/adt-images/autopkgtest-cosmic-amd64.img

The full run takes about 10min.

To post a comment you must log in.
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

First of all - I totally like it.
Thanks for holding up the spirit of bugfixing and improvement in these busy times!

Some comments inline already - I'm still testing the code ...

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Tests all look good and succeed.

+1 from a Reviews POV.

Now that Bileto is working again I'd recommend to test it there to get full LP+Arch coverage before an upload.

review: Approve
356af40... by Andreas Hasenack

Be a bit more generous with timeouts

Revision history for this message
Andreas Hasenack (ahasenack) :
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

This is blocked in bileto now: https://bileto.ubuntu.com/#/ticket/3293

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

>
> > + if ! testparm -s 2>&1 | grep -qE "^\[${share}\]"; then
> > + echo "Adding [${share}] share"
> > + cat >> /etc/samba/smb.conf <<EOFEOF
> > +[${share}]
>
> Indentation isn't important, it's just aesthetic. What do you mean by
> inline, just a bunch of echo's instead of cat? Or both [${share}] and the
> lines below it in column 1?
>

All moved from column 1 to the column of "cat"+4
But this is style/opinion-only, so only follow if you prefer that as well.
Keep it as-is otherwise please

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

FYI: I kicked the tests in the ticket, if it works (as it did two weeks ago) we should later on have results

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Check the ouput of all tests on all arches, and if you are ok please go on with the upload.
Since we know it is good now you can also suggest to Debian to help them as well.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

The armhf tests were skipped because there is no vm for it:

smb-mount SKIP Test requires machine-level isolation but testbed does not provide that
nfs-mount SKIP Test requires machine-level isolation but testbed does not provide that

Is it expected to have no vm for armhf? What's the alternative?

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Looks like that's the way it is on armh :)

Please tag and upload, thanks

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 5efc4bf..db1546d 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,11 @@
6+autofs (5.1.2-3ubuntu2) cosmic; urgency=medium
7+
8+ * Add DEP8 tests (LP: #1677751):
9+ - d/tests/control, d/tests/smb-mount: smb automount DEP8 test
10+ - d/tests/control, d/tests/nfs-mount: nfs automount DEP8 test
11+
12+ -- Andreas Hasenack <andreas@canonical.com> Tue, 12 Jun 2018 17:35:31 -0300
13+
14 autofs (5.1.2-3ubuntu1) cosmic; urgency=medium
15
16 * Merge with Debian unstable (LP: #1775232). Remaining changes:
17diff --git a/debian/tests/control b/debian/tests/control
18new file mode 100644
19index 0000000..0058590
20--- /dev/null
21+++ b/debian/tests/control
22@@ -0,0 +1,7 @@
23+Tests: smb-mount
24+Depends: @, cifs-utils, samba, smbclient
25+Restrictions: isolation-machine, needs-root, allow-stderr
26+
27+Tests: nfs-mount
28+Depends: @, nfs-common, nfs-server
29+Restrictions: isolation-machine, needs-root, allow-stderr
30diff --git a/debian/tests/nfs-mount b/debian/tests/nfs-mount
31new file mode 100644
32index 0000000..f3ed7c1
33--- /dev/null
34+++ b/debian/tests/nfs-mount
35@@ -0,0 +1,25 @@
36+#!/bin/sh
37+
38+set -x
39+set -e
40+
41+now=$(date --utc)
42+result=0
43+
44+echo "creating /nfspub nfs export"
45+mkdir -p /nfspub
46+echo "${now} - This is an nfs public export" > /nfspub/nfs-public.txt
47+echo "/nfspub *(ro,no_subtree_check)" > /etc/exports
48+exportfs -avr
49+
50+echo "Configuring automount for nfs on /net"
51+mkdir -p /etc/auto.master.d
52+echo '/net -hosts -intr,soft --timeout=180' > /etc/auto.master.d/net.autofs
53+systemctl restart autofs
54+
55+echo "Accessing the autofs mountpoint"
56+timeout 30s grep -qE "${now}.*nfs public" /net/localhost/nfspub/nfs-public.txt || result=$?
57+if [ "$result" -ne "0" ]; then
58+ echo "test failed, couldn't access /net/localhost/nfspub/nfs-public.txt"
59+ exit ${result}
60+fi
61diff --git a/debian/tests/smb-mount b/debian/tests/smb-mount
62new file mode 100644
63index 0000000..b9b685b
64--- /dev/null
65+++ b/debian/tests/smb-mount
66@@ -0,0 +1,135 @@
67+#!/bin/sh
68+
69+set -x
70+
71+add_smb_share() {
72+ local share="$1"
73+ local sharepath="$2"
74+ local public="$3"
75+
76+ if ! testparm -s 2>&1 | grep -qE "^\[${share}\]"; then
77+ echo "Adding [${share}] share"
78+ cat >> /etc/samba/smb.conf <<EOFEOF
79+[${share}]
80+ path = ${sharepath}
81+ read only = no
82+EOFEOF
83+ if [ "${public}" = "yes" ]; then
84+ cat >> /etc/samba/smb.conf <<EOFEOF
85+ guest ok = yes
86+EOFEOF
87+ else
88+ cat >> /etc/samba/smb.conf <<EOFEOF
89+ guest ok = no
90+EOFEOF
91+ fi
92+ systemctl reload smbd.service
93+ else
94+ echo "No need to add private [${share}] share, continuing."
95+ fi
96+}
97+
98+create_user() {
99+ local username="$1"
100+ local password="$2"
101+
102+ useradd -m "$username"
103+ echo "Setting samba password for the ${username} user"
104+ echo "${password}\n${password}" | smbpasswd -s -a ${username}
105+}
106+
107+
108+now=$(date --utc)
109+result=0
110+# Remount everything in case someone is running this interactively
111+# and mounts from previous runs and previous usernames are still lingering
112+systemctl restart autofs
113+
114+echo "Setting up a public samba share in /pub"
115+mkdir -p /pub
116+echo "${now} - This is the public samba share." > /pub/hello-public.txt
117+add_smb_share pub /pub yes
118+
119+echo "Setting up a private samba share in /private"
120+mkdir -p /private
121+echo "${now} - This is the private samba share." > /private/hello-private.txt
122+add_smb_share private /private no
123+
124+username="smbtest$$"
125+password="$$"
126+echo "Creating a local test user called ${username}"
127+create_user "${username}" "${password}"
128+
129+echo "Setting up autofs credentials for the private share"
130+mkdir -m 0700 -p /etc/creds
131+cat > /etc/creds/localhost <<EOFEOF
132+username=${username}
133+password=${password}
134+domain=WORKGROUP
135+EOFEOF
136+chmod 0600 /etc/creds/localhost
137+
138+if ! grep -qE "^/cifs" /etc/auto.master; then
139+ echo "Configuring autofs for the /cifs mountpoint"
140+ echo "/cifs /etc/auto.smb --timeout=180" >> /etc/auto.master
141+ systemctl restart autofs
142+fi
143+
144+# We use a trick here. By storing the credentials in /etc/creds/localhost,
145+# that means the autofs key is "localhost", and the credentials will be used
146+# when accessing /cifs/localhost.
147+# If instead we access /cifs/127.0.0.1, since there is no corresponding entry in
148+# /etc/creds, that access will be as a guest, i.e., with no credentials
149+echo "Testing authenticated share automount"
150+timeout 30s grep -qE "${now}.*private" /cifs/localhost/private/hello-private.txt || result=$?
151+if [ "$result" -ne "0" ]; then
152+ echo "test failed"
153+ exit ${result}
154+fi
155+
156+echo "Confirming with smbstatus that an authenticated connection was used"
157+output=$(smbstatus 2>&1)
158+echo "${output}" | grep -q "${username}" || result=$?
159+if [ "${result}" -ne "0" ]; then
160+ echo "test failed"
161+ echo "smbstatus output:"
162+ echo "${smbstatus}"
163+ exit "${result}"
164+fi
165+
166+echo "Confirming with mount -t cifs that the filesystem is mounted with authentication"
167+output=$(mount -t cifs 2>&1)
168+echo "${output}" | grep -qE "on /cifs/localhost/private.*username=${username}" || result=$?
169+if [ "${result}" -ne "0" ]; then
170+ echo "test failed"
171+ echo "mount -t cifs output:"
172+ echo "${output}"
173+ exit ${result}
174+fi
175+
176+echo "Testing unauthenticated share automount"
177+timeout 30s grep -q "${now}.*public" /cifs/127.0.0.1/pub/hello-public.txt || result=$?
178+if [ "$result" -ne "0" ]; then
179+ echo "test failed"
180+ exit ${result}
181+fi
182+
183+echo "Confirming with smbstatus that a guest connection was used"
184+output=$(smbstatus 2>&1)
185+echo "${output}" | grep -q nobody || result=$?
186+if [ "${result}" -ne "0" ]; then
187+ echo "test failed"
188+ echo "smbstatus output:"
189+ echo "${smbstatus}"
190+ exit ${result}
191+fi
192+
193+echo "Confirming with mount -t cifs that the filesystem is mounted without authentication"
194+output=$(mount -t cifs 2>&1)
195+echo "${output}" | grep -qE "on /cifs/127.0.0.1/pub.*sec=none" || result=$?
196+if [ "${result}" -ne "0" ]; then
197+ echo "test failed"
198+ echo "mount -t cifs output:"
199+ echo "${output}"
200+ exit ${result}
201+fi

Subscribers

People subscribed via source and target branches