]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crushtool: extent cli test to include --remove-item and --update-item
authorSage Weil <sage@newdream.net>
Wed, 2 May 2012 20:45:21 +0000 (13:45 -0700)
committerSage Weil <sage@newdream.net>
Wed, 2 May 2012 21:55:53 +0000 (14:55 -0700)
Signed-off-by: Sage Weil <sage@newdream.net>
src/test/cli/crushtool/add-item.t
src/test/cli/crushtool/help.t
src/test/cli/crushtool/simple.template.five [new file with mode: 0644]
src/test/cli/crushtool/simple.template.four [new file with mode: 0644]
src/test/cli/crushtool/simple.template.one [new file with mode: 0644]
src/test/cli/crushtool/simple.template.out [deleted file]
src/test/cli/crushtool/simple.template.three [new file with mode: 0644]
src/test/cli/crushtool/simple.template.two [new file with mode: 0644]

index aa5c23ce24d7535bc990a27d5a267a24770a1c63..80b91da59dcf443269ed58439121f06dd9c28576 100644 (file)
@@ -1,4 +1,12 @@
   $ crushtool -i "$TESTDIR/simple.template" --add-item 0 1.0 device0 --loc host host0 --loc cluster cluster0 -o one > /dev/null
   $ crushtool -i one --add-item 1 1.0 device1 --loc host host0 --loc cluster cluster0 -o two > /dev/null
   $ crushtool -d two -o final
-  $ cmp final "$TESTDIR/simple.template.out"
+  $ cmp final "$TESTDIR/simple.template.two"
+  $ crushtool -i two --add-item 1 1.0 device1 --loc host host0 --loc cluster cluster0 -o three 2>/dev/null >/dev/null || echo FAIL
+  FAIL
+  $ crushtool -i two --remove-item device1 -o four > /dev/null
+  $ crushtool -d four -o final
+  $ cmp final "$TESTDIR/simple.template.four"
+  $ crushtool -i two --update-item 1 2.0 osd1 --loc host host1 --loc cluster cluster0 -o five > /dev/null
+  $ crushtool -d five -o final
+  $ cmp final "$TESTDIR/simple.template.five"
index 7f91c1cbc3dac94d57d022888310f730dbffbda0..af411aee9908adf38de4af893101b77cf39ca6a9 100644 (file)
@@ -17,6 +17,9 @@
      -i mapfn --add-item id weight name [--loc type name ...]
                            insert an item into the hierarchy at the
                            given location
+     -i mapfn --update-item id weight name [--loc type name ...]
+                           insert or move an item into the hierarchy at the
+                           given location
      -i mapfn --remove-item name
                            remove the given item
      -i mapfn --reweight-item name weight
diff --git a/src/test/cli/crushtool/simple.template.five b/src/test/cli/crushtool/simple.template.five
new file mode 100644 (file)
index 0000000..240e81d
--- /dev/null
@@ -0,0 +1,65 @@
+# begin crush map
+
+# devices
+device 0 device0
+device 1 osd1
+
+# types
+type 0 device
+type 1 host
+type 2 cluster
+
+# buckets
+host host0 {
+       id -2           # do not change unnecessarily
+       # weight 1.000
+       alg straw
+       hash 0  # rjenkins1
+       item device0 weight 1.000
+}
+host host1 {
+       id -3           # do not change unnecessarily
+       # weight 2.000
+       alg straw
+       hash 0  # rjenkins1
+       item osd1 weight 2.000
+}
+cluster cluster0 {
+       id -1           # do not change unnecessarily
+       # weight 3.000
+       alg straw
+       hash 0  # rjenkins1
+       item host0 weight 1.000
+       item host1 weight 2.000
+}
+
+# rules
+rule data {
+       ruleset 0
+       type replicated
+       min_size 1
+       max_size 10
+       step take cluster0
+       step chooseleaf firstn 0 type host
+       step emit
+}
+rule metadata {
+       ruleset 1
+       type replicated
+       min_size 1
+       max_size 10
+       step take cluster0
+       step chooseleaf firstn 0 type host
+       step emit
+}
+rule rbd {
+       ruleset 2
+       type replicated
+       min_size 1
+       max_size 10
+       step take cluster0
+       step chooseleaf firstn 0 type host
+       step emit
+}
+
+# end crush map
diff --git a/src/test/cli/crushtool/simple.template.four b/src/test/cli/crushtool/simple.template.four
new file mode 100644 (file)
index 0000000..aa16bbd
--- /dev/null
@@ -0,0 +1,56 @@
+# begin crush map
+
+# devices
+device 0 device0
+
+# types
+type 0 device
+type 1 host
+type 2 cluster
+
+# buckets
+host host0 {
+       id -2           # do not change unnecessarily
+       # weight 1.000
+       alg straw
+       hash 0  # rjenkins1
+       item device0 weight 1.000
+}
+cluster cluster0 {
+       id -1           # do not change unnecessarily
+       # weight 1.000
+       alg straw
+       hash 0  # rjenkins1
+       item host0 weight 1.000
+}
+
+# rules
+rule data {
+       ruleset 0
+       type replicated
+       min_size 1
+       max_size 10
+       step take cluster0
+       step chooseleaf firstn 0 type host
+       step emit
+}
+rule metadata {
+       ruleset 1
+       type replicated
+       min_size 1
+       max_size 10
+       step take cluster0
+       step chooseleaf firstn 0 type host
+       step emit
+}
+rule rbd {
+       ruleset 2
+       type replicated
+       min_size 1
+       max_size 10
+       step take cluster0
+       step chooseleaf firstn 0 type host
+       step emit
+}
+
+# end crush map
diff --git a/src/test/cli/crushtool/simple.template.one b/src/test/cli/crushtool/simple.template.one
new file mode 100644 (file)
index 0000000..9a3aee7
--- /dev/null
@@ -0,0 +1,58 @@
+# begin crush map
+
+# devices
+device 0 device0
+device 1 device1
+
+# types
+type 0 device
+type 1 host
+type 2 cluster
+
+# buckets
+host host0 {
+       id -2           # do not change unnecessarily
+       # weight 2.000
+       alg straw
+       hash 0  # rjenkins1
+       item device0 weight 1.000
+       item device1 weight 1.000
+}
+cluster cluster0 {
+       id -1           # do not change unnecessarily
+       # weight 2.000
+       alg straw
+       hash 0  # rjenkins1
+       item host0 weight 2.000
+}
+
+# rules
+rule data {
+       ruleset 0
+       type replicated
+       min_size 1
+       max_size 10
+       step take cluster0
+       step chooseleaf firstn 0 type host
+       step emit
+}
+rule metadata {
+       ruleset 1
+       type replicated
+       min_size 1
+       max_size 10
+       step take cluster0
+       step chooseleaf firstn 0 type host
+       step emit
+}
+rule rbd {
+       ruleset 2
+       type replicated
+       min_size 1
+       max_size 10
+       step take cluster0
+       step chooseleaf firstn 0 type host
+       step emit
+}
+
+# end crush map
diff --git a/src/test/cli/crushtool/simple.template.out b/src/test/cli/crushtool/simple.template.out
deleted file mode 100644 (file)
index 9a3aee7..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-# begin crush map
-
-# devices
-device 0 device0
-device 1 device1
-
-# types
-type 0 device
-type 1 host
-type 2 cluster
-
-# buckets
-host host0 {
-       id -2           # do not change unnecessarily
-       # weight 2.000
-       alg straw
-       hash 0  # rjenkins1
-       item device0 weight 1.000
-       item device1 weight 1.000
-}
-cluster cluster0 {
-       id -1           # do not change unnecessarily
-       # weight 2.000
-       alg straw
-       hash 0  # rjenkins1
-       item host0 weight 2.000
-}
-
-# rules
-rule data {
-       ruleset 0
-       type replicated
-       min_size 1
-       max_size 10
-       step take cluster0
-       step chooseleaf firstn 0 type host
-       step emit
-}
-rule metadata {
-       ruleset 1
-       type replicated
-       min_size 1
-       max_size 10
-       step take cluster0
-       step chooseleaf firstn 0 type host
-       step emit
-}
-rule rbd {
-       ruleset 2
-       type replicated
-       min_size 1
-       max_size 10
-       step take cluster0
-       step chooseleaf firstn 0 type host
-       step emit
-}
-
-# end crush map
diff --git a/src/test/cli/crushtool/simple.template.three b/src/test/cli/crushtool/simple.template.three
new file mode 100644 (file)
index 0000000..9a3aee7
--- /dev/null
@@ -0,0 +1,58 @@
+# begin crush map
+
+# devices
+device 0 device0
+device 1 device1
+
+# types
+type 0 device
+type 1 host
+type 2 cluster
+
+# buckets
+host host0 {
+       id -2           # do not change unnecessarily
+       # weight 2.000
+       alg straw
+       hash 0  # rjenkins1
+       item device0 weight 1.000
+       item device1 weight 1.000
+}
+cluster cluster0 {
+       id -1           # do not change unnecessarily
+       # weight 2.000
+       alg straw
+       hash 0  # rjenkins1
+       item host0 weight 2.000
+}
+
+# rules
+rule data {
+       ruleset 0
+       type replicated
+       min_size 1
+       max_size 10
+       step take cluster0
+       step chooseleaf firstn 0 type host
+       step emit
+}
+rule metadata {
+       ruleset 1
+       type replicated
+       min_size 1
+       max_size 10
+       step take cluster0
+       step chooseleaf firstn 0 type host
+       step emit
+}
+rule rbd {
+       ruleset 2
+       type replicated
+       min_size 1
+       max_size 10
+       step take cluster0
+       step chooseleaf firstn 0 type host
+       step emit
+}
+
+# end crush map
diff --git a/src/test/cli/crushtool/simple.template.two b/src/test/cli/crushtool/simple.template.two
new file mode 100644 (file)
index 0000000..9a3aee7
--- /dev/null
@@ -0,0 +1,58 @@
+# begin crush map
+
+# devices
+device 0 device0
+device 1 device1
+
+# types
+type 0 device
+type 1 host
+type 2 cluster
+
+# buckets
+host host0 {
+       id -2           # do not change unnecessarily
+       # weight 2.000
+       alg straw
+       hash 0  # rjenkins1
+       item device0 weight 1.000
+       item device1 weight 1.000
+}
+cluster cluster0 {
+       id -1           # do not change unnecessarily
+       # weight 2.000
+       alg straw
+       hash 0  # rjenkins1
+       item host0 weight 2.000
+}
+
+# rules
+rule data {
+       ruleset 0
+       type replicated
+       min_size 1
+       max_size 10
+       step take cluster0
+       step chooseleaf firstn 0 type host
+       step emit
+}
+rule metadata {
+       ruleset 1
+       type replicated
+       min_size 1
+       max_size 10
+       step take cluster0
+       step chooseleaf firstn 0 type host
+       step emit
+}
+rule rbd {
+       ruleset 2
+       type replicated
+       min_size 1
+       max_size 10
+       step take cluster0
+       step chooseleaf firstn 0 type host
+       step emit
+}
+
+# end crush map