All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rest-api-spec.test.indices.clone.40_wait_for_completion.yml Maven / Gradle / Ivy

The newest version!
---
"Clone index with wait_for_completion":
  # clone index with wait_for_completion parameter, when the parameter is set to false, the API
  # will return a task immediately and the clone operation will run in background.

  - skip:
      version: " - 2.6.99"
      reason: "only available in 2.7+"
      features: allowed_warnings

  - do:
      nodes.info:
        node_id: data:true
  - set:
      nodes._arbitrary_key_: node_id

  - do:
      indices.create:
        index: source
        wait_for_active_shards: 1
        body:
          settings:
            # ensure everything is allocated on the same data node
            index.routing.allocation.include._id: $node_id
            index.number_of_shards: 1
            index.number_of_replicas: 0
  - do:
      index:
        index: source
        id:    "1"
        body:  { "foo": "hello world" }

  - do:
      get:
        index: source
        id:    "1"

  - match: { _index:   source }
  - match: { _id:      "1"     }
  - match: { _source:  { foo: "hello world" } }

  # make it read-only
  - do:
      indices.put_settings:
        index: source
        body:
          index.blocks.write: true
          index.number_of_replicas: 0

  - do:
      cluster.health:
        wait_for_status: green
        index: source

  # clone with wait_for_completion
  - do:
      indices.clone:
        index: "source"
        target: "new_cloned_index"
        wait_for_active_shards: 1
        cluster_manager_timeout: 10s
        wait_for_completion: false
        task_execution_timeout: 30s
        body:
          settings:
            index.number_of_shards: 1
            "index.number_of_replicas": 0

  - match: { task: /^.+$/ }
  - set: { task: taskId }

  - do:
      tasks.get:
        wait_for_completion: true
        task_id: $taskId
  - match: { task.action: "indices:admin/resize" }
  - match: { task.description: "clone from [source] to [new_cloned_index]" }

  # .tasks index is created when the clone index operation completes, so we should delete .tasks index finally,
  # if not, the .tasks index may introduce unexpected warnings and then cause other test cases to fail.
  # Delete the .tasks index directly will also introduce warning, but currently we don't have such APIs which can delete one
  # specified task or clear all completed tasks, so we have to do so. Expect we can introduce more tasks related APIs in future
  - do:
      allowed_warnings:
        - "this request accesses system indices: [.tasks], but in a future major version, direct access to system indices will be prevented by default"
      indices.delete:
        index: .tasks
        ignore_unavailable: true




© 2015 - 2024 Weber Informatics LLC | Privacy Policy