From 5ebcf183e5f4296628423b07b1cdff19e9631ab3 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Mon, 21 Dec 2015 17:02:50 -0500 Subject: [PATCH] tests --- .../test/hdfs_repository/10_basic.yaml | 2 + .../hdfs_repository/20_repository_create.yaml | 18 ++++-- .../hdfs_repository/20_repository_verify.yaml | 23 +++++++ .../test/hdfs_repository/30_snapshot.yaml | 27 ++++++--- .../test/hdfs_repository/30_snapshot_get.yaml | 60 +++++++++++++++++++ .../test/hdfs_repository/40_restore.yaml | 30 +++++++--- 6 files changed, 138 insertions(+), 22 deletions(-) create mode 100644 plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/20_repository_verify.yaml create mode 100644 plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/30_snapshot_get.yaml diff --git a/plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/10_basic.yaml b/plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/10_basic.yaml index 75c64d82d2d..7c569408a61 100644 --- a/plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/10_basic.yaml +++ b/plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/10_basic.yaml @@ -15,8 +15,10 @@ - match: { nodes.$master.plugins.0.name: repository-hdfs } - match: { nodes.$master.plugins.0.jvm: true } --- +# # Check that we can't use file:// repositories or anything like that # We only test this plugin against hdfs:// +# "HDFS only": - do: catch: /Invalid scheme/ diff --git a/plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/20_repository_create.yaml b/plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/20_repository_create.yaml index 06e33c53257..0f942dfdc03 100644 --- a/plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/20_repository_create.yaml +++ b/plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/20_repository_create.yaml @@ -2,20 +2,26 @@ # # Tests creating a repository # -"HDFS Repository Config": +"HDFS Repository Creation": + # Create repository - do: snapshot.create_repository: - repository: test_repo_hdfs_1 + repository: test_repository_create body: type: hdfs settings: uri: "hdfs://localhost:9999" - path: "foo/bar" + path: "test/repository_create" # Get repository - do: snapshot.get_repository: - repository: test_repo_hdfs_1 + repository: test_repository_create - - is_true: test_repo_hdfs_1 - - match: {test_repo_hdfs_1.settings.path : "foo/bar"} + - is_true: test_repository_create + - match: {test_repository_create.settings.path : "test/repository_create"} + + # Remove our repository + - do: + snapshot.delete_repository: + repository: test_repository_create diff --git a/plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/20_repository_verify.yaml b/plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/20_repository_verify.yaml new file mode 100644 index 00000000000..d1695b00d9d --- /dev/null +++ b/plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/20_repository_verify.yaml @@ -0,0 +1,23 @@ +# Integration tests for HDFS Repository plugin +# +# Tests explicit verify +# +"HDFS Repository Verify": + - do: + snapshot.create_repository: + repository: test_repository_verify + body: + type: hdfs + settings: + uri: "hdfs://localhost:9999" + path: "test/repository_verify" + + # Verify repository + - do: + snapshot.verify_repository: + repository: test_repository_verify + + # Remove our repository + - do: + snapshot.delete_repository: + repository: test_repository_verify diff --git a/plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/30_snapshot.yaml b/plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/30_snapshot.yaml index a7af512666c..7db9a429230 100644 --- a/plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/30_snapshot.yaml +++ b/plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/30_snapshot.yaml @@ -3,17 +3,18 @@ # Actually perform a snapshot to hdfs # --- -setup: - +"take snapshot": + # Create repository - do: snapshot.create_repository: - repository: test_repo_hdfs_snapshot + repository: test_snapshot_repository body: type: hdfs settings: uri: "hdfs://localhost:9999" - path: "foo/bar" + path: "test/snapshot" + # Create index - do: indices.create: index: test_index @@ -22,16 +23,15 @@ setup: number_of_shards: 1 number_of_replicas: 1 + # Wait for yellow - do: cluster.health: wait_for_status: yellow ---- -"Create a snapshot": - + # Create snapshot - do: snapshot.create: - repository: test_repo_hdfs_snapshot + repository: test_snapshot_repository snapshot: test_snapshot wait_for_completion: true @@ -40,3 +40,14 @@ setup: - match: { snapshot.shards.successful: 1 } - match: { snapshot.shards.failed : 0 } + # Remove our snapshot + - do: + snapshot.delete: + repository: test_snapshot_repository + snapshot: test_snapshot + + # Remove our repository + - do: + snapshot.delete_repository: + repository: test_snapshot_repository + diff --git a/plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/30_snapshot_get.yaml b/plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/30_snapshot_get.yaml new file mode 100644 index 00000000000..5819cc32db1 --- /dev/null +++ b/plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/30_snapshot_get.yaml @@ -0,0 +1,60 @@ +# Integration tests for HDFS Repository plugin +# +# Tests retrieving information about snapshot +# +--- +"Get a snapshot": + # Create repository + - do: + snapshot.create_repository: + repository: test_snapshot_get_repository + body: + type: hdfs + settings: + uri: "hdfs://localhost:9999" + path: "test/snapshot_get" + + # Create index + - do: + indices.create: + index: test_index + body: + settings: + number_of_shards: 1 + number_of_replicas: 0 + + # Wait for green + - do: + cluster.health: + wait_for_status: green + + # Create snapshot + - do: + snapshot.create: + repository: test_snapshot_get_repository + snapshot: test_snapshot_get + wait_for_completion: true + + - match: { snapshot.snapshot: test_snapshot_get } + - match: { snapshot.state : SUCCESS } + - match: { snapshot.shards.successful: 1 } + - match: { snapshot.shards.failed : 0 } + + # Get snapshot info + - do: + snapshot.get: + repository: test_snapshot_get_repository + snapshot: test_snapshot_get + + - match: { snapshots.0.snapshot : test_snapshot_get } + + # Remove our snapshot + - do: + snapshot.delete: + repository: test_snapshot_get_repository + snapshot: test_snapshot_get + + # Remove our repository + - do: + snapshot.delete_repository: + repository: test_snapshot_get_repository diff --git a/plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/40_restore.yaml b/plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/40_restore.yaml index 2327b5da906..47559226275 100644 --- a/plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/40_restore.yaml +++ b/plugins/repository-hdfs/src/test/resources/rest-api-spec/test/hdfs_repository/40_restore.yaml @@ -3,17 +3,19 @@ # Actually perform a snapshot to hdfs, then restore it # --- -setup: +"Create a snapshot and then restore it": + # Create repository - do: snapshot.create_repository: - repository: test_repo_hdfs_restore + repository: test_restore_repository body: type: hdfs settings: uri: "hdfs://localhost:9999" - path: "foo/bar" + path: "test/restore" + # Create index - do: indices.create: index: test_index @@ -22,16 +24,15 @@ setup: number_of_shards: 1 number_of_replicas: 0 + # Wait for green - do: cluster.health: wait_for_status: green ---- -"Create a snapshot and then restore it": - + # Take snapshot - do: snapshot.create: - repository: test_repo_hdfs_restore + repository: test_restore_repository snapshot: test_restore wait_for_completion: true @@ -42,16 +43,19 @@ setup: - is_true: snapshot.version - gt: { snapshot.version_id: 0} + # Close index - do: indices.close: index : test_index + # Restore index - do: snapshot.restore: - repository: test_repo_hdfs_restore + repository: test_restore_repository snapshot: test_restore wait_for_completion: true + # Check recovery stats - do: indices.recovery: index: test_index @@ -63,3 +67,13 @@ setup: - match: { test_index.shards.0.index.files.reused: 0} - match: { test_index.shards.0.index.size.reused_in_bytes: 0} + # Remove our snapshot + - do: + snapshot.delete: + repository: test_restore_repository + snapshot: test_restore + + # Remove our repository + - do: + snapshot.delete_repository: + repository: test_restore_repository