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

Set up Bazel build system to outsource parameterization #642

Merged
merged 32 commits into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
89af9e0
Set up Bazel configuration for bigtable as a sample
Oct 7, 2019
e115809
Set up Bazel build system for all our init actions. We can now specif…
Oct 11, 2019
8277546
Add absl archive dependency to WORKSPACE and refactor our integration…
Oct 15, 2019
4b7a812
Update test_solr.py
estebanlau Oct 15, 2019
09e43c0
Remove params flag
Oct 16, 2019
6e70ad3
Fix deps and nits
Oct 16, 2019
b0f7c9b
Update BUILD
estebanlau Oct 16, 2019
1c6847a
Update BUILD
estebanlau Oct 16, 2019
2a793f8
Define and instantiate flags at the DataprocTestCase class, which is …
Oct 17, 2019
5707ca0
Define hyphened init actions at the top-level to overcome Bazel namin…
Oct 18, 2019
4ae058e
Missed some changes corresponding to last commit message
Oct 18, 2019
5ce6525
Fix exit command
Oct 18, 2019
c3567a9
testing
Oct 18, 2019
cfa16a3
testing2
Oct 21, 2019
277c7df
testing3
Oct 21, 2019
fb1d6af
testing4
Oct 21, 2019
a7bda2f
testing5
Oct 21, 2019
c9761c7
testing new
Oct 21, 2019
3c4f518
testing new2
Oct 21, 2019
7e38e71
Add six dep
Oct 21, 2019
271ebc3
testing new3
Oct 21, 2019
aff8a4b
Update presubmit.sh
estebanlau Oct 21, 2019
6cb2085
Buildify BUILD files
medb Oct 22, 2019
9a5fc6e
Fix Bazel build
medb Oct 22, 2019
0d7f2b0
Migrate to absltest to support CLI flags
medb Oct 23, 2019
29d4957
Fix presubmit and run all image branches in parallel
medb Oct 23, 2019
cf7f5bd
Format Python code
medb Oct 23, 2019
a885710
Parallelize parametrized tests
medb Oct 23, 2019
e5c83e0
Fix Cloud Build config
medb Oct 23, 2019
37deb85
Various presubmit fixes
medb Oct 23, 2019
416c419
Install setuptools dependency
medb Oct 23, 2019
2f0bf27
Fix bazel presubmit
medb Oct 23, 2019
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@

# Ignore Python cache files after running tests
*/__pycache__/

# Ignore all bazel-* symlinks. There is no full list since this can change
# based on the name of the directory bazel is cloned into.
/bazel-*
91 changes: 91 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package(default_visibility = ["//visibility:public"])

test_suite(
name = "DataprocInitActionsTestSuite",
tests = [
":test_cloud_sql_proxy",
":test_dr_elephant",
":test_hive_hcatalog",
":test_starburst_presto",
"//bigtable:test_bigtable",
"//conda:test_conda",
"//connectors:test_connectors",
"//datalab:test_datalab",
"//drill:test_drill",
"//flink:test_flink",
"//ganglia:test_ganglia",
"//gpu:test_gpu",
"//hbase:test_hbase",
"//hue:test_hue",
"//jupyter:test_jupyter",
"//kafka:test_kafka",
"//livy:test_livy",
"//oozie:test_oozie",
"//presto:test_presto",
"//ranger:test_ranger",
"//rapids:test_rapids",
"//rstudio:test_rstudio",
"//solr:test_solr",
"//tez:test_tez",
"//tony:test_tony",
],
)

py_test(
name = "test_cloud_sql_proxy",
size = "enormous",
srcs = ["cloud-sql-proxy/test_cloud_sql_proxy.py"],
data = ["cloud-sql-proxy/cloud-sql-proxy.sh"],
local = True,
shard_count = 3,
deps = [
":pyspark_metastore_test",
"//integration_tests:dataproc_test_case",
"@io_abseil_py//absl/testing:parameterized",
],
)

py_test(
name = "test_dr_elephant",
size = "enormous",
srcs = ["dr-elephant/test_dr_elephant.py"],
data = ["dr-elephant/dr-elephant.sh"],
local = True,
shard_count = 2,
deps = [
"//integration_tests:dataproc_test_case",
"@io_abseil_py//absl/testing:parameterized",
],
)

py_test(
name = "test_hive_hcatalog",
size = "enormous",
srcs = ["hive-hcatalog/test_hive_hcatalog.py"],
data = ["hive-hcatalog/hive-hcatalog.sh"],
local = True,
shard_count = 6,
deps = [
"//integration_tests:dataproc_test_case",
"@io_abseil_py//absl/testing:parameterized",
],
)

py_test(
name = "test_starburst_presto",
size = "enormous",
srcs = ["starburst-presto/test_starburst_presto.py"],
data = ["starburst-presto/presto.sh"],
local = True,
shard_count = 4,
deps = [
"//integration_tests:dataproc_test_case",
"@io_abseil_py//absl/testing:parameterized",
],
)

py_library(
name = "pyspark_metastore_test",
testonly = True,
srcs = ["cloud-sql-proxy/pyspark_metastore_test.py"],
)
25 changes: 25 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_python",
sha256 = "aa96a691d3a8177f3215b14b0edc9641787abaaa30363a080165d06ab65e1161",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.0.1/rules_python-0.0.1.tar.gz",
)

http_archive(
name = "io_abseil_py",
sha256 = "9b324bc96587819a1420c592cf5d54424456645719f1de6bb22f7045bb6dbc6b",
strip_prefix = "abseil-py-master",
url = "https://github.com/abseil/abseil-py/archive/master.zip",
)

http_archive(
name = "six_archive",
build_file = "@io_abseil_py//third_party:six.BUILD",
sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a",
strip_prefix = "six-1.10.0",
urls = [
"http://mirror.bazel.build/pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz",
"https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz",
],
)
20 changes: 20 additions & 0 deletions bigtable/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package(default_visibility = ["//visibility:public"])

py_test(
name = "test_bigtable",
size = "enormous",
srcs = ["test_bigtable.py"],
data = ["bigtable.sh"],
local = True,
shard_count = 3,
deps = [
":run_hbase_commands",
"//integration_tests:dataproc_test_case",
"@io_abseil_py//absl/testing:parameterized",
],
)

py_library(
name = "run_hbase_commands",
srcs = ["run_hbase_commands.py"],
)
38 changes: 16 additions & 22 deletions bigtable/test_bigtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
See: https://cloud.google.com/bigtable/docs/cbt-overview
"""
import os
import unittest

from parameterized import parameterized
from absl.testing import absltest
from absl.testing import parameterized

from integration_tests.dataproc_test_case import DataprocTestCase

Expand Down Expand Up @@ -48,13 +48,14 @@ def tearDown(self):
def _validate_bigtable(self):
_, stdout, _ = self.assert_command(
'cbt -instance {} count test-bigtable '.format(self.db_name))
self.assertEqual(int(float(stdout)), 4,
"Invalid BigTable instance count")
self.assertEqual(
int(float(stdout)), 4, "Invalid BigTable instance count")

def verify_instance(self, name):
self.upload_test_file(
os.path.join(os.path.dirname(os.path.abspath(__file__)),
self.TEST_SCRIPT_FILE_NAME), name)
os.path.join(
os.path.dirname(os.path.abspath(__file__)),
self.TEST_SCRIPT_FILE_NAME), name)
self.assert_instance_command(
name, "python {}".format(self.TEST_SCRIPT_FILE_NAME))
self._validate_bigtable()
Expand All @@ -64,26 +65,19 @@ def verify_instance(self, name):
admin commands are provided from text file.
"""

@parameterized.expand(
[
("SINGLE", "1.2", ["m"]),
("STANDARD", "1.2", ["m"]),
("HA", "1.2", ["m-0"]),
("SINGLE", "1.3", ["m"]),
("STANDARD", "1.3", ["m"]),
("HA", "1.3", ["m-0"]),
],
testcase_func_name=DataprocTestCase.generate_verbose_test_name)
def test_bigtable(self, configuration, dataproc_version, machine_suffixes):
self.createCluster(configuration,
self.INIT_ACTIONS,
dataproc_version,
metadata=self.metadata)
@parameterized.parameters(
("SINGLE", ["m"]),
("STANDARD", ["m"]),
("HA", ["m-0"]),
)
def test_bigtable(self, configuration, machine_suffixes):
self.createCluster(
configuration, self.INIT_ACTIONS, metadata=self.metadata)

for machine_suffix in machine_suffixes:
self.verify_instance("{}-{}".format(self.getClusterName(),
machine_suffix))


if __name__ == '__main__':
unittest.main()
absltest.main()
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import json
import logging
import unittest

from parameterized import parameterized
from absl.testing import absltest
from absl.testing import parameterized

from integration_tests.dataproc_test_case import DataprocTestCase

Expand Down Expand Up @@ -50,31 +50,23 @@ def __submit_pyspark_job(self, cluster_name):
cluster_name, 'pyspark',
'{}/{}'.format(self.INIT_ACTIONS_REPO, self.TEST_SCRIPT_FILE_NAME))

@parameterized.expand(
[
("SINGLE", "1.2"),
("STANDARD", "1.2"),
("HA", "1.2"),
("SINGLE", "1.3"),
("STANDARD", "1.3"),
("HA", "1.3"),
("SINGLE", "1.4"),
("STANDARD", "1.4"),
("HA", "1.4"),
],
testcase_func_name=DataprocTestCase.generate_verbose_test_name)
def test_cloud_sql_proxy(self, configuration, dataproc_version):
@parameterized.parameters(
"SINGLE",
"STANDARD",
"HA",
)
def test_cloud_sql_proxy(self, configuration):
metadata = 'hive-metastore-instance={}:{}'.format(
self.PROJECT_METADATA, self.DB_NAME)
self.createCluster(configuration,
self.INIT_ACTIONS,
dataproc_version,
machine_type="n1-standard-2",
metadata=metadata,
scopes='sql-admin')
self.createCluster(
configuration,
self.INIT_ACTIONS,
machine_type="n1-standard-2",
metadata=metadata,
scopes='sql-admin')

self.verify_cluster(self.getClusterName())


if __name__ == '__main__':
unittest.main()
absltest.main()
13 changes: 5 additions & 8 deletions cloudbuild/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ RUN useradd -m -d /home/ia-tests -s /bin/bash ia-tests

COPY --chown=ia-tests:ia-tests . /init-actions

# Install Pip
RUN apt-get -y update
RUN apt-get -y install python3-pip

# Install fastunit
WORKDIR /tmp/fastunit
RUN git clone https://github.com/ityoung/python3-fastunit.git .
RUN python3 setup.py install
# Install Bazel:
# https://docs.bazel.build/versions/master/install-ubuntu.html
RUN echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list
RUN curl https://bazel.build/bazel-release.pub.gpg | apt-key add -
RUN apt-get update && apt-get install -y openjdk-8-jdk python3-setuptools bazel

USER ia-tests
31 changes: 29 additions & 2 deletions cloudbuild/cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,42 @@
steps:
# Create Docker image from regular Dockerfile
- name: 'gcr.io/cloud-builders/docker'
id: 'docker-build'
args: ['build', '--tag=gcr.io/$PROJECT_ID/init-actions-image:$BUILD_ID', '-f', 'cloudbuild/Dockerfile', '.']

# Push Docker image to GCR
- name: 'gcr.io/cloud-builders/docker'
id: 'gcr-push'
args: ['push', 'gcr.io/$PROJECT_ID/init-actions-image:$BUILD_ID']

# Run presubmit script
# Run presubmit tests in parallel for 1.2 image
- name: 'gcr.io/cloud-builders/kubectl'
id: 'dataproc-1.2-tests'
waitFor: ['gcr-push']
entrypoint: 'bash'
args: ['cloudbuild/run-presubmit-on-k8s.sh', 'gcr.io/$PROJECT_ID/init-actions-image:$BUILD_ID', '$BUILD_ID', '1.2']
env:
- 'COMMIT_SHA=$COMMIT_SHA'
- 'CLOUDSDK_COMPUTE_ZONE=us-central1-f'
- 'CLOUDSDK_CONTAINER_CLUSTER=init-actions-presubmit'

# Run presubmit tests in parallel for 1.3 image
- name: 'gcr.io/cloud-builders/kubectl'
id: 'dataproc-1.3-tests'
waitFor: ['gcr-push']
entrypoint: 'bash'
args: ['cloudbuild/run-presubmit-on-k8s.sh', 'gcr.io/$PROJECT_ID/init-actions-image:$BUILD_ID', '$BUILD_ID', '1.3']
env:
- 'COMMIT_SHA=$COMMIT_SHA'
- 'CLOUDSDK_COMPUTE_ZONE=us-central1-f'
- 'CLOUDSDK_CONTAINER_CLUSTER=init-actions-presubmit'

# Run presubmit tests in parallel for 1.4 image
- name: 'gcr.io/cloud-builders/kubectl'
id: 'dataproc-1.4-tests'
waitFor: ['gcr-push']
entrypoint: 'bash'
args: ['cloudbuild/run-presubmit-on-k8s.sh', 'gcr.io/$PROJECT_ID/init-actions-image:$BUILD_ID', '$BUILD_ID']
args: ['cloudbuild/run-presubmit-on-k8s.sh', 'gcr.io/$PROJECT_ID/init-actions-image:$BUILD_ID', '$BUILD_ID', '1.4']
env:
- 'COMMIT_SHA=$COMMIT_SHA'
- 'CLOUDSDK_COMPUTE_ZONE=us-central1-f'
Expand Down
Loading