Skip to content

Commit b39aa04

Browse files
committed
feat: add BackupGetter to the public API
1 parent d15dc68 commit b39aa04

File tree

2 files changed

+60
-49
lines changed

2 files changed

+60
-49
lines changed

src/backup/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Connection from '../connection/index.js';
22
import BackupCreateStatusGetter from './backupCreateStatusGetter.js';
33
import BackupCreator from './backupCreator.js';
4+
import BackupGetter from './backupGetter.js';
45
import BackupRestoreStatusGetter from './backupRestoreStatusGetter.js';
56
import BackupRestorer from './backupRestorer.js';
67

@@ -13,6 +14,7 @@ export interface Backup {
1314
createStatusGetter: () => BackupCreateStatusGetter;
1415
restorer: () => BackupRestorer;
1516
restoreStatusGetter: () => BackupRestoreStatusGetter;
17+
getter: () => BackupGetter;
1618
}
1719

1820
const backup = (client: Connection): Backup => {
@@ -21,11 +23,13 @@ const backup = (client: Connection): Backup => {
2123
createStatusGetter: () => new BackupCreateStatusGetter(client),
2224
restorer: () => new BackupRestorer(client, new BackupRestoreStatusGetter(client)),
2325
restoreStatusGetter: () => new BackupRestoreStatusGetter(client),
26+
getter: () => new BackupGetter(client),
2427
};
2528
};
2629

2730
export default backup;
2831
export { default as BackupCreateStatusGetter } from './backupCreateStatusGetter.js';
2932
export { default as BackupCreator } from './backupCreator.js';
33+
export { default as BackupGetter } from './backupGetter.js';
3034
export { default as BackupRestoreStatusGetter } from './backupRestoreStatusGetter.js';
3135
export { default as BackupRestorer } from './backupRestorer.js';

src/backup/journey.test.ts

Lines changed: 56 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
import weaviate, { WeaviateClient } from '../v2/index.js';
88
import { Backend } from './index.js';
99

10+
import { requireAtLeast } from '../../test/version';
1011
const {
1112
createTestFoodSchemaAndData,
1213
cleanupTestFood,
@@ -950,55 +951,61 @@ describe('fails restoring backup with invalid compression config', () => {
950951
it('cleans up', () => cleanupTestFood(client));
951952
});
952953

953-
// describe("get all exising backups", () => {
954-
// const BACKEND: Backend = 'filesystem';
955-
// const BACKUP_ID = randomBackupId()
956-
// const BACKUP_ID_PIZZA = BACKUP_ID + "-pizza";
957-
// const BACKUP_ID_SOUP = BACKUP_ID + "-soup";
958-
959-
// const client = weaviate.client({
960-
// scheme: "http",
961-
// host: "localhost:8080",
962-
// });
963-
964-
// it("sets up", () => createTestFoodSchemaAndData(client));
965-
966-
// it("creates backup pizza", () => {
967-
// return client.backup.creator()
968-
// .withIncludeClassNames(PIZZA_CLASS_NAME)
969-
// .withBackend(BACKEND)
970-
// .withBackupId(BACKUP_ID_PIZZA)
971-
// .withWaitForCompletion(true)
972-
// .do()
973-
// .catch((err: any) => {throw new Error("should not fail on create backup: " + err)});
974-
// });
975-
976-
// it("creates backup soup", () => {
977-
// return client.backup.creator()
978-
// .withIncludeClassNames(SOUP_CLASS_NAME)
979-
// .withBackend(BACKEND)
980-
// .withBackupId(BACKUP_ID_SOUP)
981-
// .withWaitForCompletion(true)
982-
// .do()
983-
// .catch((err: any) => {throw new Error("should not fail on create backup: " + err)});
984-
// });
985-
986-
// it("get all", () => {
987-
// return client.backup.getter()
988-
// .withBackend(BACKEND)
989-
// .do()
990-
// .then(allResponse => {
991-
// expect(allResponse).toHaveLength(2);
992-
// expect(allResponse).toEqual(expect.arrayContaining([
993-
// expect.objectContaining({id: BACKUP_ID_PIZZA}),
994-
// expect.objectContaining({id: BACKUP_ID_SOUP}),
995-
// ]));
996-
// })
997-
// .catch((err: any) => {throw new Error("should not fail on getting all: " + err)});
998-
// });
999-
1000-
// it("cleans up", () => cleanupTestFood(client));
1001-
// });
954+
requireAtLeast(1, 30, 0).describe('get all exising backups', () => {
955+
const BACKEND: Backend = 'filesystem';
956+
const BACKUP_ID = randomBackupId();
957+
const BACKUP_ID_PIZZA = BACKUP_ID + '-pizza';
958+
const BACKUP_ID_SOUP = BACKUP_ID + '-soup';
959+
960+
const client = weaviate.client({
961+
scheme: 'http',
962+
host: 'localhost:8080',
963+
});
964+
965+
it('sets up', () => createTestFoodSchemaAndData(client));
966+
967+
it('creates backup pizza', () => {
968+
return client.backup
969+
.creator()
970+
.withIncludeClassNames(PIZZA_CLASS_NAME)
971+
.withBackend(BACKEND)
972+
.withBackupId(BACKUP_ID_PIZZA)
973+
.withWaitForCompletion(true)
974+
.do()
975+
.catch((err: any) => {
976+
throw new Error('should not fail on create backup: ' + err);
977+
});
978+
});
979+
980+
it('creates backup soup', () => {
981+
return client.backup
982+
.creator()
983+
.withIncludeClassNames(SOUP_CLASS_NAME)
984+
.withBackend(BACKEND)
985+
.withBackupId(BACKUP_ID_SOUP)
986+
.withWaitForCompletion(true)
987+
.do()
988+
.catch((err: any) => {
989+
throw new Error('should not fail on create backup: ' + err);
990+
});
991+
});
992+
993+
it('get all', () => {
994+
return client.backup
995+
.getter()
996+
.withBackend(BACKEND)
997+
.do()
998+
.then((allResponse) => {
999+
const relevant = allResponse.filter((b) => b.id === BACKUP_ID_SOUP || b.id === BACKUP_ID_PIZZA);
1000+
expect(relevant).toHaveLength(2);
1001+
})
1002+
.catch((err: any) => {
1003+
throw new Error('should not fail on getting all: ' + err);
1004+
});
1005+
});
1006+
1007+
it('cleans up', () => cleanupTestFood(client));
1008+
});
10021009

10031010
function assertThatAllPizzasExist(client: WeaviateClient) {
10041011
return assertThatAllFoodObjectsExist(client, 'Pizza', 4);

0 commit comments

Comments
 (0)