Skip to content

Commit

Permalink
Add tests for Vector Collection backup config
Browse files Browse the repository at this point in the history
  • Loading branch information
olukas committed Nov 14, 2024
1 parent c932a50 commit 9a082ad
Showing 1 changed file with 62 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,21 @@ def test_backupCount_valid_values_pass(self):
name, [IndexConfig("vector", Metric.COSINE, 3)], backup_count=2, async_backup_count=2
)

def test_backupCount(self):
def test_backupCount_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
)

def test_backupCount_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
)

def test_backupCount_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 +208,32 @@ def test_backupCount(self):
async_backup_count=0,
)

def test_asyncBackupCount(self):
def test_backupCount_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_asyncBackupCount_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,
)

def test_asyncBackupCount_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
)

def test_asyncBackupCount_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 +246,27 @@ def test_asyncBackupCount(self):
async_backup_count=7,
)

def test_asyncBackupCount_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_asyncBackupCount_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 9a082ad

Please sign in to comment.