tests: Adding tests cases to cover rebased settings for LXC 3.0.

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@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
Julio Faracco 2018-11-14 15:25:46 -02:00 committed by John Ferlan
parent 31b3584b2d
commit 83405f92a9
14 changed files with 257 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,3 @@
lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
lxc.uts.name = migrate_test
lxc.autodev=1

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);