Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix more tests to work on a non yelp dev box #18

Merged
merged 2 commits into from
Nov 4, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion general_itests/fake_simple_service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion general_itests/paasta_execute_docker_command.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Then the docker container has at most 1 exec instances
15 changes: 12 additions & 3 deletions general_itests/steps/paasta_execute_docker_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
)
Expand All @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh. I don't know why in behave these asserts don't act like py.test asserts. I found it pretty difficult to get past "assertion failed" messages.

print "Number expected: %d" % int(num)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete?

assert len(execs) <= int(num)
2 changes: 1 addition & 1 deletion paasta_itests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions paasta_tools/monitoring_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ setenv =
DOCKER_COMPOSE_PROJECT_NAME = paastatools_inside_container
changedir=paasta_itests/
deps =
{[testenv]deps}
behave
mock
-r/work/requirements.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is right? I know you struggled with this but it worked before, and now if the testenv stanza gets new deps (maybe the wrong place to put them?) they will not be picked up here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really tried hard to get to the bottom of this. For whatever reason, on trusty, in tox, in docker, the current working directory is "/work", which is fine. But when tox does the deps install, it's cwd is deep within the .tox dir for whatever reason.

I agree that we lose cohesion with testenv deps. I couldn't figure out any other way :(

commands =
behave {posargs}

Expand Down
2 changes: 2 additions & 0 deletions yelp_package/dockerfiles/trusty/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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