From 2ae6c15a40682d9c1b2a14f0788236301bd57537 Mon Sep 17 00:00:00 2001 From: Kyle Anderson Date: Tue, 3 Nov 2015 12:46:51 -0800 Subject: [PATCH 1/2] Fix more tests to work on a non yelp dev box --- general_itests/fake_simple_service/Dockerfile | 2 +- .../paasta_execute_docker_command.feature | 2 +- .../steps/paasta_execute_docker_command.py | 15 ++++++++++++--- paasta_itests/docker-compose.yml | 2 +- paasta_tools/monitoring_tools.py | 12 ++++++++++-- tox.ini | 2 +- yelp_package/dockerfiles/trusty/Dockerfile | 2 ++ 7 files changed, 28 insertions(+), 9 deletions(-) diff --git a/general_itests/fake_simple_service/Dockerfile b/general_itests/fake_simple_service/Dockerfile index 3f79c10aa7..b2ab5b07ae 100644 --- a/general_itests/fake_simple_service/Dockerfile +++ b/general_itests/fake_simple_service/Dockerfile @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM docker-dev.yelpcorp.com/trusty_yelp +FROM ubuntu:trusty diff --git a/general_itests/paasta_execute_docker_command.feature b/general_itests/paasta_execute_docker_command.feature index d8d1ed6dd1..d4161d9206 100644 --- a/general_itests/paasta_execute_docker_command.feature +++ b/general_itests/paasta_execute_docker_command.feature @@ -14,4 +14,4 @@ Feature: paasta_execute_docker_command can find and run commands inside a docker Given a running docker container with task id foo When we paasta_execute_docker_command a command with exit code 0 in container with task id foo And we paasta_execute_docker_command a command with exit code 0 in container with task id foo - Then the docker container has 1 exec instances \ No newline at end of file + Then the docker container has at most 1 exec instances diff --git a/general_itests/steps/paasta_execute_docker_command.py b/general_itests/steps/paasta_execute_docker_command.py index 890d96debb..c10d8cdb1d 100644 --- a/general_itests/steps/paasta_execute_docker_command.py +++ b/general_itests/steps/paasta_execute_docker_command.py @@ -35,7 +35,7 @@ def create_docker_container(context, task_id): pass container = docker_client.create_container( name=container_name, - image='docker-dev.yelpcorp.com/trusty_yelp:latest', + image='ubuntu:trusty', command='/bin/sleep infinity', environment={'MESOS_TASK_ID': task_id}, ) @@ -57,8 +57,17 @@ def paasta_execute_docker_command_result(context, code): assert int(code) == int(context.return_code) -@then(u'the docker container has {num} exec instances') +@then(u'the docker container has at most {num} exec instances') def check_container_exec_instances(context, num): + """Modern docker versions remove ExecIDs after they finished, but older + docker versions leave ExecIDs behind. This test is for assering that + the ExecIDs are cleaned up one way or another""" container_info = context.docker_client.inspect_container(context.running_container_id) + if container_info['ExecIDs'] is None: + execs = [] + else: + execs = container_info['ExecIDs'] print 'Container info:\n%s' % container_info - assert len(container_info['ExecIDs']) == int(num) + print "Number of execs %d" % len(execs) + print "Number expected: %d" % int(num) + assert len(execs) <= int(num) diff --git a/paasta_itests/docker-compose.yml b/paasta_itests/docker-compose.yml index fcd9a549ce..d0489516ca 100644 --- a/paasta_itests/docker-compose.yml +++ b/paasta_itests/docker-compose.yml @@ -31,7 +31,7 @@ marathon: command: 'marathon --zk zk://zookeeper:2181/marathon --master zk://zookeeper:2181/mesos-testcluster --no-logger' paastatools: - build: ../yelp_package/dockerfiles/lucid/ + build: ../yelp_package/dockerfiles/trusty/ links: - marathon - mesosmaster diff --git a/paasta_tools/monitoring_tools.py b/paasta_tools/monitoring_tools.py index 71d3713695..28a2a09e47 100644 --- a/paasta_tools/monitoring_tools.py +++ b/paasta_tools/monitoring_tools.py @@ -22,6 +22,7 @@ Everything in here is private, and you shouldn't worry about it. """ import json +import logging import os import service_configuration_lib @@ -30,6 +31,9 @@ from utils import load_system_paasta_config +log = logging.getLogger('__main__') + + def get_team(overrides, service, soa_dir=service_configuration_lib.DEFAULT_SOA_DIR): return __get_monitoring_config_value('team', overrides, service, soa_dir) @@ -134,8 +138,12 @@ def get_sensu_team_data(team): def _load_sensu_team_data(): - with open('/etc/sensu/team_data.json') as f: - team_data = json.load(f) + try: + with open('/etc/sensu/team_data.json') as f: + team_data = json.load(f) + except IOError: + log.warning("No Sensu Team data (/etc/sensu/team_data.json) available. Using empty defaults") + team_data = {} return team_data diff --git a/tox.ini b/tox.ini index 6bd91a993c..a46107abcf 100644 --- a/tox.ini +++ b/tox.ini @@ -74,9 +74,9 @@ setenv = DOCKER_COMPOSE_PROJECT_NAME = paastatools_inside_container changedir=paasta_itests/ deps = - {[testenv]deps} behave mock + -r/work/requirements.txt commands = behave {posargs} diff --git a/yelp_package/dockerfiles/trusty/Dockerfile b/yelp_package/dockerfiles/trusty/Dockerfile index 485e0a8c79..a66de58d33 100644 --- a/yelp_package/dockerfiles/trusty/Dockerfile +++ b/yelp_package/dockerfiles/trusty/Dockerfile @@ -21,4 +21,6 @@ RUN apt-get update && apt-get -y install dpkg-dev python-tox python-setuptools \ RUN curl http://ppa.launchpad.net/dh-virtualenv/daily/ubuntu/pool/main/d/dh-virtualenv/dh-virtualenv_0.10-0~80~ubuntu14.04.1_all.deb --output dh-virtualenv_0.10-0~80~ubuntu14.04.1_all.deb && \ dpkg -i dh-virtualenv_0.10-0~80~ubuntu14.04.1_all.deb && rm dh-virtualenv_0.10-0~80~ubuntu14.04.1_all.deb +ENV HOME /work +ENV PWD /work WORKDIR /work From ac4cda2b821a0a13cb53936e22382ff53d607d38 Mon Sep 17 00:00:00 2001 From: Kyle Anderson Date: Wed, 4 Nov 2015 13:41:36 -0800 Subject: [PATCH 2/2] Removed extra print commands from itest output --- general_itests/steps/paasta_execute_docker_command.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/general_itests/steps/paasta_execute_docker_command.py b/general_itests/steps/paasta_execute_docker_command.py index c10d8cdb1d..d736f31397 100644 --- a/general_itests/steps/paasta_execute_docker_command.py +++ b/general_itests/steps/paasta_execute_docker_command.py @@ -68,6 +68,4 @@ def check_container_exec_instances(context, num): else: execs = container_info['ExecIDs'] print 'Container info:\n%s' % container_info - print "Number of execs %d" % len(execs) - print "Number expected: %d" % int(num) assert len(execs) <= int(num)