Beispiel #1
0
    def run_compare(self):
        self.pre_sanity_check_args()
        self.set_origin_crushmap(self.args.origin)
        self.set_destination_crushmap(self.args.destination)
        self.post_sanity_check_args()

        if self.args.origin_weights:
            with open(self.args.origin_weights) as f_ow:
                self.orig_weights = Crush.parse_weights_file(f_ow)
        if self.args.destination_weights:
            with open(self.args.destination_weights) as f_dw:
                self.dest_weights = Crush.parse_weights_file(f_dw)

        self.compare()
Beispiel #2
0
    def test_parse_weights_file(self):

        # Test Simple weights file
        weights = Crush.parse_weights_file(open("tests/ceph/weights.json"))
        assert weights == {"osd.0": 0.0, "osd.2": 0.5}

        # Test OSDMap
        weights = Crush.parse_weights_file(open("tests/ceph/osdmap.json"))
        assert weights == {"osd.0": 1.0, "osd.1": 0.95, "osd.2": 1.0}

        with pytest.raises(AssertionError):
            Crush.parse_weights_file(open("tests/ceph/weights-notfloat.json"))
        with pytest.raises(AssertionError):
            Crush.parse_weights_file(open("tests/ceph/osdmap-invalid.json"))
        with pytest.raises(AssertionError):
            Crush.parse_weights_file(open("tests/sample-ceph-crushmap.txt"))