summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTails developers <amnesia@boum.org>2015-02-22 12:43:00 +0100
committerTails developers <amnesia@boum.org>2015-02-22 12:43:00 +0100
commit4920317a7160903dfc11dae87de6ea25701f7534 (patch)
treec67e347464f9359985381708e6bc56bc0549b8e9
parent714917d949037f788702eb8b45199043ca905080 (diff)
parent91373fa6218c2ef0fdeecbe41be9beecd8cae775 (diff)
Merge remote-tracking branch 'kytv/test/8907-check-space' into testing
Fix-committed: #8907
-rw-r--r--features/support/helpers/misc_helpers.rb15
-rw-r--r--features/support/helpers/storage_helper.rb9
2 files changed, 24 insertions, 0 deletions
diff --git a/features/support/helpers/misc_helpers.rb b/features/support/helpers/misc_helpers.rb
index 36c92e7..3bcb6bf 100644
--- a/features/support/helpers/misc_helpers.rb
+++ b/features/support/helpers/misc_helpers.rb
@@ -100,3 +100,18 @@ def save_pcap_file
FileUtils.cp(@sniffer.pcap_file, pcap_copy)
puts "Full network capture available at: #{pcap_copy}"
end
+
+def get_free_space(machine, path)
+ case machine
+ when 'host'
+ assert(File.exists?(path), "Path '#{path}' not found on #{machine}.")
+ free = cmd_helper("df '#{path}'")
+ when 'guest'
+ assert(@vm.file_exist?(path), "Path '#{path}' not found on #{machine}.")
+ free = @vm.execute_successfully("df '#{path}'")
+ else
+ raise 'Unsupported machine type #{machine} passed.'
+ end
+ output = free.split("\n").last
+ return output.match(/[^\s]\s+[0-9]+\s+[0-9]+\s+([0-9]+)\s+.*/)[1].chomp.to_i
+end
diff --git a/features/support/helpers/storage_helper.rb b/features/support/helpers/storage_helper.rb
index 0e672e4..baee6d7 100644
--- a/features/support/helpers/storage_helper.rb
+++ b/features/support/helpers/storage_helper.rb
@@ -70,6 +70,15 @@ class VMStorage
options[:size] ||= 2
options[:unit] ||= "GiB"
options[:type] ||= "qcow2"
+ # Require 'slightly' more space to be available to give a bit more leeway
+ # with rounding, temp file creation, etc.
+ reserved = 500
+ needed = convert_to_MiB(options[:size].to_i, options[:unit])
+ avail = convert_to_MiB(get_free_space('host', @pool_path), "KiB")
+ assert(avail - reserved >= needed,
+ "Error creating disk \"#{name}\" in \"#{@pool_path}\". " \
+ "Need #{needed} MiB but only #{avail} MiB is available of, " \
+ "which #{reserved} MiB is reserved for other temporary files.")
begin
old_vol = @pool.lookup_volume_by_name(name)
rescue Libvirt::RetrieveError