-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #905 from cherrycl/issue-899-implement
feat: Implement tests for core-keeper
- Loading branch information
Showing
11 changed files
with
277 additions
and
79 deletions.
There are no files selected for viewing
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
63 changes: 63 additions & 0 deletions
63
TAF/testCaseModules/keywords/core-keeper/coreKeeperAPI.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,63 @@ | ||
*** Settings *** | ||
Library RequestsLibrary | ||
Resource TAF/testCaseModules/keywords/core-keeper/coreKeeperAPI.robot | ||
Resource TAF/testCaseModules/keywords/common/commonKeywords.robot | ||
|
||
*** Variables *** | ||
${coreKeeperUrl} ${URI_SCHEME}://${BASE_URL}:${CORE_KEEPER_PORT} | ||
${coreKeeperRegUri} /api/${API_VERSION}/registry | ||
${coreKeeperKVsUri} /api/${API_VERSION}/kvs/key | ||
|
||
*** Keywords *** | ||
Generate Registry Data | ||
[Arguments] ${serviceId} ${host} ${port} | ||
${data} Get File ${WORK_DIR}/TAF/testData/core-keeper/registry_data.json encoding=UTF-8 | ||
${registry_data} Evaluate json.loads('''${data}''') json | ||
${json} Create Dictionary registration=${registry_data} | ||
Set to dictionary ${json} apiVersion=${API_VERSION} | ||
Set To Dictionary ${json}[registration] serviceId=${serviceId} | ||
Set To Dictionary ${json}[registration] host=${host} | ||
Set To Dictionary ${json}[registration] port=${port} | ||
Set Test Variable ${Registry} ${json} | ||
|
||
Register A New Service | ||
[Arguments] ${entity} | ||
Create Session Core Keeper url=${coreKeeperUrl} disable_warnings=true | ||
${headers} Create Dictionary Content-Type=application/json Authorization=Bearer ${jwt_token} | ||
${resp} POST On Session Core Keeper ${coreKeeperRegUri} json=${entity} headers=${headers} | ||
... expected_status=any | ||
Set Response to Test Variables ${resp} | ||
|
||
Deregister Service | ||
[Arguments] ${serviceId} | ||
Create Session Core Keeper url=${coreKeeperUrl} disable_warnings=true | ||
${headers} Create Dictionary Authorization=Bearer ${jwt_token} | ||
${resp} DELETE On Session Core Keeper ${coreKeeperRegUri}/serviceId/${serviceId} headers=${headers} | ||
... expected_status=any | ||
run keyword if ${resp.status_code}!=204 log to console ${resp.content} | ||
Set Response to Test Variables ${resp} | ||
|
||
Query All Registered Services | ||
Create Session Core Keeper url=${coreKeeperUrl} disable_warnings=true | ||
${headers} Create Dictionary Content-Type=application/json Authorization=Bearer ${jwt_token} | ||
${resp} GET On Session Core Keeper ${coreKeeperRegUri}/all headers=${headers} | ||
... expected_status=any | ||
Set Response to Test Variables ${resp} | ||
|
||
Query Registered Service By ServiceId | ||
[Arguments] ${serviceId} | ||
Create Session Core Keeper url=${coreKeeperUrl} disable_warnings=true | ||
${headers} Create Dictionary Content-Type=application/json Authorization=Bearer ${jwt_token} | ||
${resp} GET On Session Core Keeper ${coreKeeperRegUri}/serviceId/${serviceId} headers=${headers} | ||
... expected_status=any | ||
Set Response to Test Variables ${resp} | ||
|
||
Update Registered Service | ||
[Arguments] ${entity} | ||
Create Session Core Keeper url=${coreKeeperUrl} disable_warnings=true | ||
${headers} Create Dictionary Content-Type=application/json Authorization=Bearer ${jwt_token} | ||
${resp} PUT On Session Core Keeper ${coreKeeperRegUri} json=${entity} headers=${headers} | ||
... expected_status=any | ||
Set Response to Test Variables ${resp} | ||
|
||
|
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,10 @@ | ||
{ | ||
"serviceId": "", | ||
"host": "", | ||
"port": 0, | ||
"healthCheck": { | ||
"interval": "10s", | ||
"path": "/api/v3/ping", | ||
"type": "http" | ||
} | ||
} |
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
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
17 changes: 13 additions & 4 deletions
17
TAF/testScenarios/functionalTest/API/core-keeper/registry/DELETE.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,22 +1,31 @@ | ||
*** Settings *** | ||
Resource TAF/testCaseModules/keywords/common/commonKeywords.robot | ||
Resource TAF/testCaseModules/keywords/core-keeper/coreKeeperAPI.robot | ||
Suite Setup Run Keywords Setup Suite | ||
... AND Run Keyword if $SECURITY_SERVICE_NEEDED == 'true' Get Token | ||
Suite Teardown Run Teardown Keywords | ||
Force Tags Skipped | ||
|
||
*** Variables *** | ||
${SUITE} Core Keeper Registry DELETE Test Cases | ||
${LOG_FILE_PATH} ${WORK_DIR}/TAF/testArtifacts/logs/core-keeper-registry-delete.log | ||
|
||
*** Test Cases *** | ||
RegistryDELETE001 - Delete a registered service | ||
When Delete A Registered Service | ||
RegistryDELETE001 - Deregister Service | ||
Given Set Test Variable ${serviceId} testRegistryDelService | ||
And Generate Registry Data ${serviceId} test-service-host ${12345} | ||
And Register A New Service ${Registry} | ||
When Deregister Service ${serviceId} | ||
Then Should Return Status Code "204" | ||
And Response Time Should Be Less Than "${default_response_time_threshold}"ms | ||
And Service Should Be Deregistered | ||
|
||
ErrRegistryDELETE001 - Delete an unregistered service | ||
When Delete An Unregistered Service | ||
When Deregister Service not_registry_service | ||
Then Should Return Status Code "404" | ||
And Should Return Content-Type "application/json" | ||
And Response Time Should Be Less Than "${default_response_time_threshold}"ms | ||
|
||
*** Keywords *** | ||
Service Should Be Deregistered | ||
Query Registered Service By ServiceId ${serviceId} | ||
Should Return Status Code "404" |
37 changes: 31 additions & 6 deletions
37
TAF/testScenarios/functionalTest/API/core-keeper/registry/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,31 +1,56 @@ | ||
*** Settings *** | ||
Resource TAF/testCaseModules/keywords/common/commonKeywords.robot | ||
Resource TAF/testCaseModules/keywords/core-keeper/coreKeeperAPI.robot | ||
Suite Setup Run Keywords Setup Suite | ||
... AND Run Keyword if $SECURITY_SERVICE_NEEDED == 'true' Get Token | ||
Suite Teardown Run Teardown Keywords | ||
Force Tags Skipped | ||
|
||
*** Variables *** | ||
${SUITE} Core Keeper Registry GET Test Cases | ||
${LOG_FILE_PATH} ${WORK_DIR}/TAF/testArtifacts/logs/core-keeper-registry-get.log | ||
|
||
*** Test Cases *** | ||
RegistryGET001 - Query all registered services | ||
Given Register Multiple Services | ||
When Query All Registered Services | ||
Then Should Return Status Code "200" And registrations | ||
And apiVersion Should be ${API_VERSION} | ||
And Response Time Should Be Less Than "${default_response_time_threshold}"ms | ||
And All Registered Services Are Listed And Count Should Match totalCount | ||
[Teardown] Deregister Multiple Configurations | ||
|
||
RegistryGET002 - Query registered service by name | ||
When Query Registered Service By Name | ||
Then Should Return Status Code "200" And registrations | ||
RegistryGET002 - Query registered service by serviceId | ||
Given Set Test Variable ${serviceId} testRegistryGetService | ||
And Generate Registry Data ${serviceId} test-service-host ${12345} | ||
And Register A New Service ${Registry} | ||
When Query Registered Service By ServiceId ${serviceId} | ||
Then Should Return Status Code "200" And registration | ||
And apiVersion Should be ${API_VERSION} | ||
And Response Time Should Be Less Than "${default_response_time_threshold}"ms | ||
And Registered Service Should Be Found | ||
And Should Be Equal As Strings ${serviceId} ${content}[registration][serviceId] | ||
[Teardown] Deregister Service ${serviceId} | ||
|
||
ErrRegistryGET001 - Should return error when querying unregistered service | ||
When Query Unregistered Service | ||
When Query Registered Service By ServiceId unregistered_service | ||
Then Should Return Status Code "404" | ||
And Should Return Content-Type "application/json" | ||
And Response Time Should Be Less Than "${default_response_time_threshold}"ms | ||
|
||
*** Keywords *** | ||
All Registered Services Are Listed And Count Should Match totalCount | ||
${service_count} Get Length ${content}[registrations] | ||
Should Be Equal As Integers ${service_count} ${content}[totalCount] | ||
|
||
Register Multiple Services | ||
${Ids} Create List service1 service2 service3 | ||
FOR ${id} IN @{Ids} | ||
Generate Registry Data ${id} ${id}-host ${12345} | ||
Register A New Service ${Registry} | ||
END | ||
Set Test Variable ${serviceIds} ${Ids} | ||
|
||
Deregister Multiple Configurations | ||
FOR ${id} IN @{serviceIds} | ||
Deregister Service ${id} | ||
END | ||
|
Oops, something went wrong.