Use random http port for watcher REST tests (elastic/x-pack-elasticsearch#936)

Adapts the Watcher REST tests so that they don't require a fixed http port anymore.

Original commit: elastic/x-pack-elasticsearch@14919b16e7
This commit is contained in:
Yannick Welsch 2017-04-04 09:02:23 +02:00 committed by GitHub
parent edb8c543ed
commit e52fbdf63c
5 changed files with 133 additions and 112 deletions

View File

@ -10,7 +10,6 @@ integTestCluster {
plugin ':x-pack-elasticsearch:plugin' plugin ':x-pack-elasticsearch:plugin'
setting 'xpack.security.enabled', 'false' setting 'xpack.security.enabled', 'false'
setting 'xpack.monitoring.enabled', 'false' setting 'xpack.monitoring.enabled', 'false'
setting 'http.port', '9400'
setting 'script.inline', 'true' setting 'script.inline', 'true'
setting 'script.stored', 'true' setting 'script.stored', 'true'
// Need to allow more compilations per minute because of the integration tests // Need to allow more compilations per minute because of the integration tests

View File

@ -4,41 +4,51 @@
cluster.health: cluster.health:
wait_for_status: yellow wait_for_status: yellow
# extract http host and port from master node
- do:
cluster.state: {}
- set: { master_node: master }
- do:
nodes.info:
metric: [ http ]
- is_true: nodes.$master.http.publish_address
- set: { nodes.$master.http.publish_address: host }
- do:
ingest.simulate:
body:
pipeline:
description: _description
processors: [ grok: { field: host, patterns : ["%{IPORHOST:hostname}:%{NUMBER:port:int}"]} ]
docs: [ { _index: index, _type: type, _id: id, _source: { host: $host } } ]
- set: { docs.0.doc._source.hostname: hostname }
- set: { docs.0.doc._source.port: port }
- do: - do:
xpack.watcher.put_watch: xpack.watcher.put_watch:
id: "test_watch" id: "test_watch"
body: > body:
{ trigger:
"trigger": { schedule:
"schedule": { interval: 1s
"interval": "1s" input:
} simple:
}, key: value
"input": { condition:
"simple" : { always: {}
"key" : "value" actions:
} output:
}, webhook:
"condition": { method: PUT
"always" : {} host: $hostname
}, port: $port
"actions": { path: "/my_index/my_type/{{ctx.watch_id}}"
"output": { body:
"webhook" : { inline:
"method" : "PUT", watch_id: "{{ctx.watch_id}}"
"host" : "localhost", params: {}
"port" : 9400,
"path": "/my_index/my_type/{{ctx.watch_id}}",
"body" : {
"inline": {
"watch_id" : "{{ctx.watch_id}}"
},
"params": {}
}
}
}
}
}
- match: { _id: "test_watch" } - match: { _id: "test_watch" }
- match: { created: true } - match: { created: true }

View File

@ -16,50 +16,56 @@
- match: { "watcher_state": "started" } - match: { "watcher_state": "started" }
- match: { "watch_count": 0 } - match: { "watch_count": 0 }
# extract http host and port from master node
- do:
cluster.state: {}
- set: { master_node: master }
- do:
nodes.info:
metric: [ http ]
- is_true: nodes.$master.http.publish_address
- set: { nodes.$master.http.publish_address: host }
- do:
ingest.simulate:
body:
pipeline:
description: _description
processors: [ grok: { field: host, patterns : ["%{IPORHOST:hostname}:%{NUMBER:port:int}"] } ]
docs: [ { _index: index, _type: type, _id: id, _source: { host: $host } } ]
- set: { docs.0.doc._source.hostname: hostname }
- set: { docs.0.doc._source.port: port }
- do: - do:
xpack.watcher.put_watch: xpack.watcher.put_watch:
id: "test_watch" id: "test_watch"
body: > body:
{ metadata:
"metadata" : { index: "<date-index-{now/d}>"
"index" : "<date-index-{now/d}>" trigger:
}, schedule:
"trigger": { interval: 1h
"schedule": { input:
"interval": "1h" http:
} request:
}, host: $hostname
"input": { port: $port
"http" : { path: "/{{#url}}{{ctx.metadata.index}}{{/url}}/_search"
"request" : { condition:
"host" : "localhost", compare:
"port" : 9400, "ctx.payload.hits.total":
"path" : "/{{#url}}{{ctx.metadata.index}}{{/url}}/_search" eq: 1
} actions:
} output:
}, webhook:
"condition" : { method: PUT
"compare" : { host: $hostname
"ctx.payload.hits.total" : { port: $port
"eq" : 1 path: "/{{#url}}{{ctx.metadata.index}}{{/url}}/log/2"
} params:
} refresh: "true"
}, body: "{ \"foo\": \"bar\" }"
"actions": {
"output": {
"webhook" : {
"method" : "PUT",
"host" : "localhost",
"port" : 9400,
"path" : "/{{#url}}{{ctx.metadata.index}}{{/url}}/log/2",
"params" : {
"refresh" : "true"
},
"body" : "{ \"foo\": \"bar\" }"
}
}
}
}
- match: { _id: "test_watch" } - match: { _id: "test_watch" }
- match: { created: true } - match: { created: true }

View File

@ -22,7 +22,6 @@ integTestCluster {
setting 'xpack.security.enabled', 'false' setting 'xpack.security.enabled', 'false'
setting 'xpack.monitoring.enabled', 'false' setting 'xpack.monitoring.enabled', 'false'
setting 'xpack.ml.enabled', 'false' setting 'xpack.ml.enabled', 'false'
setting 'http.port', '9400'
// Need to allow more compilations per minute because of the integration tests // Need to allow more compilations per minute because of the integration tests
setting 'script.max_compilations_per_minute', '100' setting 'script.max_compilations_per_minute', '100'

View File

@ -21,46 +21,53 @@ teardown:
- match: { "watcher_state": "started" } - match: { "watcher_state": "started" }
- match: { "watch_count": 0 } - match: { "watch_count": 0 }
# extract http host and port from master node
- do:
cluster.state: {}
- set: { master_node: master }
- do:
nodes.info:
metric: [ http ]
- is_true: nodes.$master.http.publish_address
- set: { nodes.$master.http.publish_address: host }
- do:
ingest.simulate:
body:
pipeline:
description: _description
processors: [ grok: { field: host, patterns : ["%{IPORHOST:hostname}:%{NUMBER:port:int}"]} ]
docs: [ { _index: index, _type: type, _id: id, _source: { host: $host } } ]
- set: { docs.0.doc._source.hostname: hostname }
- set: { docs.0.doc._source.port: port }
- do: - do:
xpack.watcher.put_watch: xpack.watcher.put_watch:
id: "cluster_health_watch" id: "cluster_health_watch"
body: > body:
{ trigger:
"trigger": { schedule:
"schedule": { interval: 1s
"interval": "1s" input:
} http:
}, request:
"input": { host: $hostname
"http": { port: $port
"request": { path: "/_cluster/health"
"host": "localhost", auth:
"port": 9400, basic:
"path": "/_cluster/health", username: test_admin
"auth" : { password: changeme
"basic" : { condition:
"username" : "test_admin", compare:
"password" : "changeme" "ctx.payload.number_of_data_nodes":
} lt: 10
} actions:
} log:
} logging:
}, text: "executed at {{ctx.execution_time}}"
"condition": {
"compare": {
"ctx.payload.number_of_data_nodes": {
"lt": "10"
}
}
},
"actions": {
"log": {
"logging": {
"text": "executed at {{ctx.execution_time}}"
}
}
}
}
- match: { _id: "cluster_health_watch" } - match: { _id: "cluster_health_watch" }
- match: { created: true } - match: { created: true }