def test_connect(install_framework): try: result = dcos.http.get(cassandra_api_url('connection')) try: body = result.json() assert len(body) == 3 assert len(body["address"]) == DEFAULT_NODE_COUNT assert len(body["dns"]) == DEFAULT_NODE_COUNT assert body[ "vip"] == 'node.{}.l4lb.thisdcos.directory:9042'.format( PACKAGE_NAME) except: print('Failed to parse connect response') raise except: # TODO: remove fallback when universe has recent build with '/connection' result = dcos.http.get(cassandra_api_url('nodes/connect')) try: body = result.json() assert len(body) == 2 assert len(body["address"]) == DEFAULT_NODE_COUNT assert len(body["dns"]) == DEFAULT_NODE_COUNT except: print('Failed to parse connect response') raise
def test_connect_address(install_framework): # TODO: remove fallback when universe has recent build with '/connection' try: result = dcos.http.get(cassandra_api_url('connection/address')) except: result = dcos.http.get(cassandra_api_url('nodes/connect/address')) try: body = result.json() assert len(body) == DEFAULT_NODE_COUNT except: print('Failed to parse connect response') raise
def get_and_verify_plan(predicate=lambda r: True): global counter plan_url = cassandra_api_url('plan') def fn(): try: return dcos.http.get(plan_url) except dcos.errors.DCOSHTTPException as err: return err.response def success_predicate(result): global counter message = 'Request to {} failed'.format(plan_url) try: body = result.json() except ValueError: return False, message if counter < 3: counter += 1 pred_res = predicate(body) if pred_res: counter = 0 return pred_res, message return spin(fn, success_predicate).json()
def get_and_verify_plan(predicate=lambda r: True, wait_time=WAIT_TIME_IN_SECONDS): global counter plan_url = cassandra_api_url('plan') def fn(): try: return dcos.http.get(plan_url) except dcos.errors.DCOSHTTPException as err: return err.response def success_predicate(result): global counter message = 'Request to {} failed'.format(plan_url) try: body = result.json() except ValueError: return False, message if counter < 3: counter += 1 pred_res = predicate(body) if pred_res: counter = 0 return pred_res, message return spin(fn, success_predicate, wait_time=wait_time).json()
def run_repair(): payload = {'nodes': ['*']} request( dcos.http.put, cassandra_api_url('repair/start'), json=payload, )
def test_connect(): result = dcos.http.get(cassandra_api_url('connection')) body = result.json() assert len(body) == 3 assert len(body["address"]) == DEFAULT_NODE_COUNT assert len(body["dns"]) == DEFAULT_NODE_COUNT assert body["vip"] == 'node.{}.l4lb.thisdcos.directory:9042'.format(PACKAGE_NAME)
def run_cleanup(): payload = {'nodes': ['*']} request( dcos.http.put, cassandra_api_url('cleanup/start'), json=payload, )
def run_repair(): payload = {'nodes': ['*']} request( requests.put, cassandra_api_url('repair/start'), json=payload, headers=request_headers() )
def run_cleanup(): payload = {'nodes': ['*']} request( requests.put, cassandra_api_url('cleanup/start'), json=payload, headers=request_headers() )
def run_repair(): payload = {'nodes': '*'} str = cassandra_api_url('/plans/repair/start') print(str) #dcos.http.post(str, data=None, json=payload) request( dcos.http.post, str, data=None, json=payload#, #is_success=request_success )
def test_marathon_rack_not_found(): install(additional_options={"service": {"placement_constraint": "rack_id:LIKE:rack-foo-.*"}}) try: check_health(wait_time=60) # long enough for /plan to work and for a node to have been IN_PROGRESS assert False, "Should have failed healthcheck" except: pass # expected to fail, just wanting to wait 30s plan = dcos.http.get(cassandra_api_url("plan"), is_success=allow_incomplete_plan).json() # check that first node is still (unsuccessfully) looking for a match: assert plan["status"] == infinity_commons.PlanState.IN_PROGRESS.value assert infinity_commons.filter_phase(plan, "Deploy")["steps"][0]["status"] == "PENDING" uninstall()
def test_connect(install_framework): try: result = dcos.http.get(cassandra_api_url('connection')) try: body = result.json() assert len(body) == 3 assert len(body["address"]) == DEFAULT_NODE_COUNT assert len(body["dns"]) == DEFAULT_NODE_COUNT assert body["vip"] == 'node.{}.l4lb.thisdcos.directory:9042'.format(PACKAGE_NAME) except: print('Failed to parse connect response') raise except: # TODO: remove fallback when universe has recent build with '/connection' result = dcos.http.get(cassandra_api_url('nodes/connect')) try: body = result.json() assert len(body) == 2 assert len(body["address"]) == DEFAULT_NODE_COUNT assert len(body["dns"]) == DEFAULT_NODE_COUNT except: print('Failed to parse connect response') raise
def test_marathon_rack_not_found(): # install without waiting, since the install should never succeed and a timeout would result in an # assertion failure install(additional_options={ 'service': { 'placement_constraint': 'rack_id:LIKE:rack-foo-.*' } }, wait=False) try: check_health( wait_time=60 ) # long enough for /plan to work and for a node to have been IN_PROGRESS assert False, "Should have failed healthcheck" except: pass # expected to fail, just wanting to wait 30s plan = dcos.http.get(cassandra_api_url('plan'), is_success=allow_incomplete_plan).json() # check that first node is still (unsuccessfully) looking for a match: assert plan['status'] == infinity_commons.PlanState.IN_PROGRESS.value assert infinity_commons.filter_phase( plan, "Deploy")['steps'][0]['status'] == 'PENDING' uninstall()
def fn(): return dcos.http.get(cassandra_api_url('plan'))
def test_is_suppressed(): infinity_commons.get_and_verify_plan(lambda p: p['status'] == 'COMPLETE') time.sleep(5) response = dcos.http.get(cassandra_api_url('state/properties/suppressed')) response.raise_for_status() assert response.text == "true"
def fn(): str = cassandra_api_url('plans/deploy') print("get_and_verify_plan: " + str) return dcos.http.get(str, is_success=request_success)
def test_connect_dns(): result = dcos.http.get(cassandra_api_url('connection/dns')) body = result.json() assert len(body) == DEFAULT_NODE_COUNT
def fn(): return dcos.http.get(cassandra_api_url('plan'), is_success=request_success)
def fn(): return requests.get( cassandra_api_url('plan'), headers=request_headers() )