Skip to content
Merged
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
4 changes: 4 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ config_setting(
},
visibility = ["//visibility:public"],
)

load("@io_bazel_rules_go//go:def.bzl", "go_prefix")

go_prefix("istio.io/proxy")
16 changes: 16 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,19 @@ http_file(
url = "https://storage.googleapis.com/istio-build/manager/ubuntu_xenial_debug-" + DEBUG_BASE_IMAGE_SHA + ".tar.gz",
sha256 = DEBUG_BASE_IMAGE_SHA,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

push these changes in to a separate .bzl file

# Following go repositories are for building go integration test for mixer filter.
git_repository(
name = "io_bazel_rules_go",
commit = "9496d79880a7d55b8e4a96f04688d70a374eaaf4", # Mar 3, 2017 (v0.4.1)
remote = "https://github.com/bazelbuild/rules_go.git",
)

git_repository(
name = "org_pubref_rules_protobuf",
commit = "d42e895387c658eda90276aea018056fcdcb30e4", # Mar 07 2017 (gogo* support)
remote = "https://github.com/pubref/rules_protobuf",
)

load("//src/envoy/mixer/integration_test:repositories.bzl", "go_mixer_repositories")
go_mixer_repositories()
16 changes: 11 additions & 5 deletions src/envoy/mixer/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
################################################################################
#


load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")
load("//src/envoy/mixer:proxy_docker.bzl", "proxy_docker_build")
load("@protobuf_git//:protobuf.bzl", "cc_proto_library")
Expand Down Expand Up @@ -48,6 +47,7 @@ cc_library(
cc_binary(
name = "envoy",
linkstatic = 1,
visibility = [":__subpackages__"],
deps = [
":filter_lib",
"@envoy_git//:envoy-main",
Expand Down Expand Up @@ -80,10 +80,6 @@ pkg_tar(
)

proxy_docker_build(
images = [
{"name": "proxy", "base": "@docker_ubuntu//:xenial"},
{"name": "proxy_debug", "base": "@ubuntu_xenial_debug//file"},
],
entrypoint = [
"/usr/local/bin/start_envoy",
"-e",
Expand All @@ -93,6 +89,16 @@ proxy_docker_build(
"-t",
"/etc/opt/proxy/envoy.conf.template",
],
images = [
{
"name": "proxy",
"base": "@docker_ubuntu//:xenial",
},
{
"name": "proxy_debug",
"base": "@ubuntu_xenial_debug//file",
},
],
ports = ["9090"],
repository = "istio",
tags = ["manual"],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You probably also want to use envoy debug build for debug image.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This PR just re-format the BUILD file. It did not change this part.
It should be done by separate PR.

Expand Down
58 changes: 58 additions & 0 deletions src/envoy/mixer/integration_test/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# 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.
#
################################################################################
#

load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = [
"attributes.go",
"envoy.go",
"http_client.go",
"http_server.go",
"mixer_server.go",
"setup.go",
],
deps = [
"@com_github_gogo_protobuf//types:go_default_library",
"@com_github_golang_glog//:go_default_library",
"@com_github_golang_protobuf//proto:go_default_library",
"@com_github_googleapis_googleapis//:google/rpc",
"@com_github_istio_api//:mixer/v1",
"@com_github_istio_mixer//pkg/api:go_default_library",
"@com_github_istio_mixer//pkg/attribute:go_default_library",
"@com_github_istio_mixer//pkg/pool:go_default_library",
"@com_github_istio_mixer//pkg/tracing:go_default_library",
"@org_golang_google_grpc//:go_default_library",
],
)

go_test(
name = "mixer_test",
size = "small",
srcs = [
"mixer_test.go",
],
data = [
"envoy.conf",
"//src/envoy/mixer:envoy",
],
library = ":go_default_library",
# shared memory path /envoy_shared_memory_0 used by Envoy
# hot start is not working in sandbox mode.
local = True,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you try with --sandbox_tmpfs_path=/dev/shm?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Tried with --sandbox_tmpfs_path=/dev/shm. Error is:

critical][assert] panic: cannot open shared memory region /envoy_shared_memory_0 check user permissions: external/envoy_git/source/exe/hot_restart.cc:32

Tried with --sandbox_tmpfs_path=/envoy_shared_memory_0, the error is

src/main/tools/linux-sandbox-pid1.cc:245: "mount(tmpfs, envoy_shared_memory_0, tmpfs, MS_NOSUID | MS_NODEV | MS_NOATIME, NULL)": No such file or directory

)
114 changes: 114 additions & 0 deletions src/envoy/mixer/integration_test/attributes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// Copyright 2017 Istio Authors
//
// 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.

package test

import (
"encoding/json"
"fmt"
"reflect"

"istio.io/mixer/pkg/attribute"
)

func verifyStringMap(actual map[string]string, expected map[string]interface{}) error {
for k, v := range expected {
vstring := v.(string)
// "-" make sure the key does not exist.
if vstring == "-" {
if _, ok := actual[k]; ok {
return fmt.Errorf("key %+v is NOT expected", k)
}
} else {
if val, ok := actual[k]; ok {
// "*" only check key exist
if val != vstring && vstring != "*" {
return fmt.Errorf("key %+v value doesn't match. Actual %+v, expected %+v",
k, val, vstring)
}
} else {
return fmt.Errorf("key %+v is expected", k)
}
}
}
return nil
}

// Please see the comment at top of mixer_test.go for verification rules
func Verify(b *attribute.MutableBag, json_results string) error {
var r map[string]interface{}
if err := json.Unmarshal([]byte(json_results), &r); err != nil {
return fmt.Errorf("unable to decode json %v", err)
}

all_keys := make(map[string]bool)
for _, k := range b.Names() {
all_keys[k] = true
}

for k, v := range r {
switch vv := v.(type) {
case string:
// "*" means only checking key.
if vv == "*" {
if _, ok := b.Get(k); !ok {
return fmt.Errorf("attribute %+v is expected", k)
}
} else {
if val, ok := b.Get(k); ok {
if val.(string) != v.(string) {
return fmt.Errorf("attribute %+v value doesn't match. Actual %+v, expected %+v",
k, val.(string), v.(string))
}
} else {
return fmt.Errorf("attribute %+v is expected", k)
}
}
case float64:
// Json converts all integers to float64,
// Our tests only verify size related attributes which are int64 type
if val, ok := b.Get(k); ok {
vint64 := int64(vv)
if val.(int64) != vint64 {
return fmt.Errorf("attribute %+v value doesn't match. Actual %+v, expected %+v",
k, val.(int64), vint64)
}
} else {
return fmt.Errorf("attribute %+v is expected", k)
}
case map[string]interface{}:
if val, ok := b.Get(k); ok {
if err := verifyStringMap(val.(map[string]string), v.(map[string]interface{})); err != nil {
return fmt.Errorf("attribute %+v StringMap doesn't match: %+v", k, err)
}
} else {
return fmt.Errorf("attribute %+v is expected", k)
}
default:
return fmt.Errorf("attribute %+v is of a type %+v that I don't know how to handle ",
k, reflect.TypeOf(v))
}
delete(all_keys, k)

}

if len(all_keys) > 0 {
var s string
for k, _ := range all_keys {
s += k + ", "
}
return fmt.Errorf("Following attributes are not expected: %s", s)
}
return nil
}
142 changes: 142 additions & 0 deletions src/envoy/mixer/integration_test/envoy.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
{
"listeners": [
{
"port": 29090,
"bind_to_port": true,
"filters": [
{
"type": "read",
"name": "http_connection_manager",
"config": {
"codec_type": "auto",
"stat_prefix": "ingress_http",
"route_config": {
"virtual_hosts": [
{
"name": "backend",
"domains": ["*"],
"routes": [
{
"timeout_ms": 0,
"prefix": "/",
"cluster": "service1",
"opaque_config": {
"mixer_control": "on",
"mixer_forward": "off"
}
}
]
}
]
},
"access_log": [
{
"path": "/dev/stdout"
}
],
"filters": [
{
"type": "decoder",
"name": "mixer",
"config": {
"mixer_server": "localhost:29091",
"mixer_attributes": {
"target.uid": "POD222",
"target.namespace": "XYZ222"
}
}
},
{
"type": "decoder",
"name": "router",
"config": {}
}
]
}
}
]
},
{
"port": 27070,
"bind_to_port": true,
"filters": [
{
"type": "read",
"name": "http_connection_manager",
"config": {
"codec_type": "auto",
"stat_prefix": "ingress_http",
"route_config": {
"virtual_hosts": [
{
"name": "backend",
"domains": ["*"],
"routes": [
{
"timeout_ms": 0,
"prefix": "/",
"cluster": "service2"
}
]
}
]
},
"access_log": [
{
"path": "/dev/stdout"
}
],
"filters": [
{
"type": "decoder",
"name": "mixer",
"config": {
"mixer_server": "localhost:29091",
"forward_attributes": {
"source.uid": "POD11",
"source.namespace": "XYZ11"
}
}
},
{
"type": "decoder",
"name": "router",
"config": {}
}
]
}
}
]
}
],
"admin": {
"access_log_path": "/dev/stdout",
"port": 29001
},
"cluster_manager": {
"clusters": [
{
"name": "service1",
"connect_timeout_ms": 5000,
"type": "strict_dns",
"lb_type": "round_robin",
"hosts": [
{
"url": "tcp://localhost:28080"
}
]
},
{
"name": "service2",
"connect_timeout_ms": 5000,
"type": "strict_dns",
"lb_type": "round_robin",
"hosts": [
{
"url": "tcp://localhost:29090"
}
]
}
]
}
}
Loading