예제 #1
0
 def test_build_seed(self):
     bucket = Builder(addresses["alpha"], my_shard_size, my_max_size,
                      debug=True)
     hash0 = fixtures["test_build_seed"]["hash0"]
     hash3 = fixtures["test_build_seed"]["hash3"]
     self.assertEqual(bucket.build_seed(0), hash0)
     self.assertEqual(bucket.build_seed(3), hash3)
예제 #2
0
    def test_builder_clean(self):
        # generate shards for testing
        bucket = Builder(addresses["delta"], my_shard_size, my_max_size, debug=True)
        bucket.build(self.store_path)

        # see if the shards exist
        for shard_num in range(height):
            path = os.path.join(self.store_path, bucket.build_seed(shard_num))
            self.assertTrue(os.path.exists(path))

        # clean command
        bucket.clean(self.store_path)

        # see if the shards are deleted
        for shard_num in range(height):
            path = os.path.join(self.store_path, bucket.build_seed(shard_num))
            self.assertFalse(os.path.exists(path))
예제 #3
0
    def test_builder_build(self):
        # generate shards for testing
        bucket = Builder(addresses["beta"], my_shard_size, my_max_size)
        bucket.build(self.store_path)

        # see if the shards exist
        for shard_num in range(height):
            path = os.path.join(self.store_path, bucket.build_seed(shard_num))
            print("PATH", path)
            self.assertTrue(os.path.exists(path))

        bucket.clean(self.store_path)

        # generate shards for testing
        bucket = Builder(addresses["gamma"], my_shard_size, my_max_size)
        bucket.build(self.store_path, cleanup=True)

        # see if the shards are deleted
        for shard_num in range(height):
            path = os.path.join(self.store_path, bucket.build_seed(shard_num))
            self.assertFalse(os.path.exists(path))
예제 #4
0
    def test_builder_rebuilds(self):
        bucket = Builder(addresses["epsilon"], my_shard_size, my_max_size, debug=True)

        # generate empty files to be rebuilt
        for shard_num in range(height):
            path = os.path.join(self.store_path, bucket.build_seed(shard_num))
            with open(path, 'a'):
                os.utime(path, None)

        # rebuild all files
        bucket.build(self.store_path, rebuild=True)

        # audit full
        expected = fixtures["test_builder_audit"]["expected"]
        audit_results = bucket.full_audit(b"storj", self.store_path,
                                          height)
        self.assertEqual(audit_results, expected)
예제 #5
0
    def test_on_KeyboardInterrupt(self):
        def _raise(height, last):
            if not last: # only raise 1 of 2 calls
                raise KeyboardInterrupt()

        # generate 1 file with KeyboadInterrupt
        bucket = Builder(addresses["epsilon"], my_shard_size, my_max_size,
                         my_min_free_size, on_generate_shard=_raise)
        self.assertTrue(bucket.build(store_path=self.store_path))
        
        # 1 of 2 files exists and no bad files
        for shard_num in range(height):
            path = os.path.join(self.store_path, bucket.build_seed(shard_num))
            if shard_num <= 0:
                self.assertTrue(os.path.exists(path) 
                                and os.path.getsize(path) == my_shard_size)
            else:
                self.assertFalse(os.path.exists(path))
예제 #6
0
    def test_on_KeyboardInterrupt(self):
        def _raise(height, last):
            if not last:  # only raise 1 of 2 calls
                raise KeyboardInterrupt()

        # generate 1 file with KeyboadInterrupt
        bucket = Builder(addresses["epsilon"],
                         my_shard_size,
                         my_max_size,
                         my_min_free_size,
                         on_generate_shard=_raise)
        self.assertTrue(bucket.build(store_path=self.store_path))

        # 1 of 2 files exists and no bad files
        for shard_num in range(height):
            path = os.path.join(self.store_path, bucket.build_seed(shard_num))
            if shard_num <= 0:
                self.assertTrue(
                    os.path.exists(path)
                    and os.path.getsize(path) == my_shard_size)
            else:
                self.assertFalse(os.path.exists(path))
예제 #7
0
 def test_build_seed(self):
     bucket = Builder(addresses["alpha"], my_shard_size, my_max_size)
     hash0 = fixtures["test_build_seed"]["hash0"]
     hash3 = fixtures["test_build_seed"]["hash3"]
     self.assertEqual(bucket.build_seed(0), hash0)
     self.assertEqual(bucket.build_seed(3), hash3)
예제 #8
0
 def test_build_seed(self):
     bucket = Builder(addresses["alpha"], 0, 0)  # emtpy bucket
     hash0 = fixtures["test_build_seed"]["hash0"]
     hash3 = fixtures["test_build_seed"]["hash3"]
     self.assertEqual(bucket.build_seed(0), hash0)
     self.assertEqual(bucket.build_seed(3), hash3)
예제 #9
0
 def test_build_seed(self):
     bucket = Builder(addresses["alpha"], 0, 0)  # emtpy bucket
     hash0 = fixtures["test_build_seed"]["hash0"]
     hash3 = fixtures["test_build_seed"]["hash3"]
     self.assertEqual(bucket.build_seed(0), hash0)
     self.assertEqual(bucket.build_seed(3), hash3)