monkey/envs/monkey_zoo/blackbox/test_blackbox.py

33 lines
1.0 KiB
Python
Raw Normal View History

2019-08-27 20:52:39 +08:00
import unittest
2019-08-27 23:12:14 +08:00
from .gcp_machine_handlers import GCPHandler
2019-08-27 20:52:39 +08:00
2019-08-27 21:23:09 +08:00
import requests
from config import *
2019-08-27 20:52:39 +08:00
class TestMonkeyBlackbox(unittest.TestCase):
2019-08-27 23:12:14 +08:00
2019-08-27 20:52:39 +08:00
@classmethod
def setUpClass(cls):
2019-08-27 23:12:14 +08:00
GCPHandler().start_machines("elastic-4")
2019-08-27 20:52:39 +08:00
print("Setting up all GCP machines...")
@classmethod
def tearDownClass(cls):
2019-08-27 23:12:14 +08:00
GCPHandler().stop_machines("elastic-4")
2019-08-27 20:52:39 +08:00
print("Killing all GCP machines...")
2019-08-27 21:23:09 +08:00
def generic_blackbox_test_case(self, config_file_path, analyzers):
self.load_config_into_server(config_file_path)
self.run_local_monkey_on_island()
for analyzer in analyzers:
assert analyzer.analyze_test_results()
def load_config_into_server(self, config_file_path):
print("uploading {} to {}".format(config_file_path, ISLAND_SERVER_ADDRESS))
def run_local_monkey_on_island(self):
print("Trying to run local monkey on {}".format(ISLAND_SERVER_ADDRESS))
print(requests.get(ISLAND_SERVER_URL_FORMAT.format(resource="api"), verify=False).text)