def get_status(): node1_host = get_first( get_first(get_dcos_command('task --json'), lambda t: t['name'] == 'node-1')['labels'], lambda label: label['key'] == 'offer_hostname' )['value'] return shakedown.run_command_on_agent( node1_host, "docker run -t --net=host pitrho/cassandra-nodetool nodetool -p 7199 status" )
def test_node_is_replaced(): infinity_commons.get_and_verify_plan(lambda p: p['status'] == 'COMPLETE') replaced_node_host = [ t['slave_id'] for t in get_dcos_command('task --json') if t['name'] == 'node-0' ][0] replaced_node_task_id = get_cassandra_command('node replace node-0')[0] assert 'node-0' in replaced_node_task_id plan = infinity_commons.get_and_verify_plan( lambda p: ( p['status'] == infinity_commons.PlanState.COMPLETE.value and len(infinity_commons.filter_phase(p, "Deploy")['steps']) == 3 ) ) print(plan) assert plan['status'] == infinity_commons.PlanState.COMPLETE.value # Check that we've created a new task with a new id, waiting until a new one comes up. def get_status(): return get_first( get_dcos_command('task --json'), lambda t: t['name'] == 'node-0' )['id'] def success_predicate(task_id): return task_id != replaced_node_task_id, 'Task ID for replaced node did not change' spin(get_status, success_predicate) # Check cluster status with nodetool to assure that the new node has rejoined the cluster # and the old node has been removed, waiting until it's running (status "UN"). def get_status(): node1_host = get_first( get_first(get_dcos_command('task --json'), lambda t: t['name'] == 'node-1')['labels'], lambda label: label['key'] == 'offer_hostname' )['value'] return shakedown.run_command_on_agent( node1_host, "docker run -t --net=host pitrho/cassandra-nodetool nodetool -p 7199 status" ) def success_predicate(status): command_succeeded, status = status succeeded = ( command_succeeded and len([x for x in status.split('\n') if x.startswith('UN')]) == DEFAULT_NODE_COUNT ) return succeeded, 'Node did not successfully rejoin cluster' spin(get_status, success_predicate)
def get_pkg_version(): cmd = 'package describe {}'.format(SERVICE_NAME) print("get_pkg_version cmd: " + cmd) pkg_description = get_dcos_command(cmd) print("pkg_description: " + pkg_description) return pkg_description['version']
def get_status(): return get_first( get_dcos_command('task --json'), lambda t: t['name'] == 'node-0' )['id']
def get_status(): first_node0 = get_first(get_dcos_command('task --json'), lambda t: t['name'] == 'node-0') if first_node0: return first_node0['id'] return None
def get_pkg_version(): cmd = 'package describe {}'.format(PACKAGE_NAME) pkg_description = get_dcos_command(cmd) return pkg_description['version']