Skip to content

Commit

Permalink
Add tests for Vector Collection backup config (#711)
Browse files Browse the repository at this point in the history
Add tests for setting Vector Collection `backup_count` and
`async_backup_count` configuration.
  • Loading branch information
olukas authored Nov 15, 2024
1 parent a5fd26f commit 0274025
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 4 deletions.
2 changes: 1 addition & 1 deletion hazelcast/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "5.5.0"
__version__ = "6.0.0"

# Set the default handler to "hazelcast" loggers
# to avoid "No handlers could be found" warnings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,31 @@ def test_size(self):
self.vector_collection.clear()
self.assertEqual(self.vector_collection.size(), 0)

def test_backupCount_valid_values_pass(self):
def test_backup_count_valid_values_pass(self):
skip_if_client_version_older_than(self, "6.0")
name = random_string()
self.client.create_vector_collection_config(
name, [IndexConfig("vector", Metric.COSINE, 3)], backup_count=2, async_backup_count=2
)
self.client.get_vector_collection(name).blocking()

def test_backupCount(self):
def test_backup_count_max_value_pass(self):
skip_if_client_version_older_than(self, "6.0")
name = random_string()
self.client.create_vector_collection_config(
name, [IndexConfig("vector", Metric.COSINE, 3)], backup_count=6
)
self.client.get_vector_collection(name).blocking()

def test_backup_count_min_value_pass(self):
skip_if_client_version_older_than(self, "6.0")
name = random_string()
self.client.create_vector_collection_config(
name, [IndexConfig("vector", Metric.COSINE, 3)], backup_count=0
)
self.client.get_vector_collection(name).blocking()

def test_backup_count_more_than_max_value_fail(self):
skip_if_server_version_older_than(self, self.client, "6.0")
name = random_string()
# check that the parameter is used by ensuring that it is validated on server side
Expand All @@ -194,7 +211,34 @@ def test_backupCount(self):
async_backup_count=0,
)

def test_asyncBackupCount(self):
def test_backup_count_less_than_min_value_fail(self):
skip_if_server_version_older_than(self, self.client, "6.0")
name = random_string()
with self.assertRaises(hazelcast.errors.IllegalArgumentError):
self.client.create_vector_collection_config(
name, [IndexConfig("vector", Metric.COSINE, 3)], backup_count=-1
)

def test_async_backup_count_max_value_pass(self):
skip_if_client_version_older_than(self, "6.0")
name = random_string()
self.client.create_vector_collection_config(
name,
[IndexConfig("vector", Metric.COSINE, 3)],
backup_count=0,
async_backup_count=6,
)
self.client.get_vector_collection(name).blocking()

def test_async_backup_count_min_value_pass(self):
skip_if_client_version_older_than(self, "6.0")
name = random_string()
self.client.create_vector_collection_config(
name, [IndexConfig("vector", Metric.COSINE, 3)], async_backup_count=0
)
self.client.get_vector_collection(name).blocking()

def test_async_backup_count_more_than_max_value_fail(self):
skip_if_server_version_older_than(self, self.client, "6.0")
name = random_string()
# check that the parameter is used by ensuring that it is validated on server side
Expand All @@ -207,6 +251,27 @@ def test_asyncBackupCount(self):
async_backup_count=7,
)

def test_async_backup_count_less_than_min_value_fail(self):
skip_if_server_version_older_than(self, self.client, "6.0")
name = random_string()
with self.assertRaises(hazelcast.errors.IllegalArgumentError):
self.client.create_vector_collection_config(
name,
[IndexConfig("vector", Metric.COSINE, 3)],
async_backup_count=-1,
)

def test_sync_and_async_backup_count_more_than_max_value_fail(self):
skip_if_server_version_older_than(self, self.client, "6.0")
name = random_string()
with self.assertRaises(hazelcast.errors.IllegalArgumentError):
self.client.create_vector_collection_config(
name,
[IndexConfig("vector", Metric.COSINE, 3)],
backup_count=4,
async_backup_count=3,
)

def assert_document_equal(self, doc1, doc2) -> None:
self.assertEqual(doc1.value, doc2.value)
self.assertEqual(len(doc1.vectors), len(doc2.vectors))
Expand Down

0 comments on commit 0274025

Please sign in to comment.