Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 110 lines (88 sloc) 3.045 kb
9dcb226 Joe Thornber start working on the multiple pool scenarios
authored
1 require 'config'
2 require 'lib/dm'
3 require 'lib/log'
4 require 'lib/process'
5 require 'lib/utils'
8f18726 Joe Thornber add tags to tests
authored
6 require 'lib/tags'
9dcb226 Joe Thornber start working on the multiple pool scenarios
authored
7 require 'lib/thinp-test'
8
9 #----------------------------------------------------------------
10
11 class MultiplePoolTests < ThinpTestCase
8f18726 Joe Thornber add tags to tests
authored
12 include Tags
18424f7 Joe Thornber change MultiplePoolTests to use the new name for tvm
authored
13 include TinyVolumeManager
8f18726 Joe Thornber add tags to tests
authored
14 include Utils
15
c2ebc4d Heinz Mauelshagen Introduce limit_metadata_dev_size and fix potentially too large metadata...
mauelsha authored
16 def setup
17 super
18
19 @block_size = 128
20 end
21
22 def limit_data_dev_size(size)
23 max_size = 1024 * 2048 # 1GB
24 size = max_size if size > max_size
25 size
26 end
27
8f18726 Joe Thornber add tags to tests
authored
28 tag :thinp_target, :quick
9dcb226 Joe Thornber start working on the multiple pool scenarios
authored
29
30 def test_two_pools_pointing_to_the_same_metadata_fails
e60028c Joe Thornber RuntimeError -> ExitError in lots of assert_raise
authored
31 assert_raise(ExitError) do
9dcb226 Joe Thornber start working on the multiple pool scenarios
authored
32 with_standard_pool(@size) do |pool1|
33 with_standard_pool(@size) do |pool2|
34 # shouldn't get here
35 end
36 end
37 end
38 end
39
8f18726 Joe Thornber add tags to tests
authored
40 tag :thinp_target, :slow
41
9dcb226 Joe Thornber start working on the multiple pool scenarios
authored
42 def test_two_pools_can_create_thins
43 # carve up the data device into two metadata volumes and two data
44 # volumes.
18424f7 Joe Thornber change MultiplePoolTests to use the new name for tvm
authored
45 tvm = VM.new
49f7476 Joe Thornber fix bugs in test_two_pools_can_create_thins
authored
46 tvm.add_allocation_volume(@data_dev, 0, dev_size(@data_dev))
9dcb226 Joe Thornber start working on the multiple pool scenarios
authored
47
c2ebc4d Heinz Mauelshagen Introduce limit_metadata_dev_size and fix potentially too large metadata...
mauelsha authored
48 md_size = limit_metadata_dev_size(tvm.free_space / 16)
125002b Joe Thornber first step toward supporting different volume types in tvm
authored
49 1.upto(2) {|id| tvm.add_volume(linear_vol("md_#{id}", md_size))}
9dcb226 Joe Thornber start working on the multiple pool scenarios
authored
50
c2ebc4d Heinz Mauelshagen Introduce limit_metadata_dev_size and fix potentially too large metadata...
mauelsha authored
51 data_size = limit_data_dev_size(round_up(tvm.free_space / 8, @block_size))
125002b Joe Thornber first step toward supporting different volume types in tvm
authored
52 1.upto(2) {|id| tvm.add_volume(linear_vol("data_#{id}", data_size))}
9dcb226 Joe Thornber start working on the multiple pool scenarios
authored
53
54 # Activate. We need a component that automates this from a
55 # description of the system.
49f7476 Joe Thornber fix bugs in test_two_pools_can_create_thins
authored
56 with_devs(tvm.table('md_1'),
57 tvm.table('md_2'),
58 tvm.table('data_1'),
59 tvm.table('data_2')) do |md_1, md_2, data_1, data_2|
9dcb226 Joe Thornber start working on the multiple pool scenarios
authored
60
61 # zero the metadata so we get a fresh pool
62 wipe_device(md_1, 8)
63 wipe_device(md_2, 8)
64
c2ebc4d Heinz Mauelshagen Introduce limit_metadata_dev_size and fix potentially too large metadata...
mauelsha authored
65 with_devs(Table.new(ThinPool.new(data_size, md_1, data_1, @block_size, 1)),
66 Table.new(ThinPool.new(data_size, md_2, data_2, @block_size, 1))) do |pool1, pool2|
9dcb226 Joe Thornber start working on the multiple pool scenarios
authored
67
68 with_new_thin(pool1, data_size, 0) do |thin1|
69 with_new_thin(pool2, data_size, 0) do |thin2|
70 in_parallel(thin1, thin2) {|t| dt_device(t)}
71 end
72 end
73 end
74 end
75 end
a4ec6fe Joe Thornber tests_stacked_pools
authored
76
77 # creates a pool on dev, and creates as big a thin as possible on
78 # that
fb735be Joe Thornber tweak test_stacked_pools
authored
79 def with_pool_volume(dev, max_size = nil)
18424f7 Joe Thornber change MultiplePoolTests to use the new name for tvm
authored
80 tvm = VM.new
fb735be Joe Thornber tweak test_stacked_pools
authored
81 ds = dev_size(dev)
82 ds = [ds, max_size].min unless max_size.nil?
83 tvm.add_allocation_volume(dev, 0, ds)
a4ec6fe Joe Thornber tests_stacked_pools
authored
84
c2ebc4d Heinz Mauelshagen Introduce limit_metadata_dev_size and fix potentially too large metadata...
mauelsha authored
85 md_size = limit_metadata_dev_size(tvm.free_space / 16)
125002b Joe Thornber first step toward supporting different volume types in tvm
authored
86 tvm.add_volume(linear_vol('md', md_size))
c2ebc4d Heinz Mauelshagen Introduce limit_metadata_dev_size and fix potentially too large metadata...
mauelsha authored
87 data_size = limit_data_dev_size(tvm.free_space)
125002b Joe Thornber first step toward supporting different volume types in tvm
authored
88 tvm.add_volume(linear_vol('data', data_size))
a4ec6fe Joe Thornber tests_stacked_pools
authored
89
90 with_devs(tvm.table('md'),
91 tvm.table('data')) do |md, data|
92
93 # zero the metadata so we get a fresh pool
94 wipe_device(md, 8)
95
c2ebc4d Heinz Mauelshagen Introduce limit_metadata_dev_size and fix potentially too large metadata...
mauelsha authored
96 with_devs(Table.new(ThinPool.new(data_size, md, data, @block_size, 1))) do |pool|
d1f31d7 Heinz Mauelshagen More straemlining
mauelsha authored
97 with_new_thin(pool, data_size, 0) {|thin| yield(thin)}
a4ec6fe Joe Thornber tests_stacked_pools
authored
98 end
99 end
100 end
101
102 def test_stacked_pools
fb735be Joe Thornber tweak test_stacked_pools
authored
103 with_pool_volume(@data_dev, @volume_size) do |layer1|
a4ec6fe Joe Thornber tests_stacked_pools
authored
104 with_pool_volume(layer1) do |layer2|
d1f31d7 Heinz Mauelshagen More straemlining
mauelsha authored
105 with_pool_volume(layer2) {|layer3| dt_device(layer3)}
a4ec6fe Joe Thornber tests_stacked_pools
authored
106 end
107 end
108 end
9dcb226 Joe Thornber start working on the multiple pool scenarios
authored
109 end
Something went wrong with that request. Please try again.