|
13 | 13 | import io.weaviate.client6.v1.api.collections.Property; |
14 | 14 | import io.weaviate.client6.v1.api.collections.Replication; |
15 | 15 | import io.weaviate.client6.v1.api.collections.VectorIndex; |
| 16 | +import io.weaviate.client6.v1.api.collections.config.Shard; |
| 17 | +import io.weaviate.client6.v1.api.collections.config.ShardStatus; |
16 | 18 | import io.weaviate.client6.v1.api.collections.vectorindex.Hnsw; |
17 | 19 | import io.weaviate.client6.v1.api.collections.vectorizers.NoneVectorizer; |
18 | 20 | import io.weaviate.containers.Container; |
@@ -159,4 +161,27 @@ public void testUpdateCollection() throws IOException { |
159 | 161 | .extracting(CollectionConfig::replication).returns(false, Replication::asyncEnabled); |
160 | 162 | }); |
161 | 163 | } |
| 164 | + |
| 165 | + @Test |
| 166 | + public void testShards() throws IOException { |
| 167 | + var nsShatteredCups = ns("ShatteredCups"); |
| 168 | + client.collections.create(nsShatteredCups); |
| 169 | + var cups = client.collections.use(nsShatteredCups); |
| 170 | + |
| 171 | + // Act: get initial shard state |
| 172 | + var shards = cups.config.getShards(); |
| 173 | + |
| 174 | + Assertions.assertThat(shards).as("single-tenant collections has 1 shard").hasSize(1); |
| 175 | + var singleShard = shards.get(0); |
| 176 | + |
| 177 | + // Act: flip the status |
| 178 | + var wantStatus = singleShard.status().equals("READY") ? ShardStatus.READONLY : ShardStatus.READY; |
| 179 | + var updated = cups.config.updateShards(wantStatus, singleShard.name()); |
| 180 | + |
| 181 | + Assertions.assertThat(updated) |
| 182 | + .as("shard status changed") |
| 183 | + .hasSize(1) |
| 184 | + .extracting(Shard::status) |
| 185 | + .containsOnly(wantStatus.name()); |
| 186 | + } |
162 | 187 | } |
0 commit comments