8000 os.Exit for TestMain by nejisama · Pull Request #1143 · mosn/mosn · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

os.Exit for TestMain #1 8000 143

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

Merged
merged 2 commits into from
Apr 28, 2020
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
3 changes: 2 additions & 1 deletion pkg/configmanager/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package configmanager
import (
"encoding/json"
"net"
"os"
"reflect"
"testing"

Expand All @@ -41,7 +42,7 @@ func TestMain(m *testing.M) {
RegisterConfigParsedListener(ParseCallbackKeyCluster, cb.ParsedCallback)
RegisterConfigParsedListener(ParseCallbackKeyServiceRgtInfo, cb.ParsedCallback)
RegisterConfigParsedListener(ParseCallbackKeyProcessor, cb.ParsedCallback)
m.Run()
os.Exit(m.Run())
}

var mockedFilterChains = `
Expand Down
3 changes: 2 additions & 1 deletion pkg/mtls/confighook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"errors"
"io/ioutil"
"net/http"
"os"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -152,7 +153,7 @@ func (f *testConfigHooksFactory) CreateConfigHooks(config map[string]interface{}

func TestMain(m *testing.M) {
Register(testType, &testConfigHooksFactory{})
m.Run()
os.Exit(m.Run())
}

// TestTLSExtensionsVerifyClient tests server allow request with certificate's common name is client only
Expand Down
3 changes: 2 additions & 1 deletion pkg/router/routers_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package router

import (
"os"
"strings"
"testing"

Expand Down Expand Up @@ -457,5 +458,5 @@ func TestInvalidConfig(t *testing.T) {

func TestMain(m *testing.M) {
log.InitDefaultLogger("", log.DEBUG)
m.Run()
os.Exit(m.Run())
}
5 changes: 3 additions & 2 deletions pkg/upstream/cluster/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package cluster

import (
"os"
"testing"

"mosn.io/api"
Expand All @@ -28,7 +29,7 @@ import (

func TestMain(m *testing.M) {
log.DefaultLogger.SetLogLevel(log.ERROR)
m.Run()
os.Exit(m.Run())
}

func BenchmarkHostConfig(b *testing.B) {
Expand Down Expand Up @@ -262,7 +263,7 @@ func BenchmarkRoundRobinLBWithUnhealthyHost(b *testing.B) {

func BenchmarkLeastActiveRequestLB(b *testing.B) {
hostSet := &hostSet{}
hosts := makePool(10).MakeHosts(10, map[string]string{"cluster":""})
hosts := makePool(10).MakeHosts(10, map[string]string{"cluster": ""})
hostSet.setFinalHost(hosts)
lb := newleastActiveRequestLoadBalancer(nil, hostSet)
b.RunParallel(func(pb *testing.PB) {
Expand Down
9 changes: 5 additions & 4 deletions pkg/upstream/cluster/loadbalancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@ package cluster
import (
"math"
"math/rand"
"mosn.io/api"
"sync"
"testing"
"time"

"mosn.io/api"

"github.com/stretchr/testify/assert"
"mosn.io/mosn/pkg/types"
)

// load should be balanced when node fails
func TestRandomLBWhenNodeFailBalanced(t *testing.T) {
defer func () {
defer func() {
// clear healthStore
healthStore = sync.Map{}
}()
Expand Down Expand Up @@ -70,7 +71,7 @@ func TestRandomLBWhenNodeFailBalanced(t *testing.T) {
if i == unhealthyIdx {
expected = 0.000
}
if math.Abs(rate-expected) > 0.03 { // no lock, have deviation 3% is acceptable
if math.Abs(rate-expected) > 0.1 { // no lock, have deviation 10% is acceptable
t.Errorf("%s request rate is %f, expected %f", addr, rate, expected)
}
t.Logf("%s request rate is %f, request count: %d", addr, rate, results[addr])
Expand Down Expand Up @@ -120,7 +121,7 @@ func TestWRRLB(t *testing.T) {
addr := hosts[i].AddressString()
rate := float64(results[addr]) / float64(subTotal)
expected := float64(i+1) / 10.0
if math.Abs(rate-expected) > 0.03 { // no lock, have deviation 3% is acceptable
if math.Abs(rate-expected) > 0.1 { // no lock, have deviation 10% is acceptable
t.Errorf("%s request rate is %f, expected %f", addr, rate, expected)
}
t.Logf("%s request rate is %f, request count: %d", addr, rate, results[addr])
Expand Down
19 changes: 10 additions & 9 deletions pkg/xds/conv/convertxds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package conv

import (
"os"
"reflect"
"testing"
"time"
Expand Down Expand Up @@ -60,7 +61,7 @@ func TestMain(m *testing.M) {
DefaultLogLevel: "FATAL",
})
server.NewServer(sc, &mockCMF{}, cm)
m.Run()
os.Exit(m.Run())
}

// messageToAny converts from proto message to proto Any
Expand Down Expand Up @@ -333,14 +334,14 @@ func Test_convertListenerConfig(t *testing.T) {
accessLogFilterConfig,
},
}},
UseRemoteAddress: NewBoolValue(false),
XffNumTrustedHops: 0,
SkipXffAppend: false,
Via: "",
GenerateRequestId: NewBoolValue(true),
ForwardClientCertDetails: xdshttp.SANITIZE,
SetCurrentClientCertDetails: nil,
Proxy_100Continue: false,
UseRemoteAddress: NewBoolValue(false),
XffNumTrustedHops: 0,
SkipXffAppend: false,
Via: "",
GenerateRequestId: NewBoolValue(true),
ForwardClientCertDetails: xdshttp.SANITIZE,
SetCurrentClientCertDetails: nil,
Proxy_100Continue: false,
RepresentIpv4RemoteAddressAsIpv4MappedIpv6: false,
},
filterName: "envoy.http_connection_manager",
Expand Down
0