Skip to content

Commit

Permalink
Merge pull request #113 from mchalski/trigger-config-depl
Browse files Browse the repository at this point in the history
worker: config deployment triggers device update check
  • Loading branch information
tranchitella committed Feb 16, 2021
2 parents c5f6551 + 8b6fc2b commit ef0bacb
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 29 deletions.
10 changes: 10 additions & 0 deletions tests/mmock/deviceconnect_POST_check_update.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"description": "deviceconnect: POST device check-update",
"request": {
"method": "POST",
"path": "/api/internal/v1/deviceconnect/tenants/tenant/devices/device_id/check-update"
},
"response": {
"statusCode": 202
}
}
86 changes: 57 additions & 29 deletions tests/tests/test_deploy_device_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,39 +67,67 @@ def test_deploy_device_configuration(mmock_url, workflows_url):
]
assert {"name": "retries", "value": "0"} in response["inputParameters"]
assert response["status"] == "done"
assert len(response["results"]) == 1
assert len(response["results"]) == 2
assert response["results"][0]["success"] == True
assert response["results"][0]["httpResponse"]["statusCode"] == 201
assert response["results"][1]["success"] == True
assert response["results"][1]["httpResponse"]["statusCode"] == 202
#  verify the mock server has been correctly called
res = requests.get(mmock_url + "/api/request/all")
assert res.status_code == 200
response = res.json()
assert len(response) == 1
expected = {
"request": {
"scheme": "http",
"host": "mender-deployments",
"port": "8080",
"method": "POST",
"path": "/api/internal/v1/deployments/tenants/"
+ tenant_id
+ "/configuration/deployments/"
+ deployment_id
+ "/devices/"
+ device_id,
"queryStringParameters": {},
"fragment": "",
"headers": {
"Content-Type": ["application/json"],
"Accept-Encoding": ["gzip"],
"Content-Length": ["88"],
"User-Agent": ["Go-http-client/1.1"],
"X-Men-Requestid": [request_id],
},
"cookies": {},
"body": '{"configuration":"{\\"key\\":\\"value\\"}","name":"configuration-'
+ deployment_id
+ '","retries":0}',
assert len(response) == 2
expected = [
{
"request": {
"scheme": "http",
"host": "mender-deployments",
"port": "8080",
"method": "POST",
"path": "/api/internal/v1/deployments/tenants/"
+ tenant_id
+ "/configuration/deployments/"
+ deployment_id
+ "/devices/"
+ device_id,
"queryStringParameters": {},
"fragment": "",
"headers": {
"Content-Type": ["application/json"],
"Accept-Encoding": ["gzip"],
"Content-Length": ["88"],
"User-Agent": ["Go-http-client/1.1"],
"X-Men-Requestid": [request_id],
},
"cookies": {},
"body": '{"configuration":"{\\"key\\":\\"value\\"}","name":"configuration-'
+ deployment_id
+ '","retries":0}',
}
},
}
assert expected["request"] == response[0]["request"]
{
"request": {
"scheme": "http",
"host": "mender-deviceconnect",
"port": "8080",
"method": "POST",
"path": "/api/internal/v1/deviceconnect/tenants/"
+ tenant_id
+ "/devices/"
+ device_id
+ "/check-update",
"queryStringParameters": {},
"fragment": "",
"headers": {
"Accept-Encoding": ["gzip"],
"Content-Length": ["0"],
"User-Agent": ["Go-http-client/1.1"],
"X-Men-Requestid": [request_id],
},
"cookies": {},
"body": "",
}
},
]
assert expected[0]["request"] == response[0]["request"]
assert expected[1]["request"] == response[1]["request"]
15 changes: 15 additions & 0 deletions worker/deploy_device_configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@
"connectionTimeOut": 8000,
"readTimeOut": 8000
}
},
{
"name": "trigger_check_update",
"type": "http",
"retries": 3,
"http": {
"uri": "http://${env.DEVICECONNECT_ADDR|mender-deviceconnect:8080}/api/internal/v1/deviceconnect/tenants/${workflow.input.tenant_id}/devices/${workflow.input.device_id}/check-update",
"method": "POST",
"headers": {
"X-MEN-RequestID": "${workflow.input.request_id}"
},
"connectionTimeOut": 8000,
"readTimeOut": 8000,
"statusCodes": [202, 404, 409]
}
}
],
"inputParameters": [
Expand Down

0 comments on commit ef0bacb

Please sign in to comment.