forked from edgexfoundry/edgex-taf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement app service V2 API test cases
Fix edgexfoundry#155 Signed-off-by: Ginny Guan <[email protected]>
- Loading branch information
1 parent
fca51c6
commit e387dee
Showing
11 changed files
with
268 additions
and
33 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
TAF/testCaseModules/keywords/app-service/AppServiceAPI.robot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
*** Settings *** | ||
Library RequestsLibrary | ||
Library OperatingSystem | ||
Library TAF/testCaseModules/keywords/setup/edgex.py | ||
Resource TAF/testCaseModules/keywords/common/commonKeywords.robot | ||
|
||
*** Keywords *** | ||
Deploy App Service | ||
Deploy services app-service-${edgex_profile} | ||
|
||
Remove App Service | ||
Remove services app-service-${edgex_profile} | ||
|
||
Set functions ${functions} | ||
${path}= Set variable /v1/kv/edgex/appservices/1.0/AppService-${edgex_profile}/Writable/Pipeline/ExecutionOrder | ||
Modify consul config ${path} ${functions} | ||
sleep 1 | ||
|
||
Trigger Function Pipeline With ${data} | ||
${trigger_data}= Run keyword if '${data}' != 'Invalid Data' and '${data}' != 'Unprocessable Entity' | ||
... set variable Valid Data ELSE set variable ${data} | ||
${trigger_data}= Load data file "app-service/trigger_data.json" and get variable "${trigger_data}" | ||
Run keyword if '${data}' == 'No Matching DeviceName' | ||
... Run keywords set to dictionary ${trigger_data} device="DeiveNotMatch" | ||
... AND set to dictionary ${trigger_data}[readings][0] device="DeviceNotMatch" | ||
Create Session Trigger url=${url} disable_warnings=true | ||
${headers}= Create Dictionary Authorization=Bearer ${jwt_token} | ||
${resp}= Post request Trigger api/${api_version}/trigger json=${trigger_data} headers=${headers} | ||
Set Response to Test Variables ${resp} | ||
Run keyword if ${response} != 200 log to console ${content} | ||
|
||
Store Secret Data With ${data} | ||
${secrets_data}= Load data file "app-service/secrets_data.json" and get variable "${data}" | ||
Create Session Secrets url=${url} disable_warnings=true | ||
${headers}= Create Dictionary Authorization=Bearer ${jwt_token} | ||
${resp}= Post request Secrets api/${api_version}/secrets json=${secrets_data} headers=${headers} | ||
Set Response to Test Variables ${resp} | ||
Run keyword if ${response} != 201 log to console ${content} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"No Path": { | ||
"secrets" : [ | ||
{ | ||
"key" : "MySecretKey", | ||
"value" : "MySecretValue" | ||
} | ||
] | ||
}, | ||
"Path": { | ||
"path" : "MyPath", | ||
"secrets" : [ | ||
{ | ||
"key" : "MySecretKey", | ||
"value" : "MySecretValue" | ||
} | ||
] | ||
}, | ||
"Missing Key": { | ||
"path" : "MyPath", | ||
"secrets" : [ | ||
{ | ||
"value" : "MySecretValue" | ||
} | ||
] | ||
}, | ||
"Missing Value": { | ||
"path" : "MyPath", | ||
"secrets" : [ | ||
{ | ||
"key" : "MySecretKey" | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"Valid Data": { | ||
"id": "5bd794de0e36080001f53eab", | ||
"pushed": 0, | ||
"device": "Random-Float-Device", | ||
"created": 1540855006481, | ||
"modified": 0, | ||
"origin": 1540855006469, | ||
"schedule": null, | ||
"event": null, | ||
"readings": [ | ||
{ | ||
"id": "5bd794de0e36080001f53eac", | ||
"pushed": 0, | ||
"created": 1540855006481, | ||
"origin": 1540855006469, | ||
"modified": 0, | ||
"device": "Random-Float-Device", | ||
"name": "RandomValue_Float64", | ||
"value": "QAFk2HxRUOo=" | ||
} | ||
] | ||
}, | ||
"Invalid Data": { | ||
"id": "5bd794de0e36080001f53eab", | ||
"device": "Random-Float-Device", | ||
"origin": 1540855006469, | ||
"readings": [ | ||
{ | ||
"id": "5bd794de0e36080001f53eac", | ||
"origin": 1540855006469, | ||
"device": "Random-Float-Device", | ||
"name": "RandomValue_Float64", | ||
"value": "invalid value" | ||
} | ||
] | ||
}, | ||
"Unprocessable Entity": { | ||
"id": "5bd794de0e36080001f53eab", | ||
"device": "Random-Float-Device", | ||
"origin": 1540855006469, | ||
"readings": [ | ||
{ | ||
"id": "5bd794de0e36080001f53eac", | ||
"origin": 1540855006469, | ||
"device": "Random-Float-Device", | ||
"name": "RandomValue_Float64", | ||
"value": "QAFk2HxRUOo=" | ||
} | ||
], | ||
"addition": 123 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
trigger_content={ | ||
"XML String": '<Event><ID>5bd794de0e36080001f53eab</ID><Pushed>0</Pushed><Device>Random-Float-Device</Device>' | ||
'<Created>1540855006481</Created><Modified>0</Modified><Origin>1540855006469</Origin><Readings>' | ||
'<Id>5bd794de0e36080001f53eac</Id><Pushed>0</Pushed><Created>1540855006481</Created><Origin>1540855006469</Origin>' | ||
'<Modified>0</Modified><Device>Random-Float-Device</Device><Name>RandomValue_Float64</Name><Value>QAFk2HxRUOo=</Value>' | ||
'<ValueType></ValueType><FloatEncoding></FloatEncoding><BinaryValue></BinaryValue><MediaType></MediaType></Readings></Event>', | ||
"JSON String": '{"id":"5bd794de0e36080001f53eab","device":"Random-Float-Device","created":1540855006481,"origin":1540855006469,' | ||
'"readings":[{"id":"5bd794de0e36080001f53eac","created":1540855006481,"origin":1540855006469,' | ||
'"device":"Random-Float-Device","name":"RandomValue_Float64","value":"QAFk2HxRUOo="}]}', | ||
"JSON-GZIP String": 'H4sIAAAAAAAA/5SOwYrCMBiE32XOKfzdJtk2sIeFpext2YJeRCRtfkuwTaDWIkjfXdSDeFE8zjfDzJzgHQxU7T4L6Zg405QTUbpVGdsaAo4n3zAMKhtc7JOyi3ZMfm5UoBnYjuxgUiUpV4pIyzwViINvfXjAuhAY2Dof2j3M6vl08373i6fB9ndzabsDb64JLSEwXTQM/r/L3cfvsVr8xS/M6/kcAAD//766olAgAQAA', | ||
"JSON-ZLIB String": 'eJyUjsGKwjAYhN9lzin83SbZNrCHhaXsbdmCXkQkbX5LsE2g1iJI313Ug3hRPM43w8yc4B0MVO0+C+mYONOUE1G6VRnbGgKOJ98wDCobXOyTsot2TH5uVKAZ2I7sYFIlKVeKSMs8FYiDb314wLoQGNg6H9o9zOr5dPN+94unwfZ3c2m7A2+uCS0hMF00DP6/y93H77Fa/MUvzOv5HAAA//9QTVQF', | ||
"JSON-ZLIB-AES String": '7E/CbWn7FhxheP2OgLT1OFCquTKtVXGVDLqjX8EWL8vlnYEhRIKII2KA9MJQlXx5pxXzMkA8dYW5uXDpm4UbKqVVpi7QqQoYPJ4tBo0D7LIT4NJpRwg5qAXQ0FaZtEPvO6tpK1KA1wWMrnj9uXCa2zphifSxDRG+W2Hbm/Hc2GItheZI+yS2+2nbuANVOhtBeYblT31B1rr4wPX4wCxwzil2SVSLRclR3eLy/fiokzv3s423em5TsN34SsG5R9JcsEPZtAt9tTWhw2k8vY8osJd1ZWOq1S0s3+Hkscp2mO9d+NUBZD+MbMwUPTrdfCCkh9pTCQIBs5OSkGxIb2JVHCzutX+kC6MJnE+KfmHKezfF+AlgzHKZ5rScPrkbnO7Cp5aJ6Aarw0dhog97y/Q2K/CsE5A9W1L/bgIP1W/EgZm94rtDFqGnzGP8FihHSeLn' | ||
} |
21 changes: 15 additions & 6 deletions
21
TAF/testScenarios/functionalTest/V2-API/app-service/info/GET.robot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,37 @@ | ||
*** Settings *** | ||
Resource TAF/testCaseModules/keywords/common/commonKeywords.robot | ||
Resource TAF/testCaseModules/keywords/common/commonKeywords.robot | ||
Resource TAF/testCaseModules/keywords/app-service/AppServiceAPI.robot | ||
Suite Setup Run Keywords Setup Suite AND Deploy App Service | ||
... AND Set Suite Variable ${url} ${AppServiceUrl_blackbox} | ||
... AND Run Keyword if $SECURITY_SERVICE_NEEDED == 'true' Get Token | ||
Suite Teardown Run Keywords Suite Teardown AND Remove App Service | ||
... AND Run Keyword if $SECURITY_SERVICE_NEEDED == 'true' Remove Token | ||
|
||
*** Variables *** | ||
${SUITE} App-Service GET Testcases | ||
${LOG_FILE_PATH} ${WORK_DIR}/TAF/testArtifacts/logs/app-service-get.log | ||
${edgex_profile} blackbox-tests | ||
${AppServiceUrl_blackbox} http://${BASE_URL}:48095 | ||
${api_version} v2 | ||
|
||
*** Test Cases *** | ||
InfoGET001 - Query ping | ||
When Query Ping | ||
Then Should Return Status Code "200" And Timestamp | ||
Then Should Return Status Code "200" And timestamp | ||
|
||
InfoGET002 - Query version | ||
When Query Version | ||
Then Should Return Status Code "200" And Version | ||
And Should Return SDK Version | ||
Then Should Return Status Code "200" And version | ||
And Should Return SDK Version | ||
|
||
InfoGET003 - Query metrics | ||
When Query Metrics | ||
Then Should Return Status Code "200" And Metrics | ||
Then Should Return Status Code "200" And metrics | ||
|
||
InfoGET004 - Query config | ||
When Query Config | ||
Then Should Return Status Code "200" And Config | ||
Then Should Return Status Code "200" And config | ||
|
||
**** Keywords *** | ||
Should Return SDK Version | ||
Should contain "sdk_version" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 10 additions & 1 deletion
11
TAF/testScenarios/functionalTest/V2-API/app-service/trigger/POST-negative.robot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,27 @@ | ||
*** Settings *** | ||
Resource TAF/testCaseModules/keywords/common/commonKeywords.robot | ||
Resource TAF/testCaseModules/keywords/common/commonKeywords.robot | ||
Resource TAF/testCaseModules/keywords/app-service/AppServiceAPI.robot | ||
Library TAF/testCaseModules/keywords/consul/consul.py | ||
Suite Setup Run Keywords Setup Suite AND Deploy App Service | ||
... AND Set Suite Variable ${url} ${AppServiceUrl_blackbox} | ||
... AND Run Keyword if $SECURITY_SERVICE_NEEDED == 'true' Get Token | ||
Suite Teardown Run Keywords Suite Teardown AND Remove App Service | ||
... AND Run Keyword if $SECURITY_SERVICE_NEEDED == 'true' Remove Token | ||
|
||
*** Variables *** | ||
${SUITE} App-Service Trigger POST Negative Testcases | ||
${LOG_FILE_PATH} ${WORK_DIR}/TAF/testArtifacts/logs/app-service-trigger-negative.log | ||
${edgex_profile} blackbox-tests | ||
${AppServiceUrl_blackbox} http://${BASE_URL}:48095 | ||
${api_version} v2 | ||
|
||
*** Test Cases *** | ||
ErrTriggerPOST001 - Trigger pipeline fails (Invalid Data) | ||
Given Set functions FilterByDeviceName, TransformToXML, SetOutputData | ||
When Trigger Function Pipeline With Invalid Data | ||
Then Should Return Status Code "400" | ||
|
||
ErrTriggerPOST002 - Trigger pipeline fails (Unprocessable Entity) | ||
Given Set functions FilterByDeviceName, TransformToXML, SetOutputData | ||
When Trigger Function Pipeline With Unprocessable Entity | ||
Then Should Return Status Code "422" |
39 changes: 28 additions & 11 deletions
39
TAF/testScenarios/functionalTest/V2-API/app-service/trigger/POST-positive.robot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,61 @@ | ||
*** Settings *** | ||
Resource TAF/testCaseModules/keywords/common/commonKeywords.robot | ||
Resource TAF/testCaseModules/keywords/common/commonKeywords.robot | ||
Resource TAF/testCaseModules/keywords/app-service/AppServiceAPI.robot | ||
Library TAF/testCaseModules/keywords/consul/consul.py | ||
Variables TAF/testData/app-service/trigger_response_content.py | ||
Suite Setup Run Keywords Setup Suite AND Deploy App Service | ||
... AND Set Suite Variable ${url} ${AppServiceUrl_blackbox} | ||
... AND Run Keyword if $SECURITY_SERVICE_NEEDED == 'true' Get Token | ||
Suite Teardown Run Keywords Suite Teardown AND Remove App Service | ||
... AND Run Keyword if $SECURITY_SERVICE_NEEDED == 'true' Remove Token | ||
|
||
*** Variables *** | ||
${SUITE} App-Service Trigger POST Positive Testcases | ||
${LOG_FILE_PATH} ${WORK_DIR}/TAF/testArtifacts/logs/app-service-trigger-positive.log | ||
${edgex_profile} blackbox-tests | ||
${AppServiceUrl_blackbox} http://${BASE_URL}:48095 | ||
${api_version} v2 | ||
|
||
*** Test Cases *** | ||
TriggerPOST001 - Trigger pipeline (no match) | ||
Given Set functions FilterByDeviceName, TransformToXML, SetOutputData | ||
When Trigger Function Pipeline With No Matching DeviceName | ||
Then Should Return Status Code "200" | ||
And Body Should Match Empty | ||
And Body Should Match Empty | ||
|
||
TriggerPOST002 - Trigger pipeline (XML) | ||
Given Set functions FilterByDeviceName, TransformToXML, SetOutputData | ||
When Trigger Function Pipeline With Matching DeviceName | ||
Then Should Return Status Code "200" | ||
And Body Should Match XML String | ||
And Body Should Match XML String | ||
|
||
TriggerPOST003 - Trigger pipeline (JSON) | ||
Given Set TransformToJSON | ||
Given Set functions FilterByDeviceName, TransformToJSON, SetOutputData | ||
When Trigger Function Pipeline With Matching DeviceName | ||
Then Should Return Status Code "200" | ||
And Body Should Match JSON String | ||
And Body Should Match JSON String | ||
|
||
TriggerPOST004 - Trigger pipeline (JSON-GZIP) | ||
Given Set CompressWithGZIP | ||
Given Set functions FilterByDeviceName, TransformToJSON, CompressWithGZIP, SetOutputData | ||
When Trigger Function Pipeline With Matching DeviceName | ||
Then Should Return Status Code "200" | ||
And Body Should Match JSON String | ||
And Body Should Match JSON-GZIP String | ||
|
||
TriggerPOST005 - Trigger pipeline (JSON-ZLIB) | ||
Given Set CompressWithZLIB | ||
Given Set functions FilterByDeviceName, TransformToJSON, CompressWithZLIB, SetOutputData | ||
When Trigger Function Pipeline With Matching DeviceName | ||
Then Should Return Status Code "200" | ||
And Body Should Match JSON String | ||
And Body Should Match JSON-ZLIB String | ||
|
||
TriggerPOST006 - Trigger pipeline (JSON-ZLIB-AES) | ||
Given Set EncryptWithAES | ||
Given Set functions FilterByDeviceName, TransformToXML, CompressWithZLIB, EncryptWithAES, SetOutputData | ||
When Trigger Function Pipeline With Matching DeviceName | ||
Then Should Return Status Code "200" | ||
And Body Should Match JSON String | ||
And Body Should Match JSON-ZLIB-AES String | ||
|
||
*** Keywords *** | ||
Body Should Match ${type} | ||
${length}= Get Length ${content} | ||
Run keyword if '${type}' == 'Empty' Should be true ${length}==0 | ||
... ELSE Should be true '${content}' == '${trigger_content["${type}"]}' | ||
|
Oops, something went wrong.