Skip to content

Commit

Permalink
Move base images tag info into its own file
Browse files Browse the repository at this point in the history
This makes it possible to run tests through pycharm or nosetests
without fiddling with environment variables.
  • Loading branch information
Eric Diven committed Sep 28, 2016
1 parent 51c67a5 commit 6c04a93
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ services:
- docker
env:
global:
- BASE_IMAGES_TAG=6
- PA_TEST_ONLINE_INSTALLER=true
- PYTHONPATH=$PYTHONPATH:$(pwd)
- LONG_PRODUCT_TESTS="tests/product/test_server_install.py tests/product/test_status.py tests/product/test_collect.py tests/product/test_connectors.py tests/product/test_control.py tests/product/test_server_uninstall.py"
Expand Down
28 changes: 15 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,24 @@ _test-all:
IMAGE_NAMES?="all"

#
# The canonical source of the BASE_IMAGES_TAG is .travis.yml because we don't
# have a good way to get that information into travis from somewhere else.
# The build process and product tests rely on several base Docker images.
# Teradata builds and releases a number of Docker images from the same
# repository, all versioned together. This makes it simple to verify that your
# test environment is sane: if all of the images are the same version, they
# should work together.
#
# Note that this is conditionally assigned. If you export
# BASE_IMAGES_TAG="something else" before invoking e.g. `make smoke', you'll
# get that value, not the one here. This makes it possible to test new docker
# images without modifying the Makefile
# As part of the process of releasing those images, we tag all of the images
# with the version number of the release. This means that anything that uses
# the images can reference them as `teradatalabs/image_name:version'. The
# Makefile needs to know that to pull the images, and the python code needs to
# know that for various reasons.
#
# To confirm the value of BASE_IMAGES_TAG that make is using, run `make bit'
# base-images-tag.json is the canonical source of the tag information for the
# repository. The python code parses it properly with the json module, and the
# Makefile parses it adequately with awk ;-)
#
BASE_IMAGES_TAG ?= $(shell awk '/BASE_IMAGES_TAG/ {split($$0, a, "="); print a[2]}' .travis.yml)
export BASE_IMAGES_TAG

.PHONY: bit
bit:
echo $(BASE_IMAGES_TAG)
BASE_IMAGES_TAG := $(shell awk '/base_images_tag/ \
{split($$NF, a, "\""); print a[2]}' base-images-tag.json)

test-images: docker-images presto-server-rpm.rpm
python tests/product/image_builder.py $(IMAGE_NAMES)
Expand Down
3 changes: 3 additions & 0 deletions base-images-tag.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"base_images_tag": "6"
}
13 changes: 11 additions & 2 deletions tests/product/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,25 @@
Module defining constants global to the product tests
"""

import json
import os
import sys

import prestoadmin
from prestoadmin import main_dir

BASE_IMAGES_TAG_CONFIG = 'base-images-tag.json'

#
# See the Makefile for an in-depth explanation of how we're using the base
# Docker images.
#
try:
BASE_IMAGES_TAG = os.environ['BASE_IMAGES_TAG']
with open(os.path.join(main_dir, BASE_IMAGES_TAG_CONFIG)) as tag_config:
tag_json = json.load(tag_config)
BASE_IMAGES_TAG = tag_json['base_images_tag']
except KeyError:
print "BASE_IMAGES_TAG must be set in the environment"
print "base_images_tag must be set in %s" % (BASE_IMAGES_TAG_CONFIG,)
sys.exit(1)


Expand Down

0 comments on commit 6c04a93

Please sign in to comment.