Skip to content

Commit

Permalink
Add integration test (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
functicons authored Jun 15, 2019
1 parent f29ce54 commit 05226fc
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
__pycache__
*.pyc
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
.PHONY: clean
.PHONY: tests

all: clean tests
default: clean unit_tests

clean:
rm -f custom_image_utils/*.pyc
rm -f tests/*.pyc
rm -f custom_image_utils/*.pyc tests/*.pyc

tests:
unit_tests:
python2 -m unittest discover

integration_tests:
bash tests/test_create_custom_image.sh
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ python generate_custom_image.py \
* **--dry-run**: Dry run mode which only validates input and generates
workflow script without creating image. Disabled by default.

### Example
### Examples

#### Create a custom image without Daisy (recommended)

Expand Down
15 changes: 7 additions & 8 deletions examples/customization_script.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash

# Copyright 2019 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the 'License');
Expand All @@ -12,12 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

#!/bin/bash

# Initialization actions examples:
#
# apt-get -y update
# apt-get install python-dev
# apt-get install python-pip
# pip install numpy

echo "Installing custom packages..."
apt-get -y update
apt-get install python-dev python-pip -y
pip install numpy
echo "Successfully installed custom packages."
27 changes: 27 additions & 0 deletions tests/test_create_custom_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

# Copyright 2019 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

this_dir=$(cd $(dirname ${BASH_SOURCE[0]}) >/dev/null 2>&1 && pwd)
repo_dir=$(realpath ${this_dir}/..)
suffix=$(cat /dev/urandom | tr -dc 'a-z0-9' | head -c 6)
image_name=test-image-${suffix}

python2 ${repo_dir}/generate_custom_image.py \
--image-name ${image_name} \
--dataproc-version 1.4.5-debian9 \
--customization-script ${repo_dir}/examples/customization_script.sh \
--zone us-west1-a \
--gcs-bucket gs://dataproc-custom-images-presubmit

0 comments on commit 05226fc

Please sign in to comment.