Ejemplo n.º 1
0
 def test_display(self):
     c1, c2 = self.define_crushmaps_1()
     c = Main().constructor([
         'compare',
         '--rule', 'indep',
         '--replication-count', '2',
         '--values-count', '10',
     ])
     c.set_origin(c1)
     c.set_destination(c2)
     c.compare()
     out = c.display()
     print(out)
     assert 'device04        0        0        1        1   10.00%' in out
     assert 'objects%   10.00%    5.00%    5.00%    5.00%   25.00%' in out
Ejemplo n.º 2
0
    def test_compare(self):
        c1, c2 = self.define_crushmaps_1()

        # firstn, mapping order does not matter
        c = Main().constructor([
            'compare',
            '--rule', 'firstn',
            '--replication-count', '2',
            '--values-count', '10',
        ])

        # device05 is removed
        c.set_origin(c1)
        c.set_destination(c2)
        assert c.compare() == {
            'device04': {'device17': 1},
            'device05': {'device12': 1, 'device04': 2, 'device08': 1}
        }
        # device05 is added
        c.set_origin(c2)
        c.set_destination(c1)
        assert c.compare() == {
            'device12': {'device05': 1},
            'device17': {'device04': 1},
            'device04': {'device05': 2},
            'device08': {'device05': 1}
        }

        # indep, mapping order matters
        c = Main().constructor([
            'compare',
            '--rule', 'indep',
            '--replication-count', '2',
            '--values-count', '10',
            '--order-matters',
        ])
        # device05 is removed
        c.set_origin(c1)
        c.set_destination(c2)
        assert c.compare() == {
            'device04': {'device13': 1, 'device17': 1},
            'device05': {'device04': 2, 'device08': 1}
        }
        # device05 is added
        c.set_origin(c2)
        c.set_destination(c1)
        assert c.compare() == {
            'device13': {'device04': 1},
            'device17': {'device04': 1},
            'device04': {'device05': 2},
            'device08': {'device05': 1}
        }
Ejemplo n.º 3
0
 def test_compare_display(self):
     c = Main().constructor([
         'compare',
         '--rule', 'firstn',
         '--values-count', '1000',
     ])
     c1, c2 = self.define_crushmaps_2()
     c.set_origin(c2)
     c.set_destination(c1)
     c.args.replication_count = 1
     c.compare()
     out = c.display()
     print(out)
     assert "objects%   10.20%   12.70%   22.90%" in out
     c.args.replication_count = 3
     c.compare()
     out = c.display()
     print(out)
     assert ("objects%    0.17%    0.13%    0.97%    0.77%    0.77%"
             "    0.63%    0.73%    0.87%   12.30%   12.20%   29.53%") in out