Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 10 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,13 @@ load(
)

envoy_repositories()

load(
"//test:repositories.bzl",
"perl_repositories",
"nginx_test_repositories",
)

perl_repositories()

nginx_test_repositories()
1 change: 1 addition & 0 deletions src/envoy/prototype/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ cc_binary(
"@envoy_git//:envoy-main"
],
linkstatic=1,
visibility=["//visibility:public"],
)
Empty file added test/BUILD
Empty file.
90 changes: 90 additions & 0 deletions test/nginx.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Copyright (C) Extensible Service Proxy Authors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
################################################################################
#
# Skylark macros for nginx tests.

load("@io_bazel_rules_perl//perl:perl.bzl", "perl_test")

def nginx_test(name, nginx, data=None, env=None, config=None, **kwargs):
if nginx == None or len(nginx) == 0:
fail("'nginx' parameter must be a non-empty string (target).")

if data == None:
data = []
data += [ nginx ]

if env == None:
env = {}

if config != None:
data += [ config ]
c = Label(config)
env["TEST_CONFIG"] = "server_config " + "${TEST_SRCDIR}/" + c.package + "/" + c.name + ";"
name = name + '_' + c.name.split("/")[-1].split(".")[0]

# Count existing rules in the BUILD file and assign base port using
# Each rule can use 10 ports in its range
# Rules generated from config_list get separate ranges
port = 9000 + len(native.existing_rules().values()) * 10

l = Label(nginx)
env["TEST_PORT"] = "%s" % port

env_files = {
"TEST_NGINX_BINARY": "../__main__/" + l.package + "/" + l.name
}
perl_test(name=name, data=data, env=env, env_files=env_files, **kwargs)

def nginx_suite(tests, deps, nginx, size="small", config_list=[], data=None, tags=[],
timeout="short", env=None):
for test in tests:
if not config_list:
nginx_test(
name = test.split(".")[0],
size = size,
timeout = timeout,
srcs = [test],
deps = deps,
data = data,
nginx = nginx,
config = None,
tags = tags,
env = env,
)
else:
for config in config_list:
nginx_test(
name = test.split(".")[0],
size = size,
timeout = timeout,
srcs = [test],
deps = deps,
data = data,
nginx = nginx,
config = config,
tags = tags,
env = env,
)
49 changes: 49 additions & 0 deletions test/repositories.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2016 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.
#
################################################################################
#

def perl_repositories(bind=True):
native.git_repository(
name = "io_bazel_rules_perl",
remote = "https://github.com/bazelbuild/rules_perl",
commit = "f6211c2db1e54d0a30bc3c3a718f2b5d45f02a22",
)

def nginx_test_repositories(bind=True):
BUILD = """
load("@io_bazel_rules_perl//perl:perl.bzl", "perl_library")

perl_library(
name = "nginx_test",
srcs = glob([
"lib/Test/**/*.pm",
]),
visibility = ["//visibility:public"],
)
"""

native.new_git_repository(
name = "nginx_tests_git",
remote = "https://nginx.googlesource.com/nginx-tests",
commit = "e740612281f4b64c168e99f2e6d04260d6e9ca28",
build_file_content = BUILD,
)

if bind:
native.bind(
name = "nginx_test",
actual = "@nginx_tests_git//:nginx_test",
)
Loading