Exemplo n.º 1
0
    def test_cuboids_exist_with_cache_miss(self, fake_get_region):
        """Test method for checking if cuboids exist in S3 index while supporting
        the cache miss key index parameter"""
        os = AWSObjectStore(self.object_store_config)

        expected_keys = [
            "CACHED-CUBOID&1&1&1&0&0&12", "CACHED-CUBOID&1&1&1&0&0&13",
            "CACHED-CUBOID&1&1&1&0&0&14"
        ]
        test_keys = [
            "CACHED-CUBOID&1&1&1&0&0&100", "CACHED-CUBOID&1&1&1&0&0&13",
            "CACHED-CUBOID&1&1&1&0&0&14", "CACHED-CUBOID&1&1&1&0&0&15"
        ]

        expected_object_keys = os.cached_cuboid_to_object_keys(expected_keys)

        # Populate table
        for k in expected_object_keys:
            os.add_cuboid_to_index(k)

        # Check for keys
        exist_keys, missing_keys = os.cuboids_exist(test_keys, [1, 2])

        assert exist_keys == [1, 2]
        assert missing_keys == []
Exemplo n.º 2
0
    def test_cached_cuboid_to_object_keys_str(self):
        """Test to check key conversion from cached cuboid to object"""

        cached_cuboid_keys = "CACHED-CUBOID&1&1&1&0&0&12"

        os = AWSObjectStore(self.object_store_config)
        object_keys = os.cached_cuboid_to_object_keys(cached_cuboid_keys)

        assert len(object_keys) == 1
        assert object_keys[0] == '6b5ebb14395dec6cd9d7edaa1fbcd748&1&1&1&0&0&12'
Exemplo n.º 3
0
    def test_cached_cuboid_to_object_keys(self):
        """Test to check key conversion from cached cuboid to object"""

        cached_cuboid_keys = ["CACHED-CUBOID&1&1&1&0&0&12", "CACHED-CUBOID&1&1&1&0&0&13"]

        os = AWSObjectStore(self.object_store_config)
        object_keys = os.cached_cuboid_to_object_keys(cached_cuboid_keys)

        assert len(object_keys) == 2
        assert object_keys[0] == '6b5ebb14395dec6cd9d7edaa1fbcd748&1&1&1&0&0&12'
        assert object_keys[1] == '592ed5f40528bb16bce769fed5b2e9c6&1&1&1&0&0&13'
Exemplo n.º 4
0
    def test_put_get_single_object(self):
        """Method to test putting and getting objects to and from S3"""
        os = AWSObjectStore(self.object_store_config)

        cached_cuboid_keys = ["CACHED-CUBOID&1&1&1&0&0&12"]
        fake_data = [b"aaaadddffffaadddfffaadddfff"]

        object_keys = os.cached_cuboid_to_object_keys(cached_cuboid_keys)

        os.put_objects(object_keys, fake_data)

        returned_data = os.get_single_object(object_keys[0])
        assert fake_data[0] == returned_data
Exemplo n.º 5
0
    def test_put_get_objects_syncronous(self):
        """Method to test putting and getting objects to and from S3"""
        os = AWSObjectStore(self.object_store_config)

        cached_cuboid_keys = ["CACHED-CUBOID&1&1&1&0&0&12", "CACHED-CUBOID&1&1&1&0&0&13"]
        fake_data = [b"aaaadddffffaadddfffaadddfff", b"fffddaaffddffdfffaaa"]

        object_keys = os.cached_cuboid_to_object_keys(cached_cuboid_keys)

        os.put_objects(object_keys, fake_data)

        returned_data = os.get_objects(object_keys)
        for rdata, sdata in zip(returned_data, fake_data):
            assert rdata == sdata
Exemplo n.º 6
0
    def test_cuboids_exist(self):
        """Test method for checking if cuboids exist in S3 index"""
        os = AWSObjectStore(self.object_store_config)

        expected_keys = ["CACHED-CUBOID&1&1&1&0&0&12", "CACHED-CUBOID&1&1&1&0&0&13", "CACHED-CUBOID&1&1&1&0&0&14"]
        test_keys = ["CACHED-CUBOID&1&1&1&0&0&100", "CACHED-CUBOID&1&1&1&0&0&13", "CACHED-CUBOID&1&1&1&0&0&14",
                     "CACHED-CUBOID&1&1&1&0&0&15"]

        expected_object_keys = os.cached_cuboid_to_object_keys(expected_keys)

        # Populate table
        for k in expected_object_keys:
            os.add_cuboid_to_index(k)

        # Check for keys
        exist_keys, missing_keys = os.cuboids_exist(test_keys)

        assert exist_keys == [1, 2]
        assert missing_keys == [0, 3]