Skip to content

Commit 91dab06

Browse files
authored
Merge pull request #71 from layer5io/remove-meshkit
Remove meshkit
2 parents 9b11b2a + bcff0c5 commit 91dab06

File tree

13 files changed

+265
-155
lines changed

13 files changed

+265
-155
lines changed

smi-conformance/.golangci.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
run:
2+
tests: true
3+
4+
linters:
5+
enable:
6+
- goconst
7+
- gocyclo
8+
- gofmt
9+
- goimports
10+
- golint
11+
- gosec
12+
- govet
13+
- misspell
14+
- unused
15+
- whitespace
16+
17+
linters-settings:
18+
goimports:
19+
local-prefixes: github.com/openservicemesh/osm
20+
21+
issues:
22+
exclude-rules:
23+
# Ignore error for ginkgo and gomega dot imports
24+
- linters:
25+
- golint
26+
source: ". \"github.com/onsi/(ginkgo|gomega)\""
27+
text: "dot imports"
28+
# Ignore error for test framework imports
29+
- linters:
30+
- golint
31+
source: ". \"github.com/openservicemesh/osm/tests/framework\""
32+
text: "dot imports"
33+
# ignore unused linters on keyvault as this code isn't being used
34+
# TODO: disable this rule once keyvault is integrated
35+
- path: pkg/certificate/providers/keyvault/
36+
linters:
37+
- unused
38+
- deadcode
39+
# Exclude staticcheck messages for deprecated function, variable or constant
40+
# This causes issues with package github.com/golang/protobuf/proto
41+
- linters:
42+
- staticcheck
43+
text: "SA1019:"
44+
exclude-use-default: false
45+

smi-conformance/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.PHONY: go-lint
2+
go-lint:
3+
go run github.com/golangci/golangci-lint/cmd/golangci-lint run --config .golangci.yml

smi-conformance/go.mod

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,30 @@ module github.com/layer5io/learn-layer5/smi-conformance
22

33
go 1.13
44

5-
replace github.com/kudobuilder/kuttl => github.com/layer5io/kuttl v0.4.1-0.20200806180306-b7e46afd657f
6-
75
require (
6+
cloud.google.com/go v0.46.3 // indirect
87
github.com/golang/protobuf v1.4.2
9-
github.com/google/go-cmp v0.5.1 // indirect
8+
github.com/google/go-cmp v0.5.2 // indirect
109
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4
10+
github.com/kr/text v0.2.0 // indirect
1111
github.com/kudobuilder/kuttl v0.0.0-00010101000000-000000000000
12-
github.com/kumarabd/gokit v0.2.0
13-
github.com/sirupsen/logrus v1.6.0
12+
github.com/mattn/go-isatty v0.0.12 // indirect
13+
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
14+
github.com/onsi/ginkgo v1.14.1 // indirect
15+
github.com/onsi/gomega v1.10.2 // indirect
16+
github.com/pkg/errors v0.9.1 // indirect
17+
github.com/sirupsen/logrus v1.7.0
1418
github.com/stretchr/testify v1.6.1 // indirect
15-
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1 // indirect
16-
google.golang.org/genproto v0.0.0-20191009194640-548a555dbc03 // indirect
19+
golang.org/x/net v0.0.0-20200822124328-c89045814202 // indirect
20+
golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e634 // indirect
21+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
22+
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a // indirect
1723
google.golang.org/grpc v1.30.0
1824
google.golang.org/protobuf v1.23.0
25+
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
1926
k8s.io/api v0.17.3
2027
k8s.io/client-go v0.17.3
2128
sigs.k8s.io/controller-runtime v0.5.1
2229
)
30+
31+
replace github.com/kudobuilder/kuttl => github.com/layer5io/kuttl v0.4.1-0.20200806180306-b7e46afd657f

smi-conformance/go.sum

Lines changed: 105 additions & 72 deletions
Large diffs are not rendered by default.

smi-conformance/grpc/grpc.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
package grpc
22

33
import (
4-
"errors"
54
"fmt"
65
"net"
76
"time"
87

98
middleware "github.com/grpc-ecosystem/go-grpc-middleware"
109
grpc_recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery"
11-
1210
"google.golang.org/grpc"
1311

1412
"github.com/layer5io/learn-layer5/smi-conformance/conformance"
@@ -19,18 +17,17 @@ type Service struct {
1917
Name string `json:"name"`
2018
Port string `json:"port"`
2119
Version string `json:"version"`
22-
StartedAt time.Time `json:"startedat,string"`
20+
StartedAt time.Time `json:"startedat"`
2321
}
2422

2523
// panicHandler is the handler function to handle panic errors
2624
func panicHandler(r interface{}) error {
2725
fmt.Println("500 panic Error")
28-
return errors.New(fmt.Sprintf("Panic error for: %+v", r))
26+
return fmt.Errorf("Panic error for: %+v", r)
2927
}
3028

31-
// StartServer starts grpc server
29+
// Start grpc server
3230
func Start(s *Service) error {
33-
3431
address := fmt.Sprintf(":%s", s.Port)
3532
listener, err := net.Listen("tcp", address)
3633
if err != nil {
@@ -55,5 +52,4 @@ func Start(s *Service) error {
5552
return err
5653
}
5754
return nil
58-
5955
}

smi-conformance/grpc/handlers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ var (
3232
}
3333
)
3434

35+
// RunTest return conformance response
3536
func (s *Service) RunTest(ctx context.Context, req *conformance.Request) (*conformance.Response, error) {
3637
var config test_gen.ServiceMesh
3738

@@ -68,7 +69,7 @@ func (s *Service) RunTest(ctx context.Context, req *conformance.Request) (*confo
6869
d.Result = res.Failure.Message
6970
d.Status = "Failing"
7071
d.Capability = "None"
71-
failures += 1
72+
failures++
7273
if (res.Assertions - failures) > (res.Assertions / 2) {
7374
d.Capability = "Half"
7475
}

smi-conformance/main.go

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,26 @@
11
package main
22

33
import (
4-
"fmt"
4+
"github.com/layer5io/learn-layer5/smi-conformance/grpc"
55
"os"
6+
"sigs.k8s.io/controller-runtime/pkg/log"
67
"time"
7-
8-
"github.com/layer5io/gokit/logger"
9-
"github.com/layer5io/learn-layer5/smi-conformance/grpc"
108
)
119

1210
func main() {
13-
1411
service := &grpc.Service{
1512
Name: "smi-conformance",
1613
Port: "10011",
1714
Version: "v1.0.0",
1815
StartedAt: time.Now(),
1916
}
20-
2117
// Initialize Logger instance
22-
log, err := logger.New(service.Name)
23-
if err != nil {
24-
fmt.Println("Logger Init Failed", err.Error())
25-
os.Exit(1)
26-
}
27-
18+
logger := log.Log.WithName(service.Name)
19+
logger.Info("Conformance tool Started")
2820
// Server Initialization
29-
log.Info("Conformance tool Started")
30-
err = grpc.Start(service)
21+
err := grpc.Start(service)
3122
if err != nil {
32-
log.Err("Conformance tool crashed!!", err.Error())
23+
logger.Error(err, "Conformance tool crashed!!")
3324
os.Exit(1)
3425
}
3526
}

smi-conformance/test-gen/service-mesh.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ type Maesh struct {
2626
}
2727

2828
func (sm Maesh) SvcAGetInternalName(namespace string) string {
29-
return fmt.Sprintf("http://%s.%s.maesh:%s", SERVICE_A_NAME, namespace, sm.PortSvcA)
29+
return fmt.Sprintf("http://%s.%s.maesh:%s", SvcNameA, namespace, sm.PortSvcA)
3030
}
3131

3232
func (sm Maesh) SvcBGetInternalName(namespace string) string {
33-
return fmt.Sprintf("http://%s.%s.maesh:%s", SERVICE_B_NAME, namespace, sm.PortSvcB)
33+
return fmt.Sprintf("http://%s.%s.maesh:%s", SvcNameB, namespace, sm.PortSvcB)
3434
}
3535

3636
func (sm Maesh) SvcCGetInternalName(namespace string) string {
37-
return fmt.Sprintf("http://%s.%s.maesh:%s", SERVICE_C_NAME, namespace, sm.PortSvcC)
37+
return fmt.Sprintf("http://%s.%s.maesh:%s", SvcNameC, namespace, sm.PortSvcC)
3838
}
3939

4040
func (sm Maesh) SvcAGetPort() string {
@@ -56,15 +56,15 @@ type Linkerd struct {
5656
}
5757

5858
func (sm Linkerd) SvcAGetInternalName(namespace string) string {
59-
return fmt.Sprintf("http://%s.%s..svc.cluster.local.:%s", SERVICE_A_NAME, namespace, sm.PortSvcA)
59+
return fmt.Sprintf("http://%s.%s..svc.cluster.local.:%s", SvcNameA, namespace, sm.PortSvcA)
6060
}
6161

6262
func (sm Linkerd) SvcBGetInternalName(namespace string) string {
63-
return fmt.Sprintf("http://%s.%s..svc.cluster.local.:%s", SERVICE_B_NAME, namespace, sm.PortSvcB)
63+
return fmt.Sprintf("http://%s.%s..svc.cluster.local.:%s", SvcNameB, namespace, sm.PortSvcB)
6464
}
6565

6666
func (sm Linkerd) SvcCGetInternalName(namespace string) string {
67-
return fmt.Sprintf("http://%s.%s..svc.cluster.local.:%s", SERVICE_C_NAME, namespace, sm.PortSvcC)
67+
return fmt.Sprintf("http://%s.%s..svc.cluster.local.:%s", SvcNameC, namespace, sm.PortSvcC)
6868
}
6969

7070
func (sm Linkerd) SvcAGetPort() string {
@@ -86,15 +86,15 @@ type Istio struct {
8686
}
8787

8888
func (sm Istio) SvcAGetInternalName(namespace string) string {
89-
return fmt.Sprintf("http://%s.%s..svc.cluster.local.:%s", SERVICE_A_NAME, namespace, sm.PortSvcA)
89+
return fmt.Sprintf("http://%s.%s..svc.cluster.local.:%s", SvcNameA, namespace, sm.PortSvcA)
9090
}
9191

9292
func (sm Istio) SvcBGetInternalName(namespace string) string {
93-
return fmt.Sprintf("http://%s.%s..svc.cluster.local.:%s", SERVICE_B_NAME, namespace, sm.PortSvcB)
93+
return fmt.Sprintf("http://%s.%s..svc.cluster.local.:%s", SvcNameB, namespace, sm.PortSvcB)
9494
}
9595

9696
func (sm Istio) SvcCGetInternalName(namespace string) string {
97-
return fmt.Sprintf("http://%s.%s..svc.cluster.local.:%s", SERVICE_C_NAME, namespace, sm.PortSvcC)
97+
return fmt.Sprintf("http://%s.%s..svc.cluster.local.:%s", SvcNameC, namespace, sm.PortSvcC)
9898
}
9999

100100
func (sm Istio) SvcAGetPort() string {
@@ -116,15 +116,15 @@ type OSM struct {
116116
}
117117

118118
func (sm OSM) SvcAGetInternalName(namespace string) string {
119-
return fmt.Sprintf("http://%s.%s..svc.cluster.local.:%s", SERVICE_A_NAME, namespace, sm.PortSvcA)
119+
return fmt.Sprintf("http://%s.%s..svc.cluster.local.:%s", SvcNameA, namespace, sm.PortSvcA)
120120
}
121121

122122
func (sm OSM) SvcBGetInternalName(namespace string) string {
123-
return fmt.Sprintf("http://%s.%s..svc.cluster.local.:%s", SERVICE_B_NAME, namespace, sm.PortSvcB)
123+
return fmt.Sprintf("http://%s.%s..svc.cluster.local.:%s", SvcNameB, namespace, sm.PortSvcB)
124124
}
125125

126126
func (sm OSM) SvcCGetInternalName(namespace string) string {
127-
return fmt.Sprintf("http://%s.%s..svc.cluster.local.:%s", SERVICE_C_NAME, namespace, sm.PortSvcC)
127+
return fmt.Sprintf("http://%s.%s..svc.cluster.local.:%s", SvcNameC, namespace, sm.PortSvcC)
128128
}
129129

130130
func (sm OSM) SvcAGetPort() string {

smi-conformance/test-gen/test_gen.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,5 @@ func RunTest(meshConfig ServiceMesh, annotations, labels map[string]string) Resu
104104
time.Sleep(30 * time.Second)
105105
})
106106
}()
107-
select {
108-
case x := <-c:
109-
return x
110-
}
107+
return <-c
111108
}

smi-conformance/test-gen/traffic-access.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,17 @@ func (smi *SMIConformance) trafficBlocked(
3838
return []error{err}
3939
}
4040
clusterIPs, err := GetClusterIPs(kubeClient, namespace)
41-
41+
if err != nil {
42+
t.Fail()
43+
return []error{err}
44+
}
4245
ClearAllMetrics(clusterIPs, smi.SMObj)
4346

4447
// This test will make SERVICE A make a request to SERVICE B
4548
svcBTestURL := fmt.Sprintf("%s/%s", smi.SMObj.SvcBGetInternalName(namespace), ECHO)
4649
var jsonStr = []byte(`{"url":"` + svcBTestURL + `", "body":"", "method": "GET", "headers": {}}`)
4750

48-
url := fmt.Sprintf("http://%s:%s/%s", clusterIPs[SERVICE_A_NAME], smi.SMObj.SvcAGetPort(), CALL)
51+
url := fmt.Sprintf("http://%s:%s/%s", clusterIPs[SvcNameA], smi.SMObj.SvcAGetPort(), CALL)
4952
_, err = httpClient.Post(url, "application/json", bytes.NewBuffer(jsonStr))
5053

5154
Logger.Logf("URL : \n", url)
@@ -56,7 +59,7 @@ func (smi *SMIConformance) trafficBlocked(
5659
return []error{err}
5760
}
5861

59-
metricsSvcA, err := GetMetrics(clusterIPs[SERVICE_A_NAME], "9091")
62+
metricsSvcA, err := GetMetrics(clusterIPs[SvcNameA], "9091")
6063
if err != nil {
6164
t.Fail()
6265
Logger.Logf("Error : %s", err.Error())
@@ -100,14 +103,18 @@ func (smi *SMIConformance) trafficAllow(
100103
return []error{err}
101104
}
102105
clusterIPs, err := GetClusterIPs(kubeClient, namespace)
103-
106+
if err!=nil{
107+
t.Fail()
108+
Logger.Logf("Error : %s", err.Error())
109+
return []error{err}
110+
}
104111
ClearAllMetrics(clusterIPs, smi.SMObj)
105112

106113
// This test will make SERVICE A make a request to SERVICE B
107114
svcBTestURL := fmt.Sprintf("%s/%s", smi.SMObj.SvcBGetInternalName(namespace), ECHO)
108115
var jsonStr = []byte(`{"url":"` + svcBTestURL + `", "body":"", "method": "GET", "headers": {}}`)
109116

110-
url := fmt.Sprintf("http://%s:%s/%s", clusterIPs[SERVICE_A_NAME], smi.SMObj.SvcAGetPort(), CALL)
117+
url := fmt.Sprintf("http://%s:%s/%s", clusterIPs[SvcNameA], smi.SMObj.SvcAGetPort(), CALL)
111118
_, err = httpClient.Post(url, "application/json", bytes.NewBuffer(jsonStr))
112119

113120
Logger.Logf("URL : \n", url)
@@ -118,7 +125,7 @@ func (smi *SMIConformance) trafficAllow(
118125
return []error{err}
119126
}
120127

121-
metricsSvcA, err := GetMetrics(clusterIPs[SERVICE_A_NAME], "9091")
128+
metricsSvcA, err := GetMetrics(clusterIPs[SvcNameA], "9091")
122129

123130
if err != nil {
124131
t.Fail()
@@ -143,7 +150,7 @@ func (smi *SMIConformance) trafficAllow(
143150
}
144151
Logger.Log("Validated: Response destination")
145152

146-
metricsSvcB, err := GetMetrics(clusterIPs[SERVICE_B_NAME], "9091")
153+
metricsSvcB, err := GetMetrics(clusterIPs[SvcNameB], "9091")
147154
if err != nil {
148155
t.Fail()
149156
Logger.Log("Error: ", err)

0 commit comments

Comments
 (0)