-
Notifications
You must be signed in to change notification settings - Fork 458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Elasticsearch tests #353
Elasticsearch tests #353
Changes from 8 commits
f485c14
36b2bc9
10b9ad3
f9701a2
e34f7fb
772b78a
6e49f07
ad1e386
d4118b4
076742e
607a38c
f4d1906
128cdef
22d0e99
53a8054
07956dc
2e11422
0a116a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,89 @@ | ||
actions: | ||
- name: dummy test | ||
- name: Wait until all expected nodes are connected to the cluster | ||
bashTest: | ||
script: |- | ||
exit 0 | ||
function get_nodes_count() { | ||
curl -s "${HEALTH_URL}" | jq '.number_of_nodes' | ||
} | ||
|
||
expected_nodes="${REPLICAS}" | ||
|
||
timeout=300 | ||
timeout_time=$(( $(date +%s) + timeout )) | ||
|
||
# Wait for all nodes to join the cluster | ||
nodes_count="$(get_nodes_count)" | ||
while [[ "${nodes_count}" -ne "${expected_nodes}" ]] \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a question: Does it mean that running Pod can be still not connected to the cluster? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. |
||
&& [[ "$(date +%s)" -le "${timeout_time}" ]]; do | ||
sleep 3 | ||
nodes_count="$(get_nodes_count)" | ||
done | ||
|
||
if [[ "${nodes_count}" -eq "${expected_nodes}" ]]; then | ||
echo "OK - all nodes joined" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer stdout checks for ease of debugging in case of failure, even if I agree that checking the exitCode is more readable. We can return to checking the exitCode once testrunner prints the logs from both stdout and stderr in case of failure. |
||
else | ||
echo "FAIL - nodes count: ${nodes_count}" | ||
fi | ||
expect: | ||
stdout: | ||
contains: OK - all nodes joined | ||
|
||
- name: Wait for green status in the cluster | ||
bashTest: | ||
script: |- | ||
function get_cluster_status() { | ||
curl -s "${HEALTH_URL}" | jq '.status' | ||
} | ||
|
||
timeout=300 | ||
timeout_time=$(( $(date +%s) + timeout )) | ||
|
||
# Wait for green status | ||
status="$(get_cluster_status)" | ||
while [[ "${status}" != '"green"' ]] \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you modify jq in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, it's nice. Corrected. |
||
&& [[ "$(date +%s)" -le "${timeout_time}" ]]; do | ||
sleep 3 | ||
status="$(get_cluster_status)" | ||
done | ||
|
||
if [[ "${status}" == '"green"' ]]; then | ||
echo "OK - green status" | ||
else | ||
echo "FAIL - status: ${status}" | ||
fi | ||
expect: | ||
stdout: | ||
contains: OK - green status | ||
|
||
- name: Add a document | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you name steps in a question form? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I rephrased the names. |
||
bashTest: | ||
script: |- | ||
curl -s -f -X PUT -H 'Content-Type:application/json' -d '{ | ||
"name": "John", | ||
"surname": "Smith" | ||
}' "${ELASTIC_URL}/employees/person/1" | ||
expect: | ||
exitCode: | ||
equals: 0 | ||
|
||
- name: Update the document | ||
bashTest: | ||
script: |- | ||
curl -s -f -X POST -H 'Content-Type:application/json' -d '{ | ||
"doc": { | ||
"lastname": "Jones" | ||
} | ||
}' "${ELASTIC_URL}/employees/person/1/_update" | ||
expect: | ||
exitCode: | ||
equals: 0 | ||
|
||
- name: Search for the document | ||
bashTest: | ||
script: |- | ||
# Wait to allow the object to be propagated between all nodes | ||
sleep 5 | ||
curl -s -f "${ELASTIC_URL}/_search?q=jones" | ||
expect: | ||
stdout: | ||
contains: "\"name\":\"John\"" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cluster might not be formed - do you mean not having timeouts in the test and rely on the deployer's timeout or Cloud Build's timeout? Then we rely on the execution environment for a container, which should rather be environment-agnostic.