Skip to content

Commit

Permalink
PM #9 - Fix remote server usage. The current implementation was using…
Browse files Browse the repository at this point in the history
… the old data model.
  • Loading branch information
js-dieu committed Mar 31, 2020
1 parent 755115f commit 3bb0fdf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
3 changes: 3 additions & 0 deletions docs/sources/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Changelog
=========

* :release:`1.1.1 <2020-03-31>`
* :bug:`9` Fix remote server interface for sending measures.

* :release:`1.1.0 <2020-03-30>`
* :feature:`5` Extend item information and separate item from its variants.
* :feature:`3` Compute user time and kernel time on a per test basis for clarity and ease of exploitation.
Expand Down
29 changes: 23 additions & 6 deletions pytest_monitor/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,16 @@ def compute_info(self, description):
if self.__db:
self.__db.insert_session(self.__session, run_date, scm, description)
if self.__remote:
warnings.warn('todo')
r = requests.post(f'{self.__remote}/sessions/',
json=dict(session_h=self.__session,
run_date=run_date,
scm_ref=scm,
description=description))
if r.status_code != 200:
self.__remote = ''
msg = f"Cannot insert session in remote monitor server ({r.status_code})! Deactivating...')"
warnings.warn(msg)


def set_environment_info(self, env):
self.__eid = self.get_env_id(env)
Expand Down Expand Up @@ -105,13 +114,21 @@ def add_test_info(self, item, item_path, item_variant, item_loc, kind, component
kernel_time, cpu_usage, mem_usage)
if self.__remote and self.remote_env_id is not None:
r = requests.post(f'{self.__remote}/metrics/',
json=dict(context_h=self.remote_env_id,
item=item, kind=kind, component=final_component, total_time=total_time,
item_start_time=item_start_time, user_time=user_time,
json=dict(session_h=self.__session,
context_h=self.remote_env_id,
item_start_time=item_start_time,
item_path=item_path,
item=item,
item_variant=item_variant,
item_fs_loc=item_loc,
kind=kind,
component=final_component,
total_time=total_time,
user_time=user_time,
kernel_time=kernel_time,
cpu_usage=cpu_usage, mem_usage=mem_usage))
cpu_usage=cpu_usage,
mem_usage=mem_usage))
if r.status_code != 200:
print(r.text)
self.__remote = ''
msg = f"Cannot insert values in remote monitor server ({r.status_code})! Deactivating...')"
warnings.warn(msg)

0 comments on commit 3bb0fdf

Please sign in to comment.