Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

Commit

Permalink
more tests on package upload and lifecycles
Browse files Browse the repository at this point in the history
  • Loading branch information
joschkappel committed Mar 11, 2021
1 parent 3e71518 commit e034048
Show file tree
Hide file tree
Showing 19 changed files with 323 additions and 78 deletions.
Empty file removed tests/__init__.py
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ test_name: configuration API
stages:
- name: Get config
request:
url: "{tavern.env_vars.ARM_URL}configuration"
url: "{api_url}configuration"
method: GET
response:
status_code: 200
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ marks:
- get_uuid

stages:
- name: request test resource install
- name: Install an instance of the hello-world resrouce
request:
url: "{tavern.env_vars.ARM_URL}lifecycle/transitions"
url: "{api_url}lifecycle/transitions"
method: POST
json:
deploymentLocation: "world"
Expand All @@ -31,10 +31,9 @@ stages:
json:
req_id: requestId


- name: get request status
- name: Get the request status
request:
url: "{tavern.env_vars.ARM_URL}lifecycle/transitions/{req_id}/status"
url: "{api_url}lifecycle/transitions/{req_id}/status"
method: GET
response:
status_code: 200
Expand All @@ -50,9 +49,9 @@ stages:
json:
res_id: resourceId

- name: get resource instance status
- name: Get the instance status
request:
url: "{tavern.env_vars.ARM_URL}topology/instances/{res_id}"
url: "{api_url}topology/instances/{res_id}"
method: GET
response:
status_code: 200
Expand All @@ -69,9 +68,9 @@ stages:
resourceName: "test_{res_id}"
resourceType: "resource::hello-world::1.0"

- name: get resource for location
- name: Query the location for the instance
request:
url: "{tavern.env_vars.ARM_URL}topology/deployment-locations/world/instances"
url: "{api_url}topology/deployment-locations/world/instances"
params:
instanceName: "test_{res_id}"
method: GET
Expand Down
51 changes: 51 additions & 0 deletions tests/api/test_resourcetype_api.tavern.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
test_name: resource type API

strict:
- json:off

marks:
- parametrize:
key: res_type
vals:
- "resource::hello-world::1.2"
- "resource::hello-worlds::1.0"
- "resource::hello-world:1.0"


stages:
- name: Get all resource types
request:
url: "{api_url}types"
method: GET
response:
status_code: 200
json:
- name: "resource::hello-world::1.0"
state: "PUBLISHED"
- name: "resource::openstack-network::1.0"
state: "PUBLISHED"

- name: Get resource type details by name
request:
url: "{api_url}types/resource::hello-world::1.0"
method: GET
response:
status_code: 200
json:
name: "resource::hello-world::1.0"
state: "PUBLISHED"
descriptor: !anystr

- name: Get resource type details by name, not found cases
request:
url: "{api_url}types/{res_type}"
method: GET
response:
status_code: 404
json:
detail: !anystr
status: 404
title: "Not Found"
type: "about:blank"


Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ test_name: topology API
stages:
- name: Get all deployment locations
request:
url: "{tavern.env_vars.ARM_URL}topology/deployment-locations"
url: "{api_url}topology/deployment-locations"
method: GET
response:
status_code: 200
Expand All @@ -13,17 +13,17 @@ stages:

- name: Get a deployment location by name
request:
url: "{tavern.env_vars.ARM_URL}topology/deployment-locations/world"
url: "{api_url}topology/deployment-locations/world"
method: GET
response:
status_code: 200
json:
name: "world"
type: "planet"

- name: Get a deployment location by name, not found
- name: Get a deployment location by name, not found cases
request:
url: "{tavern.env_vars.ARM_URL}topology/deployment-locations/worlds"
url: "{api_url}topology/deployment-locations/worlds"
method: GET
response:
status_code: 404
Expand Down
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ def get_uuid():
return str(uuid.uuid1())


def pytest_tavern_beta_before_every_test_run(test_dict, variables):
variables["api_url"] = "http://0.0.0.0:8080/api/v1.0/resource-manager/"
1 change: 0 additions & 1 deletion tests/unit/docker_test.py → tests/docker_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest
import os
import requests
import requests
from urllib3.util.retry import Retry
from requests.adapters import HTTPAdapter

Expand Down
Binary file added tests/features/helloworld11.csar
Binary file not shown.
Binary file added tests/features/helloworld11.zip
Binary file not shown.
Binary file added tests/features/helloworld_nodescriptoryaml.csar
Binary file not shown.
Binary file added tests/features/helloworld_noinstall.csar
Binary file not shown.
Binary file added tests/features/helloworld_nolifecycle.csar
Binary file not shown.
Binary file added tests/features/helloworld_nomanifest.csar
Binary file not shown.
Binary file added tests/features/helloworld_nomanifestyaml.csar
Binary file not shown.
Binary file added tests/features/helloworld_nometainf.csar
Binary file not shown.
201 changes: 201 additions & 0 deletions tests/features/test_fulllifecycle_api.tavern.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
test_name: full package, location and instance lifecycle
marks:
- usefixtures:
- get_uuid

stages:
- name: create a new deployment location MARS
request:
url: "{api_url}topology/deployment-locations/MARS"
method: PUT
json:
properties:
prop1: "this is a test"
prop2: "some other property"
type: "planet"
response:
status_code: 204

- name: check MARS exists
request:
url: "{api_url}topology/deployment-locations/MARS"
method: GET
response:
status_code: 200

- name: Upload a resource package
request:
url: "{api_url}types"
method: POST
data:
resource_name: "hello-world"
resource_version: "1.1"
files:
upfile: "features/helloworld11.csar"
response:
status_code: 200

- name: Verify the new resource type exists
request:
url: "{api_url}types/resource::hello-world::1.1"
method: GET
response:
status_code: 200
json:
name: "resource::hello-world::1.1"
state: "PUBLISHED"
descriptor: !anystr

- name: Install an instance of the new resource
request:
url: "{api_url}lifecycle/transitions"
method: POST
json:
deploymentLocation: "MARS"
metricKey: "{get_uuid}"
properties:
prop1: "nouse"
resourceManagerId: "ansible"
resourceName: "test_{get_uuid}"
resourceType: "resource::hello-world::1.1"
transitionName: "Install"
response:
status_code: 200
json:
finishedAt: !anystr
requestFailureCode: ""
requestId: !anystr
requestState: "COMPLETED"
requestStateReason: !anystr
resourceId: !anystr
startedAt: !anystr
save:
json:
req_id: requestId

- name: Check the install request state
request:
url: "{api_url}lifecycle/transitions/{req_id}/status"
method: GET
response:
status_code: 200
json:
finishedAt: !anystr
requestFailureCode: ""
requestId: "{req_id}"
requestState: "COMPLETED"
requestStateReason: !anystr
resourceId: !anystr
startedAt: !anystr
save:
json:
res_id: resourceId

- name: Query the location for the new instance
request:
url: "{api_url}topology/deployment-locations/MARS/instances"
data:
instanceType: "resource::hello-world::1.1"
method: GET
response:
status_code: 200
json:
- resourceId: "{res_id}"
resourceName: "test_{res_id}"
resourceType: "resource::hello-world::1.1"
resourceManagerId: "ansible"
deploymentLocation: "MARS"
createdAt: !anystr
lastModifiedAt: !anystr
properties:
current_time: !anystr
prop1: "nouse"

- name: Uninstall the instance of the new resource
request:
url: "{api_url}lifecycle/transitions"
method: POST
json:
deploymentLocation: "MARS"
metricKey: "{res_id}"
properties:
prop1: "nouse"
resourceManagerId: "ansible"
resourceName: "test_{res_id}"
resourceType: "resource::hello-world::1.1"
transitionName: "Uninstall"
response:
status_code: 200
json:
finishedAt: !anystr
requestFailureCode: ""
requestId: !anystr
requestState: "COMPLETED"
requestStateReason: !anystr
resourceId: !anystr
startedAt: !anystr
save:
json:
req_id: requestId

- name: Get the request status
request:
url: "{api_url}lifecycle/transitions/{req_id}/status"
method: GET
response:
status_code: 200
json:
finishedAt: !anystr
requestFailureCode: ""
requestId: "{req_id}"
requestState: "COMPLETED"
requestStateReason: !anystr
resourceId: !anystr
startedAt: !anystr

- name: Verify the instance is not longer part of the location
request:
url: "{api_url}topology/deployment-locations/MARS/instances"
data:
instanceType: "resource::hello-world::1.1"
method: GET
response:
status_code: 200
json: []

- name: Delete location MARS
request:
url: "{api_url}topology/deployment-locations/MARS"
method: DELETE
response:
status_code: 200

- name: Verify MARS is gone
request:
url: "{api_url}topology/deployment-locations/MARS"
method: GET
response:
status_code: 404























Loading

0 comments on commit e034048

Please sign in to comment.