diff --git a/integration_data/elasticsearch-cluster-v1-compose.yml b/integration_data/elasticsearch-cluster-v1-compose.yml deleted file mode 100644 index e69de29..0000000 diff --git a/integration_data/elasticsearch-cluster-v2-compose.yml b/integration_data/elasticsearch-cluster-v2-compose.yml deleted file mode 100644 index e69de29..0000000 diff --git a/integration_data/integrationtest.txt b/integration_data/integrationtest.txt deleted file mode 100644 index 8193da1..0000000 --- a/integration_data/integrationtest.txt +++ /dev/null @@ -1,9 +0,0 @@ -docker compose up - -write documents - -create repository - -make snapshot - -restore snapshot diff --git a/integration_data/elasticsearch-cluster-v5-compose.yml b/integration_data/v5/elasticsearch-cluster-v5-compose.yml similarity index 90% rename from integration_data/elasticsearch-cluster-v5-compose.yml rename to integration_data/v5/elasticsearch-cluster-v5-compose.yml index d954793..a473d40 100644 --- a/integration_data/elasticsearch-cluster-v5-compose.yml +++ b/integration_data/v5/elasticsearch-cluster-v5-compose.yml @@ -11,6 +11,7 @@ services: - cluster.name=vulcanizer-elasticsearch-v5 - node.name=vulcanizer-elasticsearch-v5 - bootstrap.memory_lock=true + - "path.repo=/backups" - "ES_JAVA_OPTS=-Xms512M -Xmx512M" - xpack.security.enabled=false - xpack.monitoring.enabled=false @@ -30,6 +31,8 @@ services: - 49200:9200 networks: - esnet + volumes: + - backup-volume:/backups elasticsearch-v5-2: build: @@ -43,6 +46,7 @@ services: - cluster.name=vulcanizer-elasticsearch-v5 - bootstrap.memory_lock=true - node.name=vulcanizer-elasticsearch-v5-2 + - "path.repo=/backups" - "discovery.zen.ping.unicast.hosts=vulcanizer-elasticsearch-v5" - "ES_JAVA_OPTS=-Xms512M -Xmx512M" - xpack.security.enabled=false @@ -61,6 +65,11 @@ services: - IPC_LOCK networks: - esnet + volumes: + - backup-volume:/backups networks: esnet: + +volumes: + backup-volume: diff --git a/integration_data/elasticsearch-v5.dockerfile b/integration_data/v5/elasticsearch-v5.dockerfile similarity index 100% rename from integration_data/elasticsearch-v5.dockerfile rename to integration_data/v5/elasticsearch-v5.dockerfile diff --git a/integration_test.go b/integration_test.go index 00c076d..5c4a56b 100644 --- a/integration_test.go +++ b/integration_test.go @@ -39,3 +39,31 @@ func TestIndices(t *testing.T) { t.Fatalf("Expected 10 docs, got: %v", indices[0].DocumentCount) } } + +func TestVerifyRepository(t *testing.T) { + c := vulcanizer.NewClient("localhost", 49200) + + verified, err := c.VerifyRepository("backup-repo") + + if err != nil { + t.Fatalf("Error verifying repositories: %s", err) + } + + if !verified { + t.Fatalf("Expected to backup-repo to be a verified repository") + } +} + +func TestGetSnapshotStatus(t *testing.T) { + c := vulcanizer.NewClient("localhost", 49200) + + snapshot, err := c.GetSnapshotStatus("backup-repo", "snapshot_1") + + if err != nil { + t.Fatalf("Error getting snapshot status: %s", err) + } + + if snapshot.State != "SUCCESS" { + t.Fatalf("Expected snapshot to be a success: %+v", snapshot) + } +} diff --git a/script/integration-test b/script/integration-test index 31190d8..49afd9d 100755 --- a/script/integration-test +++ b/script/integration-test @@ -3,10 +3,12 @@ set -e ./script/build -cd integration_data/ +cd integration_data/v5 docker-compose -f elasticsearch-cluster-v5-compose.yml up -d -sleep 20 -curl -H "Content-Type: application/x-ndjson" -XPOST localhost:49200/_bulk --data-binary "@documents.dat"; echo +sleep 10 +curl --retry 5 --retry-delay 5 --retry-connrefused -H "Content-Type: application/x-ndjson" -XPOST localhost:49200/_bulk --data-binary "@../documents.dat"; echo +curl -XPUT localhost:49200/_snapshot/backup-repo -d '{ "type": "fs", "settings": { "location": "/backups" } }' +curl -XPUT localhost:49200/_snapshot/backup-repo/snapshot_1?wait_for_completion=true # Run tests go test -v github.com/github/vulcanizer/... -tags integration