|
11 | 11 | """
|
12 | 12 | import base64
|
13 | 13 | import infamy
|
14 |
| -from infamy.util import until |
| 14 | +from infamy.util import until, to_binary |
15 | 15 |
|
16 | 16 | with infamy.Test() as test:
|
17 | 17 | NAME = "web-phys"
|
18 | 18 | DUTIP = "10.0.0.2"
|
19 | 19 | OURIP = "10.0.0.1"
|
| 20 | + MESG = "Kilroy was here" |
| 21 | + BODY = f"<html><body><p>{MESG}</p></body></html>" |
20 | 22 | URL = f"http://{DUTIP}:91/index.html"
|
21 | 23 |
|
22 | 24 | with test.step("Set up topology and attach to target DUT"):
|
|
26 | 28 | if not target.has_model("infix-containers"):
|
27 | 29 | test.skip()
|
28 | 30 |
|
29 |
| - with test.step("Create container 'web-phys' from bundled OCI image"): |
| 31 | + with test.step("Create httpd container from bundled OCI image"): |
30 | 32 | _, ifname = env.ltop.xlate("target", "data")
|
31 | 33 |
|
32 | 34 | target.put_config_dict("ietf-interfaces", {
|
33 | 35 | "interfaces": {
|
34 |
| - "interface": [ |
35 |
| - { |
36 |
| - "name": f"{ifname}", |
37 |
| - "ipv4": { |
38 |
| - "address": [{ |
39 |
| - "ip": f"{DUTIP}", |
40 |
| - "prefix-length": 24 |
41 |
| - }] |
42 |
| - }, |
43 |
| - "container-network": {} |
44 |
| - } |
45 |
| - ] |
| 36 | + "interface": [{ |
| 37 | + "name": f"{ifname}", |
| 38 | + "ipv4": { |
| 39 | + "address": [{ |
| 40 | + "ip": f"{DUTIP}", |
| 41 | + "prefix-length": 24 |
| 42 | + }] |
| 43 | + }, |
| 44 | + "container-network": {} |
| 45 | + }] |
46 | 46 | }
|
47 | 47 | })
|
48 | 48 | target.put_config_dict("infix-containers", {
|
49 | 49 | "containers": {
|
50 |
| - "container": [ |
51 |
| - { |
52 |
| - "name": f"{NAME}", |
53 |
| - "image": f"oci-archive:{infamy.Container.HTTPD_IMAGE}", |
54 |
| - "command": "/usr/sbin/httpd -f -v -p 91", |
55 |
| - "network": { |
56 |
| - "interface": [ |
57 |
| - { "name": f"{ifname}" } |
58 |
| - ] |
59 |
| - } |
| 50 | + "container": [{ |
| 51 | + "name": f"{NAME}", |
| 52 | + "image": f"oci-archive:{infamy.Container.HTTPD_IMAGE}", |
| 53 | + "command": "/usr/sbin/httpd -f -v -p 91", |
| 54 | + "network": { |
| 55 | + "interface": [ |
| 56 | + {"name": f"{ifname}"} |
| 57 | + ] |
60 | 58 | }
|
61 |
| - ] |
| 59 | + }] |
62 | 60 | }
|
63 | 61 | })
|
64 | 62 |
|
65 |
| - with test.step("Verify container 'web-phys' has started"): |
| 63 | + with test.step("Verify container has started"): |
66 | 64 | c = infamy.Container(target)
|
67 | 65 | until(lambda: c.running(NAME), attempts=10)
|
68 | 66 |
|
|
74 | 72 | with test.step("Verify host:data can ping 10.0.0.2"):
|
75 | 73 | ns.must_reach(DUTIP)
|
76 | 74 |
|
77 |
| - with test.step("Verify container 'web-phys' is reachable on http://10.0.0.2:91"): |
| 75 | + with test.step("Verify container is reachable on http://10.0.0.2:91"): |
78 | 76 | until(lambda: url.nscheck(ns, "It works"), attempts=10)
|
79 | 77 |
|
| 78 | + with test.step("Verify modifying a running container takes"): |
| 79 | + # Regression test for issue #930 |
| 80 | + data = to_binary(BODY) |
| 81 | + |
| 82 | + target.put_config_dict("infix-containers", { |
| 83 | + "containers": { |
| 84 | + "container": [{ |
| 85 | + "name": f"{NAME}", |
| 86 | + "mount": [{ |
| 87 | + "name": "index.html", |
| 88 | + "content": f"{data}", |
| 89 | + "target": "/var/www/index.html" |
| 90 | + }] |
| 91 | + }] |
| 92 | + } |
| 93 | + }) |
| 94 | + |
| 95 | + until(lambda: url.nscheck(ns, MESG), attempts=10) |
| 96 | + |
80 | 97 | test.succeed()
|
0 commit comments