def test_loop_pgt_post(self): c = RestClient("localhost", lgweb_port, timeout=10) # an API call with an empty form should cause an error self.assertRaises(RestClientException, c._POST, "/gen_pgt") # new logical graph JSON with open( os.path.join(lg_dir, "logical_graphs", "testLoop.graph"), "rb" ) as infile: json_data = infile.read() # add 'correct' data to the form form_data = { "algo": "metis", "lg_name": "metis.graph", "json_data": json_data, "num_islands": 0, "num_par": 1, "par_label": "Partition", "max_load_imb": 100, "max_cpu": 8, } # POST form to /gen_pgt try: content = urllib.parse.urlencode(form_data) c._POST( "/gen_pgt", content, content_type="application/x-www-form-urlencoded" ) except RestClientException as e: self.fail(e)
def test_get_pgt_post(self): c = RestClient('localhost', lgweb_port, 10) # an API call with an empty form should cause an error self.assertRaises(RestClientException, c._POST, '/gen_pgt') # new logical graph JSON with open('test/dropmake/logical_graphs/test-20190830-110556.graph', 'rb') as infile: json_data = infile.read() # add 'correct' data to the form form_data = { 'algo': 'metis', 'lg_name': 'metis.graph', 'json_data': json_data, 'num_islands': 0, 'num_par': 1, 'par_label': 'Partition', 'max_load_imb': 100, 'max_cpu': 8 } # POST form to /gen_pgt try: content = urllib.urlencode(form_data) c._POST('/gen_pgt', content, content_type='application/x-www-form-urlencoded') except RestClientException as e: self.fail(e)
def start_nodes(self): if not self._k8s_access: raise RuntimeError("Cannot access k8s") ips = [x["svc"] for x in self._pod_details.values()] ips.remove(self._pod_details["master"]["svc"]) for ip in ips: client = RestClient( ip, self._value_data["service"]["daemon"]["port"], timeout=30 ) time.sleep(5) logger.debug(f"Starting node on {ip}") # node_ips = ['127.0.0.1'] + [x['ip'] for x in self._pod_details.values()] node_ips = [x["ip"] for x in self._pod_details.values()] # data = json.dumps({'nodes': ['127.0.0.1']}).encode('utf-8') data = json.dumps({"nodes": node_ips}).encode("utf-8") client._POST( "/managers/master/start", content=data, content_type="application/json" ).read()
def start_manager(self, manager_node): if not self._k8s_access: raise RuntimeError("Cannot access k8s") self._submission_endpoint = self._pod_details[manager_node]["svc"] client = RestClient( self._submission_endpoint, self._value_data["service"]["daemon"]["port"], timeout=30, ) node_ips = [x["ip"] for x in self._pod_details.values()] print(node_ips) data = json.dumps({"nodes": node_ips}).encode("utf-8") time.sleep(5) logger.debug(f"Starting manager on {self._submission_endpoint}") client._POST( "/managers/island/start", content=data, content_type="application/json" ).read() client._POST( "/managers/master/start", content=data, content_type="application/json" ).read()