Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Pytest support #74

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions dcos_launch/platforms/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,13 @@ def get_auto_scaling_instances(self, asg_physical_resource_id):
AutoScalingGroupNames=[asg_physical_resource_id])
['AutoScalingGroups'] for i in asg['Instances']]

@retry_boto_rate_limits
def put_s3(self, bucket, keyname, file, acl='public-read'):
return self.resource('s3').Bucket(bucket_id).put_object(
Key=keyname,
Body=file,
ACL=acl)

@retry_boto_rate_limits
def empty_and_delete_bucket(self, bucket_id):
""" Buckets must be empty to be deleted. Additionally, there is no high-level
Expand Down
11 changes: 7 additions & 4 deletions dcos_launch/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,13 @@ def wait(self):
def delete(self):
raise NotImplementedError()

def test(self, args: list, env_dict: dict, test_host=None, test_port=22) -> int:
def test(self, args: list, env_dict: dict, test_host=None, test_port=22, output=None) -> int:
""" Connects to master host with SSH and then run the internal integration test

Args:
args: a list of args that will follow the py.test command
env_dict: the env to use during the test
output: optional handle to write test output to. If None, defaults to stdout.
"""
if args is None:
args = list()
Expand Down Expand Up @@ -123,10 +124,10 @@ def test(self, args: list, env_dict: dict, test_host=None, test_port=22) -> int:
test_host = details['masters'][0]['public_ip']
if ':' in test_host:
test_host, test_port = test_host.split(':')
return try_to_output_unbuffered(self.config, test_host, pytest_cmd, test_port)
return try_to_output_unbuffered(self.config, test_host, pytest_cmd, test_port, stdout=output)


def try_to_output_unbuffered(info, test_host: str, bash_cmd: str, port: int) -> int:
def try_to_output_unbuffered(info, test_host: str, bash_cmd: str, port: int, stdout=None) -> int:
""" Tries to run a command and directly output to STDOUT

Args:
Expand All @@ -140,7 +141,9 @@ def try_to_output_unbuffered(info, test_host: str, bash_cmd: str, port: int) ->
ssh_client = dcos_test_utils.ssh_client.SshClient(info['ssh_user'], info['ssh_private_key'])
ssh_client.wait_for_ssh_connection(test_host, port=port)
try:
ssh_client.command(test_host, ['bash', '-c', bash_cmd], port=port, stdout=sys.stdout.buffer)
if stdout is None:
stdout = sys.stdout.buffer
ssh_client.command(test_host, ['bash', '-c', bash_cmd], port=port, stdout=stdout)
except subprocess.CalledProcessError as e:
log.exception('Test run failed!')
return e.returncode
Expand Down