@@ -1381,6 +1381,73 @@ func TestSnapshotAllIndices(t *testing.T) {
1381
1381
}
1382
1382
}
1383
1383
1384
+
func TestSnapshotAllIndicesWithAdditionalParameters(t *testing.T) {
1385
+
testSetup := &ServerSetup{
1386
+
Method: "PUT",
1387
+
Path: "/_snapshot/backup-repo/snapshot1",
1388
+
Body: `{"metadata":{"taken_because":"backup before upgrading","taken_by":"user123"}}`,
1389
+
Response: `{"acknowledged": true }`,
1390
+
}
1391
+
1392
+
host, port, ts := setupTestServers(t, []*ServerSetup{testSetup})
1393
+
defer ts.Close()
1394
+
client := NewClient(host, port)
1395
+
1396
+
bodyParams := map[string]interface{}{
1397
+
"metadata": map[string]interface{}{
1398
+
"taken_by": "user123",
1399
+
"taken_because": "backup before upgrading",
1400
+
},
1401
+
}
1402
+
1403
+
err := client.SnapshotAllIndicesWithBodyParams("backup-repo", "snapshot1", bodyParams)
1404
+
1405
+
if err != nil {
1406
+
t.Fatalf("Got error taking snapshot: %s", err)
1407
+
}
1408
+
}
1409
+
1410
+
func TestSnapshotAllIndicesWithAdditionalParametersIncludeGlobalState(t *testing.T) {
1411
+
testSetup := &ServerSetup{
1412
+
Method: "PUT",
1413
+
Path: "/_snapshot/backup-repo/snapshot1",
1414
+
Body: `{"include_global_state":true}`,
1415
+
Response: `{"acknowledged": true }`,
1416
+
}
1417
+
1418
+
host, port, ts := setupTestServers(t, []*ServerSetup{testSetup})
1419
+
defer ts.Close()
1420
+
client := NewClient(host, port)
1421
+
1422
+
bodyParams := map[string]interface{}{
1423
+
"include_global_state": true,
1424
+
}
1425
+
1426
+
err := client.SnapshotAllIndicesWithBodyParams("backup-repo", "snapshot1", bodyParams)
1427
+
1428
+
if err != nil {
1429
+
t.Fatalf("Got error taking snapshot: %s", err)
1430
+
}
1431
+
}
1432
+
1433
+
func TestSnapshotAllIndicesWithAdditionalParametersNilValue(t *testing.T) {
1434
+
testSetup := &ServerSetup{
1435
+
Method: "PUT",
1436
+
Path: "/_snapshot/backup-repo/snapshot1",
1437
+
Response: `{"acknowledged": true }`,
1438
+
}
1439
+
1440
+
host, port, ts := setupTestServers(t, []*ServerSetup{testSetup})
1441
+
defer ts.Close()
1442
+
client := NewClient(host, port)
1443
+
1444
+
err := client.SnapshotAllIndicesWithBodyParams("backup-repo", "snapshot1", nil)
1445
+
1446
+
if err != nil {
1447
+
t.Fatalf("Should be able to take Nil body params: %s", err)
1448
+
}
1449
+
}
1450
+
1384
1451
func TestRestoreSnapshotIndices_ErrorConditions(t *testing.T) {
1385
1452
tt := []struct {
1386
1453
Name string
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4