Skip to content

Commit e7f4f2d

Browse files
authored
Merge pull request #523 from weaviate/v6-object-ttl
v6: Object TTL
2 parents 92bebd1 + 889a488 commit e7f4f2d

File tree

11 files changed

+302
-133
lines changed

11 files changed

+302
-133
lines changed

.github/workflows/test.yaml

Lines changed: 88 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -19,103 +19,103 @@ jobs:
1919
name: Cache shared Docker images
2020
runs-on: ubuntu-latest
2121
steps:
22-
- name: Login to Docker Hub
23-
if: ${{ !github.event.pull_request.head.repo.fork }}
24-
uses: docker/login-action@v3
25-
with:
26-
username: ${{ secrets.DOCKER_USERNAME }}
27-
password: ${{ secrets.DOCKER_PASSWORD }}
28-
- id: cache-check
29-
uses: actions/cache/restore@v4
30-
env:
31-
DOCKER_CACHE_KEY: docker-images-${{ env.IMG2VEC }}-${{ env.MINIO }}-${{ env.MODEL2VEC }}
32-
with:
33-
path: ${{ env.DOCKER_IMAGES_TAR }}
34-
key: ${{ env.DOCKER_CACHE_KEY }}
35-
lookup-only: true # Only check if cache exists, don't download
36-
- name: Free Disk Space (Ubuntu)
37-
uses: jlumbroso/[email protected]
38-
with:
39-
tool-cache: false
40-
android: true
41-
dotnet: true
42-
haskell: true
43-
large-packages: true
44-
docker-images: false
45-
swap-storage: false
46-
- name: Pull images
47-
if: steps.cache-check.outputs.cache-hit != 'true'
48-
run: |
49-
docker pull $IMG2VEC
50-
docker pull $MINIO
51-
# docker pull $MODEL2VEC
52-
docker save $IMG2VEC $MINIO -o $DOCKER_IMAGES_TAR
53-
- name: Cache images
54-
if: steps.cache-check.outputs.cache-hit != 'true'
55-
uses: actions/cache/save@v4
56-
env:
57-
DOCKER_CACHE_KEY: docker-images-${{ env.IMG2VEC }}-${{ env.MINIO }}-${{ env.MODEL2VEC }}
58-
with:
59-
path: ${{ env.DOCKER_IMAGES_TAR }}
60-
key: ${{ env.DOCKER_CACHE_KEY }}
22+
- name: Login to Docker Hub
23+
if: ${{ !github.event.pull_request.head.repo.fork }}
24+
uses: docker/login-action@v3
25+
with:
26+
username: ${{ secrets.DOCKER_USERNAME }}
27+
password: ${{ secrets.DOCKER_PASSWORD }}
28+
- id: cache-check
29+
uses: actions/cache/restore@v4
30+
env:
31+
DOCKER_CACHE_KEY: docker-images-${{ env.IMG2VEC }}-${{ env.MINIO }}-${{ env.MODEL2VEC }}
32+
with:
33+
path: ${{ env.DOCKER_IMAGES_TAR }}
34+
key: ${{ env.DOCKER_CACHE_KEY }}
35+
lookup-only: true # Only check if cache exists, don't download
36+
- name: Free Disk Space (Ubuntu)
37+
uses: jlumbroso/[email protected]
38+
with:
39+
tool-cache: false
40+
android: true
41+
dotnet: true
42+
haskell: true
43+
large-packages: true
44+
docker-images: false
45+
swap-storage: false
46+
- name: Pull images
47+
if: steps.cache-check.outputs.cache-hit != 'true'
48+
run: |
49+
docker pull $IMG2VEC
50+
docker pull $MINIO
51+
# docker pull $MODEL2VEC
52+
docker save $IMG2VEC $MINIO -o $DOCKER_IMAGES_TAR
53+
- name: Cache images
54+
if: steps.cache-check.outputs.cache-hit != 'true'
55+
uses: actions/cache/save@v4
56+
env:
57+
DOCKER_CACHE_KEY: docker-images-${{ env.IMG2VEC }}-${{ env.MINIO }}-${{ env.MODEL2VEC }}
58+
with:
59+
path: ${{ env.DOCKER_IMAGES_TAR }}
60+
key: ${{ env.DOCKER_CACHE_KEY }}
6161

6262
maven-cache:
63-
name: Cache Maven dependencies
64-
runs-on: ubuntu-latest
65-
steps:
66-
- uses: actions/checkout@v4
67-
- uses: actions/setup-java@v4
68-
with:
69-
distribution: 'zulu'
70-
java-version: '17'
71-
cache: 'maven'
72-
- run: mvn dependency:go-offline
63+
name: Cache Maven dependencies
64+
runs-on: ubuntu-latest
65+
steps:
66+
- uses: actions/checkout@v4
67+
- uses: actions/setup-java@v4
68+
with:
69+
distribution: "zulu"
70+
java-version: "17"
71+
cache: "maven"
72+
- run: mvn dependency:go-offline
7373

7474
test:
7575
name: Test
7676
runs-on: ubuntu-latest
77-
needs: [ docker-cache, maven-cache]
77+
needs: [docker-cache, maven-cache]
7878
strategy:
7979
fail-fast: false
8080
matrix:
81-
WEAVIATE_VERSION: ["1.32.16", "1.33.4", "1.34.0"]
81+
WEAVIATE_VERSION: ["1.32.24", "1.33.11", "1.34.7", "1.35.2"]
8282
steps:
83-
- uses: actions/checkout@v4
83+
- uses: actions/checkout@v4
8484

85-
- uses: actions/cache/restore@v4
86-
env:
87-
DOCKER_CACHE_KEY: docker-images-${{ env.IMG2VEC }}-${{ env.MINIO }}-${{ env.MODEL2VEC }}
88-
with:
89-
path: ${{ env.DOCKER_IMAGES_TAR }}
90-
key: ${{ env.DOCKER_CACHE_KEY }}
91-
- name: Free Disk Space (Ubuntu)
92-
uses: jlumbroso/[email protected]
93-
with:
94-
tool-cache: false
95-
android: true
96-
dotnet: true
97-
haskell: true
98-
large-packages: true
99-
docker-images: false
100-
swap-storage: false
101-
- name: Load Docker images
102-
run: |
103-
if [ -f $DOCKER_IMAGES_TAR ]; then
104-
docker load -i $DOCKER_IMAGES_TAR
105-
fi
106-
- uses: actions/setup-java@v4
107-
name: Setup JDK
108-
with:
109-
distribution: 'zulu'
110-
java-version: '17'
111-
cache: 'maven'
85+
- uses: actions/cache/restore@v4
86+
env:
87+
DOCKER_CACHE_KEY: docker-images-${{ env.IMG2VEC }}-${{ env.MINIO }}-${{ env.MODEL2VEC }}
88+
with:
89+
path: ${{ env.DOCKER_IMAGES_TAR }}
90+
key: ${{ env.DOCKER_CACHE_KEY }}
91+
- name: Free Disk Space (Ubuntu)
92+
uses: jlumbroso/[email protected]
93+
with:
94+
tool-cache: false
95+
android: true
96+
dotnet: true
97+
haskell: true
98+
large-packages: true
99+
docker-images: false
100+
swap-storage: false
101+
- name: Load Docker images
102+
run: |
103+
if [ -f $DOCKER_IMAGES_TAR ]; then
104+
docker load -i $DOCKER_IMAGES_TAR
105+
fi
106+
- uses: actions/setup-java@v4
107+
name: Setup JDK
108+
with:
109+
distribution: "zulu"
110+
java-version: "17"
111+
cache: "maven"
112112

113-
- name: Run Tests (v${{ matrix.WEAVIATE_VERSION }})
114-
env:
115-
OKTA_DUMMY_CI_PW: ${{ secrets.OKTA_DUMMY_CI_PW }}
116-
WCS_DUMMY_CI_PW: ${{ secrets.WCS_DUMMY_CI_PW }}
117-
OKTA_CLIENT_SECRET: ${{ secrets.OKTA_CLIENT_SECRET }}
118-
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
119-
OPENAI_APIKEY: ${{ secrets.OPENAI_APIKEY }}
120-
WEAVIATE_VERSION: ${{ matrix.WEAVIATE_VERSION }}
121-
run: mvn verify -Dgpg.skip
113+
- name: Run Tests (v${{ matrix.WEAVIATE_VERSION }})
114+
env:
115+
OKTA_DUMMY_CI_PW: ${{ secrets.OKTA_DUMMY_CI_PW }}
116+
WCS_DUMMY_CI_PW: ${{ secrets.WCS_DUMMY_CI_PW }}
117+
OKTA_CLIENT_SECRET: ${{ secrets.OKTA_CLIENT_SECRET }}
118+
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
119+
OPENAI_APIKEY: ${{ secrets.OPENAI_APIKEY }}
120+
WEAVIATE_VERSION: ${{ matrix.WEAVIATE_VERSION }}
121+
run: mvn verify -Dgpg.skip

src/it/java/io/weaviate/containers/Weaviate.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
public class Weaviate extends WeaviateContainer {
2828
public static final String DOCKER_IMAGE = "semitechnologies/weaviate";
29-
public static final String LATEST_VERSION = Version.V134.semver.toString();
29+
public static final String LATEST_VERSION = Version.V135.semver.toString();
3030
public static final String VERSION;
3131

3232
static {
@@ -38,9 +38,10 @@ public class Weaviate extends WeaviateContainer {
3838
private final String containerName;
3939

4040
public enum Version {
41-
V132(1, 32, 16),
42-
V133(1, 33, 4),
43-
V134(1, 34, 0);
41+
V132(1, 32, 24),
42+
V133(1, 33, 11),
43+
V134(1, 34, 7),
44+
V135(1, 35, 2);
4445

4546
public final SemanticVersion semver;
4647

@@ -259,6 +260,15 @@ public Builder enableAnonymousAccess(boolean enable) {
259260
return this;
260261
}
261262

263+
/** User default OIDC provider for integration tests. */
264+
public Builder withOIDC() {
265+
return withOIDC(
266+
"Peuc12y02UA0eAED1dqSjE5HtGUrpBsx",
267+
"https://auth.weaviate.cloud/Peuc12y02UA0eAED1dqSjE5HtGUrpBsx",
268+
"email", "roles");
269+
270+
}
271+
262272
public Builder withOIDC(String clientId, String issuer, String usernameClaim, String groupsClaim) {
263273
enableAnonymousAccess(false);
264274
environment.put("AUTHENTICATION_OIDC_ENABLED", "true");

src/it/java/io/weaviate/integration/CollectionsITest.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import io.weaviate.client6.v1.api.collections.DataType;
1414
import io.weaviate.client6.v1.api.collections.Generative;
1515
import io.weaviate.client6.v1.api.collections.InvertedIndex;
16+
import io.weaviate.client6.v1.api.collections.ObjectTtl;
1617
import io.weaviate.client6.v1.api.collections.Property;
1718
import io.weaviate.client6.v1.api.collections.Quantization;
1819
import io.weaviate.client6.v1.api.collections.ReferenceProperty;
@@ -21,6 +22,7 @@
2122
import io.weaviate.client6.v1.api.collections.config.Shard;
2223
import io.weaviate.client6.v1.api.collections.config.ShardStatus;
2324
import io.weaviate.client6.v1.api.collections.generative.DummyGenerative;
25+
import io.weaviate.client6.v1.api.collections.query.BaseQueryOptions;
2426
import io.weaviate.client6.v1.api.collections.vectorindex.Hnsw;
2527
import io.weaviate.client6.v1.api.collections.vectorizers.SelfProvidedVectorizer;
2628
import io.weaviate.containers.Container;
@@ -275,4 +277,55 @@ public void test_updateGenerative() throws IOException {
275277
.extracting(CollectionConfig::generativeModule).isNotNull()
276278
.returns(Generative.Kind.DUMMY, Generative::_kind);
277279
}
280+
281+
@Test
282+
public void test_objectTtl() throws IOException {
283+
Weaviate.Version.V135.orSkip();
284+
285+
// Arrange
286+
var nsThings = ns("Things");
287+
288+
// Act: create collection
289+
var things = client.collections.create(nsThings,
290+
c -> c.objectTtl(ttl -> ttl
291+
.deleteByCreationTime()
292+
.defaultTtlSeconds(120)));
293+
294+
// Assert: correct Object TTL config
295+
var created = things.config.get();
296+
297+
Assertions.assertThat(created).get()
298+
.as("created collection")
299+
.extracting(CollectionConfig::objectTtl).isNotNull()
300+
.returns(true, ObjectTtl::enabled)
301+
.returns(BaseQueryOptions.CREATION_TIME_PROPERTY, ObjectTtl::deleteOn)
302+
.returns(120, ObjectTtl::defaultTtlSeconds);
303+
304+
// Act: update TTL config
305+
things.config.update(
306+
c -> c.objectTtl(ttl -> ttl
307+
.deleteByUpdateTime()
308+
.defaultTtlSeconds(400)));
309+
310+
// Assert: correct Object TTL config
311+
var updated = things.config.get();
312+
313+
Assertions.assertThat(updated).get()
314+
.as("updated collection")
315+
.extracting(CollectionConfig::objectTtl).isNotNull()
316+
.returns(true, ObjectTtl::enabled)
317+
.returns(BaseQueryOptions.LAST_UPDATE_TIME_PROPERTY, ObjectTtl::deleteOn)
318+
.returns(400, ObjectTtl::defaultTtlSeconds);
319+
320+
// Act: disable TTL config
321+
things.config.update(c -> c.objectTtl(ttl -> ttl.enabled(false)));
322+
323+
// Assert: correct Object TTL config
324+
var disabled = things.config.get();
325+
326+
Assertions.assertThat(disabled).get()
327+
.as("disabled object TTL")
328+
.extracting(CollectionConfig::objectTtl).isNotNull()
329+
.returns(false, ObjectTtl::enabled);
330+
}
278331
}

0 commit comments

Comments
 (0)