api: Added GET method for machine-config #242
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Testing Done
Build
cargo build
cargo build --release
cargo fmt --all
sudo env "PATH=$PATH" cargo test --all
Integration Tests
Test1a get machine-config; Should output vcpu_count: 1, mem_size: 128
HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked
Date: Fri, 27 Apr 2018 08:33:51 GMT
{ "vcpu_count": 1, "mem_size_mib": 128 }
=======================================================
Test1 setting the vCPU to 2; Should output Updated
HTTP/1.1 204 No Content
Date: Fri, 27 Apr 2018 08:33:51 GMT
=======================================================
Test1a get machine-config; Should output vcpu_count: 2, mem_size: 128
HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked
Date: Fri, 27 Apr 2018 08:33:51 GMT
{ "vcpu_count": 2, "mem_size_mib": 128 }
=======================================================
Test1 setting the vCPU to 3; Should output Error (The cpuid is not an even number) - EXPECTED TO FAIL NOW
HTTP/1.1 204 No Content
Date: Fri, 27 Apr 2018 08:33:51 GMT
=======================================================
Test2 setting the vCPU to -1; Should output Bad Request
HTTP/1.1 400 Bad Request
Content-Type: application/json
Transfer-Encoding: chunked
Date: Fri, 27 Apr 2018 08:33:51 GMT
{
"fault_message": "invalid value: integer
-1
, expected u8 at line 1 column 18"}
=======================================================
Test3 setting the vCPU to string; Should output Bad Request
HTTP/1.1 400 Bad Request
Content-Type: application/json
Transfer-Encoding: chunked
Date: Fri, 27 Apr 2018 08:33:51 GMT
{
"fault_message": "invalid type: string "str", expected u8 at line 1 column 21"
}
=======================================================
Test3a get machine-config; Should output vcpu_count: 2 (this should be 2 in the future), mem_size: 128
HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked
Date: Fri, 27 Apr 2018 08:33:51 GMT
{ "vcpu_count": 3, "mem_size_mib": 128 }
=======================================================
Test4 setting the memory size to 256; Should output Updated
HTTP/1.1 204 No Content
Date: Fri, 27 Apr 2018 08:33:51 GMT
=======================================================
Test5 setting the memory size to -1; Should output Bad Request
HTTP/1.1 400 Bad Request
Content-Type: application/json
Transfer-Encoding: chunked
Date: Fri, 27 Apr 2018 08:33:51 GMT
{
"fault_message": "invalid value: integer
-1
, expected usize at line 1 column 20"}
=======================================================
Test6 setting the memory size to string; Should output Bad Request
HTTP/1.1 400 Bad Request
Content-Type: application/json
Transfer-Encoding: chunked
Date: Fri, 27 Apr 2018 08:33:51 GMT
{
"fault_message": "invalid type: string "str", expected usize at line 1 column 23"
}
=======================================================
Test7 send request with empty body; Should output Bad Request
HTTP/1.1 204 No Content
Date: Fri, 27 Apr 2018 08:33:51 GMT
=======================================================
Test8 send request with both memory and vcpu configuration; Should output Updated
HTTP/1.1 204 No Content
Date: Fri, 27 Apr 2018 08:33:51 GMT
=======================================================
Test9 send request with vCPU set to 0; Should output BadRequest
HTTP/1.1 400 Bad Request
Content-Type: application/json
Transfer-Encoding: chunked
Date: Fri, 27 Apr 2018 08:33:51 GMT
{
"fault_message": "The vCPU number is invalid!"
}
=======================================================
Test9 send request with memory set to 0; Should output BadRequest
HTTP/1.1 400 Bad Request
Content-Type: application/json
Transfer-Encoding: chunked
Date: Fri, 27 Apr 2018 08:33:51 GMT
{
"fault_message": "The memory size (MiB) is invalid!"
}