Skip to content

Commit

Permalink
fix some unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
JamazRuan committed Jun 14, 2019
1 parent f1e42a3 commit 5c99f88
Show file tree
Hide file tree
Showing 22 changed files with 439 additions and 143 deletions.
3 changes: 1 addition & 2 deletions bin/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function set_download_command () {
# Try curl.
if command -v curl > /dev/null; then
if curl --version | grep Protocols | grep https > /dev/null; then
DOWNLOAD_COMMAND='curl -fLSsO'
DOWNLOAD_COMMAND='curl -fLSs'
return
fi
echo curl does not support https, will try wget for downloading files.
Expand All @@ -93,7 +93,6 @@ if [ -z "${PROXY_REPO_SHA:-}" ] ; then
fi

# Normally set by the Makefile.
ISTIO_ENVOY_MAC_RELEASE_URL=${ISTIO_ENVOY_MAC_RELEASE_URL:-https://github.com/istio/proxy/releases/download/1.0.2/istio-proxy-1.0.2-macos.tar.gz}
# ISTIO_MOSN_VERSION=${ISTIO_MOSN_VERSION:-${PROXY_REPO_SHA}}
ISTIO_MOSN_DEBUG_URL=${ISTIO_MOSN_DEBUG_URL:-https://github.com/alipay/sofa-mosn/releases/download/${ISTIO_MOSN_VERSION}/mosn}
ISTIO_MOSN_RELEASE_URL=${ISTIO_MOSN_RELEASE_URL:-https://github.com/alipay/sofa-mosn/releases/download/${ISTIO_MOSN_VERSION}/mosn}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ spec:
{{- end }}
- name: PILOT_DISABLE_XDS_MARSHALING_TO_ANY
value: "1"
- name: PILOT_ENABLE_FALLTHROUGH_ROUTE
value: "0"
resources:
{{- if .Values.resources }}
{{ toYaml .Values.resources | indent 12 }}
Expand Down
4 changes: 0 additions & 4 deletions install/kubernetes/helm/istio/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,10 @@ data:
{{- end }}
{{- end }}

{{- if $.Values.global.useMCP }}
configSources:
- address: istio-galley.{{ $.Release.Namespace }}.svc:9901
{{- if $.Values.global.controlPlaneSecurityEnabled}}
tlsSettings:
mode: ISTIO_MUTUAL
{{- end }}
{{- end }}

defaultConfig:
#
Expand Down
2 changes: 1 addition & 1 deletion istio.deps
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
},
{
"name": "MOSN_VERSION",
"version": "0.3.0"
"version": "0.5.0"
}
]
37 changes: 11 additions & 26 deletions mixer/test/client/env/envoy.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ package env

import (
"fmt"
"istio.io/istio/pilot/pkg/proxy/envoy"
"log"
"os"
"os/exec"
"path/filepath"
"strconv"
"time"

"istio.io/istio/pkg/test/env"
Expand All @@ -33,11 +33,11 @@ type Envoy struct {
baseID string
}

// NewEnvoy creates a new Envoy struct and starts envoy.
func (s *TestSetup) NewEnvoy() (*Envoy, error) {
// NewMosn creates a new Envoy struct and starts mson.
func (s *TestSetup) NewMosn() (*Envoy, error) {
confPath := filepath.Join(env.IstioOut, fmt.Sprintf("config.conf.%v.yaml", s.ports.AdminPort))
log.Printf("Envoy config: in %v\n", confPath)
if err := s.CreateEnvoyConf(confPath); err != nil {
if err := s.CreateEnvoyConf(confPath, jsonFormat); err != nil {
return nil, err
}

Expand All @@ -47,30 +47,15 @@ func (s *TestSetup) NewEnvoy() (*Envoy, error) {
}

baseID := ""
args := []string{"-c", confPath,
"--drain-time-s", "1",
"--allow-unknown-fields"}
if s.stress {
args = append(args, "--concurrency", "10")
} else {
// debug is far too verbose.
args = append(args, "-l", debugLevel, "--concurrency", "1")
}
if s.disableHotRestart {
args = append(args, "--disable-hot-restart")
} else {
baseID = strconv.Itoa(int(s.testName))
args = append(args,
// base id is shared between restarted envoys
"--base-id", baseID,
"--parent-shutdown-time-s", "1",
"--restart-epoch", strconv.Itoa(s.epoch))
}
// use the mosn's args
args := []string{ envoy.CmdStart,
envoy.ArgConfig, confPath}

if s.EnvoyParams != nil {
args = append(args, s.EnvoyParams...)
}
/* #nosec */
envoyPath := filepath.Join(env.IstioBin, "envoy")
envoyPath := filepath.Join(env.IstioBin, "mosn")
if path, exists := os.LookupEnv("ENVOY_PATH"); exists {
envoyPath = path
}
Expand All @@ -93,8 +78,8 @@ func (s *Envoy) Start() error {
if err != nil {
return err
}

url := fmt.Sprintf("http://localhost:%v/server_info", s.ports.AdminPort)
// use mosn xxx/listeners to check process
url := fmt.Sprintf("http://localhost:%v/listeners", s.ports.AdminPort)
return WaitForHTTPServer(url)
}

Expand Down
10 changes: 8 additions & 2 deletions mixer/test/client/env/envoy_conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import (
"github.com/gogo/protobuf/proto"
)

const envoyConfTemplYAML = `
const (
jsonFormat = "json"
envoyConfTemplYAML = `
admin:
access_log_path: {{.AccessLogPath}}
address:
Expand Down Expand Up @@ -139,14 +141,18 @@ static_resources:
stat_prefix: inbound_tcp
cluster: backend
`
)

// CreateEnvoyConf create envoy config.
func (s *TestSetup) CreateEnvoyConf(path string) error {
func (s *TestSetup) CreateEnvoyConf(path string, format string) error {
if s.stress {
s.AccessLogPath = "/dev/null"
}

confTmpl := envoyConfTemplYAML
if format == jsonFormat {
confTmpl = mosnConfigTempJson
}
if s.EnvoyTemplate != "" {
confTmpl = s.EnvoyTemplate
}
Expand Down
241 changes: 241 additions & 0 deletions mixer/test/client/env/mosn_config_temp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
package env

const (
mosnConfigTempJson = `
{
"node":{},
"stats_config":{},
"dynamic_resources":{},
"tracing": {},
"admin": {
"access_log_path": "{{.AccessLogPath}}",
"address": {
"socket_address": {
"address": "127.0.0.1",
"port_value": "{{.Ports.AdminPort}}"
}
}
},
"dynamic_resources": {
"lds_config": {
"ads": {}
},
"cds_config": {
"ads": {}
},
"ads_config": {
"api_type": "GRPC",
"grpc_services": [
{
"envoy_grpc": {
"cluster_name": "loop"
}
}
]
}
},
"static_resources": {
"clusters": [
{
"name": "backend",
"connect_timeout": "5s",
"type": "STATIC",
"hosts": [
{
"socket_address": {
"address": "127.0.0.1",
"port_value": "{{.Ports.BackendPort}}"
}
}
]
},
{
"name": "loop",
"connect_timeout": "5s",
"type": "STATIC",
"hosts": [
{
"socket_address": {
"address": "127.0.0.1",
"port_value": "{{.Ports.ServerProxyPort}}"
}
}
]
},
{
"name": "mixer_server",
"http2_protocol_options": {},
"connect_timeout": "5s",
"type": "STATIC",
"hosts": [
{
"socket_address": {
"address": "127.0.0.1",
"port_value": "{{.Ports.MixerPort}}"
}
}
],
"circuit_breakers": {
"thresholds": [
{
"max_connections": 10000,
"max_pending_requests": 10000,
"max_requests": 10000,
"max_retries": 3
}
]
}
}
],
"listeners": [
{
"name": "server",
"address": {
"socket_address": {
"address": "127.0.0.1",
"port_value": "{{.Ports.ServerProxyPort}}"
}
},
"filter_chains": [
{
"filters": [
{
"name": "envoy.http_connection_manager",
"config": {
"codec_type": "AUTO",
"stat_prefix": "inbound_http",
"access_log": [
{
"name": "envoy.file_access_log",
"config": {
"path": "{{.AccessLogPath}}"
}
}
],
"http_filters": [
{
"name": "mixer",
"config": {{.MfConfig.HTTPServerConf | toJSON }}
},
{
"name": "envoy.router"
}
],
"route_config": {
"name": "backend",
"virtual_hosts": [
{
"name": "backend",
"domains": ["*"],
"routes": [
{
"match": {
"prefix": "/"
},
"route": {
"cluster": "backend",
"timeout": "0s"
},
"per_filter_config": {
"mixer": {{.MfConfig.PerRouteConf | toJSON }}
}
}
]
}
]
}
}
}
]
}
]
}, {
"name": "client",
"address": {
"socket_address": {
"address": "127.0.0.1",
"port_value": "{{.Ports.ClientProxyPort}}"
}
},
"filter_chains": [
{
"filters": [
{
"name": "envoy.http_connection_manager",
"config": {
"codec_type": "AUTO",
"stat_prefix": "outbound_http",
"access_log": [
{
"name": "envoy.file_access_log",
"config": {
"path": "{{.AccessLogPath}}"
}
}
],
"http_filters": [
{
"name": "mixer",
"config": {{.MfConfig.HTTPClientConf | toJSON }}
},
{
"name": "envoy.router"
}
],
"route_config": {
"name": "loop",
"virtual_hosts": [
{
"name": "loop",
"domains": ["*"],
"routes": [
{
"match": {
"prefix": "/"
},
"route": {
"cluster": "loop",
"timeout": "0s"
}
}
]
}
]
}
}
}
]
}
]
}, {
"name": "tcp_server",
"address": {
"socket_address": {
"address": "127.0.0.1",
"port_value": "{{.Ports.TCPProxyPort}}"
}
},
"filter_chains": [
{
"filters": [
{
"name": "mixer",
"config": {{.MfConfig.TCPServerConf | toJSON }}
}, {
"name": "envoy.tcp_proxy",
"config": {
"stat_prefix": "inbound_tcp",
"cluster": "backend"
}
}
]
}
]
}
]
}
}
`
)
Loading

0 comments on commit 5c99f88

Please sign in to comment.