Merge ~smoser/ubuntu/+source/open-iscsi:bug/1715468-test-support-systemd-resolved into ~usd-import-team/ubuntu/+source/open-iscsi:ubuntu/devel

Proposed by Scott Moser on 2017-09-06
Status: Merged
Merge reported by: ChristianEhrhardt
Merged at revision: ad9e6fc6359cabb1930616d2f27d06eac52d2513
Proposed branch: ~smoser/ubuntu/+source/open-iscsi:bug/1715468-test-support-systemd-resolved
Merge into: ~usd-import-team/ubuntu/+source/open-iscsi:ubuntu/devel
Diff against target: 226 lines (+98/-27)
4 files modified
debian/changelog (+8/-0)
debian/tests/README-boot-test.md (+2/-2)
debian/tests/patch-image (+21/-3)
debian/tests/test-open-iscsi.py (+67/-22)
Reviewer Review Type Date Requested Status
ChristianEhrhardt 2017-09-06 Approve on 2017-09-11
Canonical Server Team 2017-09-07 Pending
Review via email: mp+330315@code.launchpad.net

Description of the Change

Change open-icsi's test to support checking systemd-resolved for dns info.

open-iscsi has a test case where it boots a system off a read-only iscsi
root device. It verifies the system starts up and shuts down successfully.
It also verifies that the dns 'search' and 'nameserver' entries provided
by the dhcp server are used by the system.

In the past, it did this just by reading asserting those values
were in /etc/resolv.conf. The change made was to also support reading
output of 'systemd-resolved --status'.

The text will still fail in current artful because of bug 1713803.

To post a comment you must log in.
Scott Moser (smoser) wrote :

Note that this is still failing at the moment, as there is no solution for
 https://bugs.launchpad.net/ubuntu/+source/initramfs-tools/+bug/1713803

but that will be fixed separately.

we currently get a failure like this:

======================================================================
FAIL: test_tgt_boot (__main__.CloudImageTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "debian/tests/test-open-iscsi.py", line 287, in test_tgt_boot
    (dns_addr, resolve_status)))
AssertionError: 10.1.1.4 not in systemd-resolve status: Global
          DNSSEC NTA: 10.in-addr.arpa
                      16.172.in-addr.arpa
                      168.192.in-addr.arpa
                      17.172.in-addr.arpa
                      18.172.in-addr.arpa
                      19.172.in-addr.arpa
                      20.172.in-addr.arpa
                      21.172.in-addr.arpa
                      22.172.in-addr.arpa
                      23.172.in-addr.arpa
                      24.172.in-addr.arpa
                      25.172.in-addr.arpa
                      26.172.in-addr.arpa
                      27.172.in-addr.arpa
                      28.172.in-addr.arpa
                      29.172.in-addr.arpa
                      30.172.in-addr.arpa
                      31.172.in-addr.arpa
                      corp
                      d.f.ip6.arpa
                      home
                      internal
                      intranet
                      lan
                      local
                      private
                      test

Link 2 (eth0)
      Current Scopes: LLMNR/IPv4 LLMNR/IPv6
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

----------------------------------------------------------------------
Ran 3 tests in 74.603s

ChristianEhrhardt (paelzer) wrote :

Added the server team review slot to show up in the active reviews for all of us to be picked up as time permits.

ChristianEhrhardt (paelzer) wrote :

I know the actual test is Ubuntu Delta we added and not in Debian.
I reviewed the code and on that level agree to the changes.

I don't like that this is a "fix the test" change but the test is still failing (due to the other bug). As a workaround I ran the new .dsc through autopkgtest with a rebuild on zesty.
It passed the "testsuite" test which the MP is modifying.
I gave it a shot on Artful as well and it failed with the known issue of:
  File "/tmp/autopkgtest.VTSgHq/build.cjb/open-iscsi-2.0.874/debian/tests/test-open-iscsi.py", line 287, in test_tgt_boot
    (dns_addr, resolve_status)))
AssertionError: 10.1.1.4 not in systemd-resolve status: Global

Debian:
debian/tests/patch-image is in Debian, would you mind to report that and associate a Debian bug to the Ubuntu one to not carry that forever.

Other fixes:
Reading into 1713803 that will be fixed in an upload to another package. So on this migration you will again run into "always failed" and migrate.
That todo is already tracked in the bugs you have open, so that is ok I guess.

@Scott if the error in artful above is really expected then ack - is it?

be1911c... by Scott Moser on 2017-09-07

improve test to also look for search entries.

33de4ec... by Scott Moser on 2017-09-07

allow ISCSI_TEST_RELEASE to set the release for easier testing.

ad9e6fc... by Scott Moser on 2017-09-07

support resolvconf and resolved .. zesty fun.

Scott Moser (smoser) wrote :

Christian,
I do not believe that 'debian/tests/patch-image' is in debian.
 $ git show pkg/debian/experimental:debian/tests/patch-image
 fatal: Path 'debian/tests/patch-image' exists on disk, but not in 'pkg/debian/experimental'.

It is really just part of the delta for that test we've added.

I've done some modifications to make the test easier to run for development. On our dev system 'diglett', which runs artful I've done:
  $ sudo ISCSI_TEST_RELEASE=zesty python debian/tests/test-open-iscsi.py
and that passes.
  $ sudo ISCSI_TEST_RELEASE=artful python debian/tests/test-open-iscsi.py

will fail as the dns is legitimately broken.

ChristianEhrhardt (paelzer) wrote :

Yeah as I mentioned in IRC I was doing the test on zesty as well but with the new package being built and it worked.

Sorry for asking on the patch-image it is clearly part of our Delta, was just not part of the same commit that added the rest. But that said:
1. test ok
2. fixing/improving the test
3. code review LGTM
=> Approve

And as you outline the "remaining" issue is already tracked in another bug.
So please go ahead and tag + upload or let me know if you want me to do so.

review: Approve
ChristianEhrhardt (paelzer) wrote :

Hi Scott,
I found your question on IRC.
Nish explained, but I still don't see an upload so following your request to do so.

I (git ubuntu lint) just found you still had set UNRELEASED.
But I can fix that up on tag/merge.

I tagged, pushed - verified the dsc debdiff matches the git one and sponsored it for you.
It is now at [1], please help tracking its build and proposed migration.

[1]: https://launchpad.net/ubuntu/+source/open-iscsi/2.0.874-4ubuntu2

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 d407b86..e5e0a94 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,11 @@
6+open-iscsi (2.0.874-4ubuntu2) UNRELEASED; urgency=medium
7+
8+ * debian/tests/test-open-iscsi.py: query systemd-resolved if present.
9+ Ubuntu images now have systemd-resolved managing /etc/resolv.conf
10+ so support test if that is the case (LP: #1715468).
11+
12+ -- Scott Moser <smoser@ubuntu.com> Wed, 06 Sep 2017 16:20:16 -0400
13+
14 open-iscsi (2.0.874-4ubuntu1) artful; urgency=medium
15
16 * Merge with Debian unstable. Remaining changes:
17diff --git a/debian/tests/README-boot-test.md b/debian/tests/README-boot-test.md
18index fe93bc6..1c4250a 100644
19--- a/debian/tests/README-boot-test.md
20+++ b/debian/tests/README-boot-test.md
21@@ -67,11 +67,11 @@ Testing manually looks like this:
22 ## Get the image you want. This creates out.d/disk.img and disk.img.dist
23 $ get-image xenial.d xenial
24
25- ## patch the image with an open-iscsi, which grabs creates xenial/kernel
26+ ## patch the image with an open-iscsi, which creates xenial/kernel
27 ## and xenial/initrd from the kernel and initramfs inside the image.
28 $ apt-get download open-iscsi
29 $ deb=$(ls open-iscsi_*.deb | tail -n 1)
30- $ patch-image xenial/disk.img "$deb" xenial/kernel xenial/initrd
31+ $ patch-image xenial/disk.img "$deb" --kernel=xenial/kernel --initrd=xenial/initrd
32
33 ## Boot the system, log in, look around.
34 $ tgt-boot-test -v xenial/disk.img xenial/kernel xenial/initrd
35diff --git a/debian/tests/patch-image b/debian/tests/patch-image
36index e3df8d7..ccec1c7 100755
37--- a/debian/tests/patch-image
38+++ b/debian/tests/patch-image
39@@ -121,15 +121,24 @@ main() {
40 local packages=( )
41 packages=( "$@" )
42
43- if [ "${#packages}" = "1" -a "${packages[0]}" = "none" ]; then
44+ if [ "${#packages[@]}" = "1" -a "${packages[0]}" = "none" ]; then
45 packages=( )
46 elif [ "${#packages[@]}" -eq 0 -a -n "${ADT_TEST_TRIGGERS}" ]; then
47 adt_test_triggers_to_bin_pkgs ${ADT_TEST_TRIGGERS} ||
48- fail "failed to find binary packages" \
49+ fail "failed to find binary packages " \
50 "from ADT_TEST_TRIGGERS=$ADT_TEST_TRIGGERS"
51 packages=( $_RET )
52 debug 1 "read ADT_TEST_TRIGGERS=$ADT_TEST_TRIGGERS to set" \
53 "packages=${packages[*]}"
54+ else
55+ local opackages="" debs="" pkg=""
56+ opackages=( "${packages[@]}" )
57+ packages=( )
58+ debs=( )
59+ for pkg in "${opackages[@]}"; do
60+ [ -f "${pkg}" ] && debs[${#debs[@]}]="$pkg" ||
61+ packages[${packages[@]}]="$pkg"
62+ done
63 fi
64
65 # if open-iscsi is not in the packages list above, we handle it specifically
66@@ -189,6 +198,15 @@ main() {
67 fail "failed to install ${packages[*]} in $target"
68 fi
69
70+ if [ "${#debs[@]}" != "0" ]; then
71+ local tmpd=""
72+ tmpd=$(mktemp -d "${target}/tmp/${0##*/}.XXXXXX")
73+ cp "${debs[@]}" "$tmpd"
74+ DEBIAN_FRONTEND=noninteractive chroot "$target" sh -exc \
75+ 'cd "$1"; shift; dpkg -i *.deb' debinstalls "${tmpd#${target}}"
76+ rm -Rf "${tmpd}"
77+ fi
78+
79 local kpath="" ipath=""
80 for f in "$target/boot/"*; do
81 case "${f##*/}" in
82@@ -208,7 +226,7 @@ main() {
83
84 if [ -n "$initrd" ]; then
85 [ -n "$ipath" ] || fail "unable to find initrd in $tsrc"
86- debug 1 "using initrd ${kernel#${ipath}}"
87+ debug 1 "using initrd ${ipath#${target}}"
88 cp "$ipath" "$initrd" ||
89 fail "failed copy $ipath to $initrd"
90 [ -z "$IMAGE" ] || chown "--reference=$IMAGE" "$initrd"
91diff --git a/debian/tests/test-open-iscsi.py b/debian/tests/test-open-iscsi.py
92index be5fbef..1c09925 100644
93--- a/debian/tests/test-open-iscsi.py
94+++ b/debian/tests/test-open-iscsi.py
95@@ -59,6 +59,35 @@ username_in = 'ubuntu'
96 password_in = 'ubuntupasswd'
97 initiatorname = 'iqn.2009-10.com.example.hardy-multi:iscsi-01'
98
99+COLLECT_USER_DATA = """\
100+#cloud-config
101+bukket:
102+ - &get_resolved_status |
103+ if [ "${1:--}" != "-" ]; then
104+ exec >"$1" 2>&1
105+ fi
106+ if ! command -v systemd-resolve >/dev/null 2>&1; then
107+ echo "systemd-resolve: not available."
108+ exit
109+ fi
110+ if ! ( systemd-resolve --help | grep -q -- --status ); then
111+ echo "systemd-resolve: no --status."
112+ exit
113+ fi
114+ systemd-resolve --status --no-pager
115+
116+runcmd:
117+ - [ mkdir, -p, /output ]
118+ - [ cp, /etc/resolv.conf, /output]
119+ - [ sh, -c, *get_resolved_status, --, /output/systemd-resolve-status.txt]
120+ - [ tar, -C, /output, -cf, /dev/disk/by-id/virtio-output-disk, . ]
121+
122+power_state:
123+ mode: poweroff
124+ message: cloud-init finished. Shutting down.
125+ timeout: 60
126+"""
127+
128 try:
129 from private.qrt.OpenIscsi import PrivateOpenIscsiTest
130 except ImportError:
131@@ -152,17 +181,6 @@ class CloudImageTest(testlib.TestlibCase, PrivateOpenIscsiTest):
132 See README-boot-test.md for more information.
133 '''
134
135- collect_user_data = textwrap.dedent("""\
136- runcmd:
137- - [ mkdir, -p, /output ]
138- - [ cp, /etc/resolv.conf, /output]
139- - [ tar, -C, /output, -cf, /dev/disk/by-id/virtio-output-disk, . ]
140- power_state:
141- mode: poweroff
142- message: cloud-init finished. Shutting down.
143- timeout: 60
144- """)
145-
146 @classmethod
147 def setUpClass(cls):
148 reason = (
149@@ -175,7 +193,8 @@ class CloudImageTest(testlib.TestlibCase, PrivateOpenIscsiTest):
150
151 here = os.path.dirname(os.path.abspath(__file__))
152 os.environ['PATH'] = "%s:%s" % (here, os.environ['PATH'])
153- release = testlib.ubuntu_release()
154+ release = os.environ.get(
155+ "ISCSI_TEST_RELEASE", testlib.ubuntu_release())
156 image_d = os.path.join(here, '{}.d'.format(release))
157 # Download MAAS ephemeral image.
158 info = {'release': release,
159@@ -201,7 +220,7 @@ class CloudImageTest(testlib.TestlibCase, PrivateOpenIscsiTest):
160 self.tmpdir = mkdtemp()
161 udp = os.path.join(self.tmpdir, 'user-data')
162 with open(udp, "w") as fp:
163- fp.write(self.collect_user_data)
164+ fp.write(COLLECT_USER_DATA)
165 self.info['user-data'] = udp
166
167 def create_output_disk(self):
168@@ -232,8 +251,9 @@ class CloudImageTest(testlib.TestlibCase, PrivateOpenIscsiTest):
169 # Add self.here to PATH so xkvm will be available to tgt-boot-test
170 dns_addr = '10.1.1.4'
171 rel_dir = '{}.d'.format(self.info['release'])
172+ dns_search = 'example.com'
173 info = {'host': '10.1.1.2', 'dns': dns_addr,
174- 'dnssearch': 'example.com', 'network': '10.1.1.0/24'}
175+ 'dnssearch': dns_search, 'network': '10.1.1.0/24'}
176 netdev = ("--netdev=user,net={network},host={host},dns={dns},"
177 "dnssearch={dnssearch}").format(**info)
178
179@@ -249,14 +269,39 @@ class CloudImageTest(testlib.TestlibCase, PrivateOpenIscsiTest):
180 subprocess.check_call(cmd)
181 files = self.extract_files(output_disk)
182 print("files: %s" % files)
183- resolvconf_contents = "NO_RESOLVCONF_FOUND"
184- for name, contents in files.items():
185- if name.endswith('resolv.conf'):
186- resolvconf_contents = contents
187- self.assertIn(
188- dns_addr, resolvconf_contents,
189- msg = ("%s not in resolvconf contents: \n%s" %
190- (dns_addr, resolvconf_contents)))
191+ resolvconf = files.get('resolv.conf', "NO_RESOLVCONF_FOUND")
192+ resolve_status = files.get('systemd-resolve-status.txt')
193+
194+ resolvconf_id = 'generated by resolvconf'
195+ resolved_addr = "127.0.0.53"
196+ if resolvconf_id in resolvconf:
197+ print("resolvconf manages resolvconf.\n")
198+ self.assertIn(
199+ dns_addr, resolvconf,
200+ msg = ("%s not in resolvconf contents: \n%s" %
201+ (dns_addr, resolvconf)))
202+ if dns_search in resolvconf:
203+ print("%s was found in resolv.conf." % dns_search)
204+ elif resolved_addr in resolvconf and dns_search in resolve_status:
205+ # zesty has resolvconf and systemd-resolved.
206+ print("%s was in resolve_status and %s in resolv.conf" %
207+ (resolved_addr, dns_search))
208+ else:
209+ raise AssertionError(
210+ "%s domain is not being searched." % dns_search)
211+
212+ else:
213+ print("systemd-resolved managing resolve.conf\n")
214+ self.assertIn(
215+ resolved_addr, resolvconf,
216+ msg="%s not in resolved resolv.conf: %s" % (resolved_addr,
217+ resolvconf))
218+ self.assertIn(dns_addr, resolve_status,
219+ msg=("%s not in systemd-resolve status: %s" %
220+ (dns_addr, resolve_status)))
221+ self.assertIn(dns_search, resolve_status,
222+ msg=("search addr '%s' not in systemd-resolve status: %s" %
223+ (dns_search, resolve_status)))
224
225
226 def get_image(top_d, release):

Subscribers

People subscribed via source and target branches