[PATCH v4 2/2] tests: Adding tests cases to cover rebased settings for LXC 3.0.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This commit includes new test cases to cover LXC version 3.0 and higher.
This LXC version rebased some settings entries and deprecated other ones.
As we support both, we should include tests to minimize problems with
integration between them.

Signed-off-by: Julio Faracco <jcfaracco@xxxxxxxxx>
---
 .../lxcconf2xml-blkiotune-v3.config           | 11 ++++
 .../lxcconf2xml-cpusettune-v3.config          |  6 +++
 .../lxcconf2xml-cputune-v3.config             |  7 +++
 .../lxcconf2xml-ethernet-v3.config            | 44 ++++++++++++++++
 .../lxcconf2xml-fstab-v3.config               | 37 ++++++++++++++
 .../lxcconf2xml-idmap-v3.config               |  5 ++
 .../lxcconf2xml-macvlannetwork-v3.config      | 13 +++++
 .../lxcconf2xml-memtune-v3.config             | 10 ++++
 .../lxcconf2xml-nonenetwork-v3.config         |  4 ++
 .../lxcconf2xml-nonetwork-v3.config           |  3 ++
 .../lxcconf2xml-physnetwork-v3.config         | 11 ++++
 .../lxcconf2xml-simple-v3.config              | 45 ++++++++++++++++
 .../lxcconf2xml-vlannetwork-v3.config         | 12 +++++
 tests/lxcconf2xmltest.c                       | 51 ++++++++++++++++++-
 14 files changed, 257 insertions(+), 2 deletions(-)
 create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-blkiotune-v3.config
 create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-cpusettune-v3.config
 create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-cputune-v3.config
 create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-ethernet-v3.config
 create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-fstab-v3.config
 create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-idmap-v3.config
 create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork-v3.config
 create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-memtune-v3.config
 create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-nonenetwork-v3.config
 create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-nonetwork-v3.config
 create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-physnetwork-v3.config
 create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-simple-v3.config
 create mode 100644 tests/lxcconf2xmldata/lxcconf2xml-vlannetwork-v3.config

diff --git a/tests/lxcconf2xmldata/lxcconf2xml-blkiotune-v3.config b/tests/lxcconf2xmldata/lxcconf2xml-blkiotune-v3.config
new file mode 100644
index 0000000000..6d82ac74eb
--- /dev/null
+++ b/tests/lxcconf2xmldata/lxcconf2xml-blkiotune-v3.config
@@ -0,0 +1,11 @@
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+lxc.autodev=1
+
+lxc.cgroup.blkio.weight = 500
+lxc.cgroup.blkio.device_weight = 8:16	1000
+lxc.cgroup.blkio.device_weight = 8:0    300
+lxc.cgroup.blkio.throttle.read_bps_device = 8:16 1234
+lxc.cgroup.blkio.throttle.write_bps_device = 8:16 5678
+lxc.cgroup.blkio.throttle.read_iops_device = 8:16 4321
+lxc.cgroup.blkio.throttle.write_iops_device = 8:16 8765
diff --git a/tests/lxcconf2xmldata/lxcconf2xml-cpusettune-v3.config b/tests/lxcconf2xmldata/lxcconf2xml-cpusettune-v3.config
new file mode 100644
index 0000000000..248874b198
--- /dev/null
+++ b/tests/lxcconf2xmldata/lxcconf2xml-cpusettune-v3.config
@@ -0,0 +1,6 @@
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+lxc.autodev=1
+
+lxc.cgroup.cpuset.cpus = 1,2,5-7
+lxc.cgroup.cpuset.mems = 1-4
diff --git a/tests/lxcconf2xmldata/lxcconf2xml-cputune-v3.config b/tests/lxcconf2xmldata/lxcconf2xml-cputune-v3.config
new file mode 100644
index 0000000000..bd2da94ec2
--- /dev/null
+++ b/tests/lxcconf2xmldata/lxcconf2xml-cputune-v3.config
@@ -0,0 +1,7 @@
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+lxc.autodev=1
+
+lxc.cgroup.cpu.shares = 1024
+lxc.cgroup.cpu.cfs_quota_us = -1
+lxc.cgroup.cpu.cfs_period_us = 500000
diff --git a/tests/lxcconf2xmldata/lxcconf2xml-ethernet-v3.config b/tests/lxcconf2xmldata/lxcconf2xml-ethernet-v3.config
new file mode 100644
index 0000000000..630cb2ebb6
--- /dev/null
+++ b/tests/lxcconf2xmldata/lxcconf2xml-ethernet-v3.config
@@ -0,0 +1,44 @@
+# Template used to create this container: opensuse
+# Template script checksum (SHA-1): 27307e0a95bd81b2c0bd82d6f87fdbe83be075ef
+
+lxc.network.type = veth
+lxc.network.flags = up
+lxc.network.hwaddr = 02:00:15:8f:05:c1
+lxc.network.name = eth0
+lxc.network.ipv4 = 192.168.122.2/24
+lxc.network.ipv4.gateway = 192.168.122.1
+lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596/64
+lxc.network.ipv6.gateway = 2003:db8:1:0:214:1234:fe0b:3595
+
+#remove next line if host DNS configuration should not be available to container
+lxc.mount.entry = proc proc proc nodev,noexec,nosuid 0 0
+lxc.mount.entry = sysfs sys sysfs defaults  0 0
+lxc.mount.entry = tmpfs run tmpfs size=8m,mode=0755,nodev,nosuid 0 0
+lxc.mount.entry = /etc/resolv.conf etc/resolv.conf none bind,ro 0 0
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+lxc.arch = x86
+lxc.autodev=1
+lxc.tty.max = 2
+lxc.pts = 1024
+lxc.cap.drop = sys_module mac_admin mac_override mknod
+
+# When using LXC with apparmor, uncomment the next line to run unconfined:
+#lxc.aa_profile = unconfined
+
+lxc.cgroup.devices.deny = a
+# /dev/null and zero
+lxc.cgroup.devices.allow = c 1:3 rwm
+lxc.cgroup.devices.allow = c 1:5 rwm
+# consoles
+lxc.cgroup.devices.allow = c 5:1 rwm
+lxc.cgroup.devices.allow = c 5:0 rwm
+lxc.cgroup.devices.allow = c 4:0 rwm
+lxc.cgroup.devices.allow = c 4:1 rwm
+# /dev/{,u}random
+lxc.cgroup.devices.allow = c 1:9 rwm
+lxc.cgroup.devices.allow = c 1:8 rwm
+lxc.cgroup.devices.allow = c 136:* rwm
+lxc.cgroup.devices.allow = c 5:2 rwm
+# rtc
+lxc.cgroup.devices.allow = c 254:0 rwm
diff --git a/tests/lxcconf2xmldata/lxcconf2xml-fstab-v3.config b/tests/lxcconf2xmldata/lxcconf2xml-fstab-v3.config
new file mode 100644
index 0000000000..8b62818657
--- /dev/null
+++ b/tests/lxcconf2xmldata/lxcconf2xml-fstab-v3.config
@@ -0,0 +1,37 @@
+# Template used to create this container: opensuse
+# Template script checksum (SHA-1): 27307e0a95bd81b2c0bd82d6f87fdbe83be075ef
+
+lxc.network.type = veth
+lxc.network.flags = up
+lxc.network.link = virbr0
+lxc.network.hwaddr = 02:00:15:8f:05:c1
+lxc.network.name = eth0
+
+#remove next line if host DNS configuration should not be available to container
+lxc.mount.fstab = /var/lib/lxc/migrate_test/fstab
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+lxc.autodev=1
+lxc.tty.max = 2
+lxc.pts = 1024
+lxc.cap.drop = sys_module mac_admin mac_override mknod
+
+# When using LXC with apparmor, uncomment the next line to run unconfined:
+#lxc.aa_profile = unconfined
+
+lxc.cgroup.devices.deny = a
+# /dev/null and zero
+lxc.cgroup.devices.allow = c 1:3 rwm
+lxc.cgroup.devices.allow = c 1:5 rwm
+# consoles
+lxc.cgroup.devices.allow = c 5:1 rwm
+lxc.cgroup.devices.allow = c 5:0 rwm
+lxc.cgroup.devices.allow = c 4:0 rwm
+lxc.cgroup.devices.allow = c 4:1 rwm
+# /dev/{,u}random
+lxc.cgroup.devices.allow = c 1:9 rwm
+lxc.cgroup.devices.allow = c 1:8 rwm
+lxc.cgroup.devices.allow = c 136:* rwm
+lxc.cgroup.devices.allow = c 5:2 rwm
+# rtc
+lxc.cgroup.devices.allow = c 254:0 rwm
diff --git a/tests/lxcconf2xmldata/lxcconf2xml-idmap-v3.config b/tests/lxcconf2xmldata/lxcconf2xml-idmap-v3.config
new file mode 100644
index 0000000000..2caae864cc
--- /dev/null
+++ b/tests/lxcconf2xmldata/lxcconf2xml-idmap-v3.config
@@ -0,0 +1,5 @@
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+
+lxc.idmap = u 10000 0 2000
+lxc.idmap = g 10000 0 1000
diff --git a/tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork-v3.config b/tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork-v3.config
new file mode 100644
index 0000000000..631f07ecca
--- /dev/null
+++ b/tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork-v3.config
@@ -0,0 +1,13 @@
+# Template used to create this container: opensuse
+# Template script checksum (SHA-1): 27307e0a95bd81b2c0bd82d6f87fdbe83be075ef
+
+lxc.network.type = macvlan
+lxc.network.flags = up
+lxc.network.link = eth0
+lxc.network.hwaddr = 02:00:15:8f:05:c1
+lxc.network.macvlan.mode = vepa
+
+#remove next line if host DNS configuration should not be available to container
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+lxc.autodev=1
diff --git a/tests/lxcconf2xmldata/lxcconf2xml-memtune-v3.config b/tests/lxcconf2xmldata/lxcconf2xml-memtune-v3.config
new file mode 100644
index 0000000000..5bd928eb1a
--- /dev/null
+++ b/tests/lxcconf2xmldata/lxcconf2xml-memtune-v3.config
@@ -0,0 +1,10 @@
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+lxc.autodev=1
+
+# 1GiB
+lxc.cgroup.memory.limit_in_bytes = 1073741824
+# 128MiB
+lxc.cgroup.memory.soft_limit_in_bytes = 134217728
+# 2GiB
+lxc.cgroup.memory.memsw.limit_in_bytes = 2147483648
diff --git a/tests/lxcconf2xmldata/lxcconf2xml-nonenetwork-v3.config b/tests/lxcconf2xmldata/lxcconf2xml-nonenetwork-v3.config
new file mode 100644
index 0000000000..f81a786f1e
--- /dev/null
+++ b/tests/lxcconf2xmldata/lxcconf2xml-nonenetwork-v3.config
@@ -0,0 +1,4 @@
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+lxc.autodev=1
+lxc.network.type = none
diff --git a/tests/lxcconf2xmldata/lxcconf2xml-nonetwork-v3.config b/tests/lxcconf2xmldata/lxcconf2xml-nonetwork-v3.config
new file mode 100644
index 0000000000..b33d5780b6
--- /dev/null
+++ b/tests/lxcconf2xmldata/lxcconf2xml-nonetwork-v3.config
@@ -0,0 +1,3 @@
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+lxc.autodev=1
diff --git a/tests/lxcconf2xmldata/lxcconf2xml-physnetwork-v3.config b/tests/lxcconf2xmldata/lxcconf2xml-physnetwork-v3.config
new file mode 100644
index 0000000000..92729841d7
--- /dev/null
+++ b/tests/lxcconf2xmldata/lxcconf2xml-physnetwork-v3.config
@@ -0,0 +1,11 @@
+lxc.network.type = phys
+lxc.network.link = eth0
+lxc.network.name = eth1
+lxc.network.ipv4 = 192.168.122.2/24
+lxc.network.ipv4.gateway = 192.168.122.1
+lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596/64
+lxc.network.ipv6.gateway = 2003:db8:1:0:214:1234:fe0b:3595
+
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+lxc.autodev=1
diff --git a/tests/lxcconf2xmldata/lxcconf2xml-simple-v3.config b/tests/lxcconf2xmldata/lxcconf2xml-simple-v3.config
new file mode 100644
index 0000000000..a0036a482e
--- /dev/null
+++ b/tests/lxcconf2xmldata/lxcconf2xml-simple-v3.config
@@ -0,0 +1,45 @@
+# Template used to create this container: opensuse
+# Template script checksum (SHA-1): 27307e0a95bd81b2c0bd82d6f87fdbe83be075ef
+
+lxc.network.type = veth
+lxc.network.flags = up
+lxc.network.link = virbr0
+lxc.network.hwaddr = 02:00:15:8f:05:c1
+lxc.network.name = eth0
+lxc.network.ipv4 = 192.168.122.2/24
+lxc.network.ipv4.gateway = 192.168.122.1
+lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596/64
+lxc.network.ipv6.gateway = 2003:db8:1:0:214:1234:fe0b:3595
+
+#remove next line if host DNS configuration should not be available to container
+lxc.mount.entry = proc proc proc nodev,noexec,nosuid 0 0
+lxc.mount.entry = sysfs sys sysfs defaults  0 0
+lxc.mount.entry = tmpfs run tmpfs size=8m,mode=0755,nodev,nosuid 0 0
+lxc.mount.entry = /etc/resolv.conf etc/resolv.conf none bind,ro 0 0
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+lxc.arch = x86
+lxc.autodev=1
+lxc.tty.max = 2
+lxc.pts = 1024
+lxc.cap.drop = sys_module mac_admin mac_override mknod
+
+# When using LXC with apparmor, uncomment the next line to run unconfined:
+#lxc.aa_profile = unconfined
+
+lxc.cgroup.devices.deny = a
+# /dev/null and zero
+lxc.cgroup.devices.allow = c 1:3 rwm
+lxc.cgroup.devices.allow = c 1:5 rwm
+# consoles
+lxc.cgroup.devices.allow = c 5:1 rwm
+lxc.cgroup.devices.allow = c 5:0 rwm
+lxc.cgroup.devices.allow = c 4:0 rwm
+lxc.cgroup.devices.allow = c 4:1 rwm
+# /dev/{,u}random
+lxc.cgroup.devices.allow = c 1:9 rwm
+lxc.cgroup.devices.allow = c 1:8 rwm
+lxc.cgroup.devices.allow = c 136:* rwm
+lxc.cgroup.devices.allow = c 5:2 rwm
+# rtc
+lxc.cgroup.devices.allow = c 254:0 rwm
diff --git a/tests/lxcconf2xmldata/lxcconf2xml-vlannetwork-v3.config b/tests/lxcconf2xmldata/lxcconf2xml-vlannetwork-v3.config
new file mode 100644
index 0000000000..31e26997dd
--- /dev/null
+++ b/tests/lxcconf2xmldata/lxcconf2xml-vlannetwork-v3.config
@@ -0,0 +1,12 @@
+# Template used to create this container: opensuse
+# Template script checksum (SHA-1): 27307e0a95bd81b2c0bd82d6f87fdbe83be075ef
+
+lxc.network.type = vlan
+lxc.network.flags = up
+lxc.network.link = eth0
+lxc.network.hwaddr = 02:00:15:8f:05:c1
+lxc.network.vlan.id = 2
+
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+lxc.autodev=1
diff --git a/tests/lxcconf2xmltest.c b/tests/lxcconf2xmltest.c
index 360d840e2e..0766239ec4 100644
--- a/tests/lxcconf2xmltest.c
+++ b/tests/lxcconf2xmltest.c
@@ -64,7 +64,7 @@ struct testInfo {
 };
 
 static int
-testCompareXMLToConfigHelper(const void *data)
+testCompareXMLToConfigHelperLegacy(const void *data)
 {
     int result = -1;
     const struct testInfo *info = data;
@@ -85,6 +85,29 @@ testCompareXMLToConfigHelper(const void *data)
     return result;
 }
 
+static int
+testCompareXMLToConfigHelperV3(const void *data)
+{
+    int result = -1;
+    const struct testInfo *info = data;
+    char *xml = NULL;
+    char *config = NULL;
+
+    if (virAsprintf(&xml, "%s/lxcconf2xmldata/lxcconf2xml-%s.xml",
+                    abs_srcdir, info->name) < 0 ||
+        virAsprintf(&config, "%s/lxcconf2xmldata/lxcconf2xml-%s-v3.config",
+                    abs_srcdir, info->name) < 0)
+        goto cleanup;
+
+    result = testCompareXMLToConfigFiles(xml, config, info->expectError);
+
+ cleanup:
+    VIR_FREE(xml);
+    VIR_FREE(config);
+    return result;
+}
+
+
 static int
 mymain(void)
 {
@@ -102,7 +125,7 @@ mymain(void)
     do { \
         const struct testInfo info = { name, expectError }; \
         if (virTestRun("LXC Native-2-XML " name, \
-                       testCompareXMLToConfigHelper, \
+                       testCompareXMLToConfigHelperLegacy, \
                        &info) < 0) \
             ret = EXIT_FAILURE; \
     } while (0)
@@ -121,6 +144,30 @@ mymain(void)
     DO_TEST("blkiotune", false);
     DO_TEST("ethernet", false);
 
+    /* Tests for LXC 3.0 and higher */
+# define DO_TEST3(name, expectError) \
+    do { \
+        const struct testInfo info = { name, expectError }; \
+        if (virTestRun("LXC Native-3-XML " name, \
+                       testCompareXMLToConfigHelperV3, \
+                       &info) < 0) \
+            ret = EXIT_FAILURE; \
+    } while (0)
+
+    DO_TEST3("simple", false);
+    DO_TEST3("fstab", true);
+    DO_TEST3("nonetwork", false);
+    DO_TEST3("nonenetwork", false);
+    DO_TEST3("physnetwork", false);
+    DO_TEST3("macvlannetwork", false);
+    DO_TEST3("vlannetwork", false);
+    DO_TEST3("idmap", false);
+    DO_TEST3("memtune", false);
+    DO_TEST3("cputune", false);
+    DO_TEST3("cpusettune", false);
+    DO_TEST3("blkiotune", false);
+    DO_TEST3("ethernet", false);
+
     virObjectUnref(xmlopt);
     virObjectUnref(caps);
 
-- 
2.19.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux