mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
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:
parent
31b3584b2d
commit
83405f92a9
11
tests/lxcconf2xmldata/lxcconf2xml-blkiotune-v3.config
Normal file
11
tests/lxcconf2xmldata/lxcconf2xml-blkiotune-v3.config
Normal 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
|
6
tests/lxcconf2xmldata/lxcconf2xml-cpusettune-v3.config
Normal file
6
tests/lxcconf2xmldata/lxcconf2xml-cpusettune-v3.config
Normal 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
|
7
tests/lxcconf2xmldata/lxcconf2xml-cputune-v3.config
Normal file
7
tests/lxcconf2xmldata/lxcconf2xml-cputune-v3.config
Normal 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
|
44
tests/lxcconf2xmldata/lxcconf2xml-ethernet-v3.config
Normal file
44
tests/lxcconf2xmldata/lxcconf2xml-ethernet-v3.config
Normal 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
|
37
tests/lxcconf2xmldata/lxcconf2xml-fstab-v3.config
Normal file
37
tests/lxcconf2xmldata/lxcconf2xml-fstab-v3.config
Normal 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
|
5
tests/lxcconf2xmldata/lxcconf2xml-idmap-v3.config
Normal file
5
tests/lxcconf2xmldata/lxcconf2xml-idmap-v3.config
Normal 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
|
13
tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork-v3.config
Normal file
13
tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork-v3.config
Normal 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
|
10
tests/lxcconf2xmldata/lxcconf2xml-memtune-v3.config
Normal file
10
tests/lxcconf2xmldata/lxcconf2xml-memtune-v3.config
Normal 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
|
4
tests/lxcconf2xmldata/lxcconf2xml-nonenetwork-v3.config
Normal file
4
tests/lxcconf2xmldata/lxcconf2xml-nonenetwork-v3.config
Normal 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
|
3
tests/lxcconf2xmldata/lxcconf2xml-nonetwork-v3.config
Normal file
3
tests/lxcconf2xmldata/lxcconf2xml-nonetwork-v3.config
Normal file
@ -0,0 +1,3 @@
|
||||
lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
|
||||
lxc.uts.name = migrate_test
|
||||
lxc.autodev=1
|
11
tests/lxcconf2xmldata/lxcconf2xml-physnetwork-v3.config
Normal file
11
tests/lxcconf2xmldata/lxcconf2xml-physnetwork-v3.config
Normal 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
|
45
tests/lxcconf2xmldata/lxcconf2xml-simple-v3.config
Normal file
45
tests/lxcconf2xmldata/lxcconf2xml-simple-v3.config
Normal 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
|
12
tests/lxcconf2xmldata/lxcconf2xml-vlannetwork-v3.config
Normal file
12
tests/lxcconf2xmldata/lxcconf2xml-vlannetwork-v3.config
Normal 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
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user