fixes for api_func_test, and log dir

This commit is contained in:
cindy oneill 2015-05-04 16:20:02 -06:00
parent 27306cba7c
commit ab957bc8e9
3 changed files with 55 additions and 23 deletions

View File

@ -30,7 +30,6 @@ To install the events api, git clone the source and run the
following commands: following commands:
sudo python setup.py install sudo python setup.py install
sudo mkdir -p /var/log/monasca/events_api
If it installs successfully, you will need to make changes to the following If it installs successfully, you will need to make changes to the following
two files to reflect your system settings, especially where kafka server is two files to reflect your system settings, especially where kafka server is

View File

@ -51,7 +51,7 @@ def test_events_get():
json_data = json.loads(response.text) json_data = json.loads(response.text)
event_id = json_data[3]['id'] event_id = json_data[0]['id']
assert response.status_code == 200 assert response.status_code == 200
@ -69,6 +69,25 @@ def test_events_get():
print("GET /events success") print("GET /events success")
def test_events_get_all():
headers = {
'X-Auth-User': 'mini-mon',
'X-Auth-Token': token(),
'X-Auth-Key': 'password',
'Accept': 'application/json',
'User-Agent': 'python-monascaclient',
'Content-Type': 'application/json'}
body = {}
response = requests.get(url=events_url + "/v2.0/events",
data=json.dumps(body),
headers=headers)
assert response.status_code == 200
print("GET /events success")
def test_stream_definition_post(): def test_stream_definition_post():
headers = { headers = {
'X-Auth-User': 'mini-mon', 'X-Auth-User': 'mini-mon',
@ -80,22 +99,29 @@ def test_stream_definition_post():
body = {} body = {}
notif_resp = requests.get(
url="http://192.168.10.4:8080/v2.0/notification-methods",
data=json.dumps(body), headers=headers)
notif_dict = json.loads(notif_resp.text)
action_id = str(notif_dict['elements'][0]['id'])
body = {"fire_criteria": [{"event_type": "compute.instance.create.start"}, body = {"fire_criteria": [{"event_type": "compute.instance.create.start"},
{"event_type": "compute.instance.create.end"}], {"event_type": "compute.instance.create.end"}],
"description": "provisioning duration", "description": "provisioning duration",
"name": "panda", "name": "panda",
"group_by": ["instance_id"], "group_by": ["instance_id"],
"expiration": 3, "expiration": 3000,
"select": [{"traits": {"tenant_id": "406904"}, "select": [{"traits": {"tenant_id": "406904"},
"event_type": "compute.instance.create.*"}], "event_type": "compute.instance.create.*"}],
"fire_actions": ["ed469bb9-2b4a-457a-9926-9da9f6ac75da"], "fire_actions": [action_id],
"expire_actions": ["ed469bb9-2b4a-457a-9926-9da9f6ac75da"]} "expire_actions": [action_id]}
response = requests.post(url=events_url + "/v2.0/stream-definitions", response = requests.post(
data=json.dumps(body), url=events_url + "/v2.0/stream-definitions",
headers=headers) data=json.dumps(body),
print(response.status_code) headers=headers)
print(response.text) assert response.status_code == 201
print("POST /stream-definitions success")
def test_stream_definition_get(): def test_stream_definition_get():
@ -109,11 +135,12 @@ def test_stream_definition_get():
body = {} body = {}
response = requests.post(url=events_url + "/v2.0/stream-definitions", response = requests.get(
data=json.dumps(body), url=events_url + "/v2.0/stream-definitions/",
headers=headers) data=json.dumps(body),
print(response.status_code) headers=headers)
print(response.text) assert response.status_code == 200
print("GET /stream-definitions success")
def test_stream_definition_delete(): def test_stream_definition_delete():
@ -127,15 +154,21 @@ def test_stream_definition_delete():
body = {} body = {}
response = requests.delete( stream_resp = requests.get(
url=events_url + "/v2.0/stream-definitions/86177f0e-f811-4c42-a91a-1813251bf93f", url=events_url + "/v2.0/stream-definitions/",
data=json.dumps(body), data=json.dumps(body),
headers=headers) headers=headers)
stream_dict = json.loads(stream_resp.text)
print(response.status_code) stream_id = str(stream_dict[0]['id'])
print(response.text) response = requests.delete(
url=events_url + "/v2.0/stream-definitions/{}".format(
stream_id),
data=json.dumps(body),
headers=headers)
assert response.status_code == 204
print("DELETE /stream-definitions success")
test_stream_definition_post() test_stream_definition_post()
test_stream_definition_get() test_stream_definition_get()
test_stream_definition_delete() test_stream_definition_delete()
test_events_get() test_events_get_all()

View File

@ -2,8 +2,8 @@
# logging, make sure that the user under whom the server runs has permission # logging, make sure that the user under whom the server runs has permission
# to write to the directory. # to write to the directory.
log_file = events_api.log log_file = events_api.log
log_dir = /var/log/monasca/events_api log_dir = .
log_level = INFO log_level = DEBUG
# Identifies the region that the Monasca API is running in. # Identifies the region that the Monasca API is running in.
region = useast region = useast