[lxc-devel] [lxd/master] Allow reducing the LVM LV size and update tests

stgraber on Github lxc-bot at linuxcontainers.org
Tue Mar 8 21:44:08 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 579 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160308/4c6fcbf6/attachment.bin>
-------------- next part --------------
From c07ad13ef7d5d81d34f1f0e6f9ff8a2904aee7d7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 8 Mar 2016 16:18:47 -0500
Subject: [PATCH] Allow reducing the LVM LV size and update tests
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

We spend more than 50% of the LVM test time in mkfs.ext4, despite using
test images only a few kB large, so lets make the LV size configurable
through environment and set it to something really small for the
testsuite.

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/storage_lvm.go   | 7 ++++++-
 test/backends/lvm.sh | 3 ++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lxd/storage_lvm.go b/lxd/storage_lvm.go
index f0fd62e..35494bc 100644
--- a/lxd/storage_lvm.go
+++ b/lxd/storage_lvm.go
@@ -952,11 +952,16 @@ func (s *storageLvm) createThinLV(lvname string) (string, error) {
 		}
 	}
 
+	lvSize := os.Getenv("LXD_LVM_LVSIZE")
+	if lvSize == "" {
+		lvSize = storageLvmDefaultThinLVSize
+	}
+
 	output, err := s.tryExec(
 		"lvcreate",
 		"--thin",
 		"-n", lvname,
-		"--virtualsize", storageLvmDefaultThinLVSize,
+		"--virtualsize", lvSize,
 		fmt.Sprintf("%s/%s", s.vgName, poolname))
 
 	if err != nil {
diff --git a/test/backends/lvm.sh b/test/backends/lvm.sh
index f7ad1d9..5e18c26 100644
--- a/test/backends/lvm.sh
+++ b/test/backends/lvm.sh
@@ -10,7 +10,7 @@ lvm_setup() {
     echo "Couldn't find the lvm binary"; false
   fi
 
-  truncate -s 100G "${TEST_DIR}/$(basename "${LXD_DIR}").lvm"
+  truncate -s 1G "${TEST_DIR}/$(basename "${LXD_DIR}").lvm"
   pvloopdev=$(losetup --show -f "${TEST_DIR}/$(basename "${LXD_DIR}").lvm")
   if [ ! -e "${pvloopdev}" ]; then
     echo "failed to setup loop"
@@ -28,6 +28,7 @@ lvm_configure() {
 
   echo "==> Configuring lvm backend in ${LXD_DIR}"
 
+  export LXD_LVM_LVSIZE="10Mib"
   lxc config set storage.lvm_vg_name "lxdtest-$(basename "${LXD_DIR}")"
 }
 


More information about the lxc-devel mailing list