/
test_server_cms_cpu.py
61 lines (49 loc) · 1.71 KB
/
test_server_cms_cpu.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
###############################################################
# pytest -v --capture=no tests/test_server_cms_cpu.py
# pytest -v tests/test_server_cms_cpu.py
# pytest -v --capture=no tests/test_server_cms_cpu..py::Test_server_cms::<METHODNAME>
###############################################################
import os
import time
import pytest
import requests
from cloudmesh.common.Benchmark import Benchmark
from cloudmesh.common.debug import VERBOSE
from cloudmesh.common.util import HEADING
Benchmark.debug()
cloud = "local"
name = "cpu"
yaml_file = f"./tests/server-cpu/{name}.yaml"
@pytest.mark.incremental
class TestServerCms:
def test_start(self):
HEADING()
Benchmark.Start()
os.system(f"cms openapi server start {yaml_file} --directory=./tests/server-cpu/")
time.sleep(4)
result = requests.get('http://127.0.0.1:8080/cloudmesh/ui')
Benchmark.Stop()
assert result.status_code == 200 # find test
def test_cpu(self):
HEADING()
url = "http://127.0.0.1:8080/cloudmesh/cpu"
Benchmark.Start()
result = requests.get(url)
time.sleep(4)
assert result.status_code == 200
assert result.reason == 'OK'
assert result.headers['content-type'] =='application/json'
assert result.json().get('model') is not None
Benchmark.Stop()
VERBOSE(result)
def test_stop(self):
HEADING()
Benchmark.Start()
os.system(f"cms openapi server stop {name}")
Benchmark.Stop()
gotException=False;
try:
result = requests.get('http://127.0.0.1:8080/cloudmesh/ui')
except Exception as ex:
gotException=True
assert gotException