-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add mixer client end to end integration test. #177
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
Changes from all commits
1b4d2b1
8d3867f
dc1ff17
c9fbf6f
3b89772
e275f40
a1864c4
9507225
bc5ea6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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") | ||
|
|
@@ -48,6 +47,7 @@ cc_library( | |
| cc_binary( | ||
| name = "envoy", | ||
| linkstatic = 1, | ||
| visibility = [":__subpackages__"], | ||
| deps = [ | ||
| ":filter_lib", | ||
| "@envoy_git//:envoy-main", | ||
|
|
@@ -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", | ||
|
|
@@ -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"], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You probably also want to use envoy debug build for debug image.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
|
||
| 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, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you try with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| ) | ||
| 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 | ||
| } |
| 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" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| } |
There was a problem hiding this comment.
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