Skip to content

Commit a245e6f

Browse files
authored
Merge pull request #31 from kumarabd/kumarabd/feature/smi-grpc
added grpc and docker for smi-conformance
2 parents 6a4cb85 + c078c04 commit a245e6f

File tree

12 files changed

+1420
-89
lines changed

12 files changed

+1420
-89
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,11 @@ To manually invoke SMI Conformance test for a deployed service mesh, you can app
121121

122122
# To check for smi conformance of a deployed service mesh
123123
Meshery, the service mesh management plane, facililtates the execution and results gathering of these conformance tests. All the tests are written in `smi-test` directory of this repository.
124-
Execute the following command in `./smi-conformance` to run the smi-conformace tests:-
124+
Build and run with the below commands to create a container for running the smi-conformace tests:-
125125

126126
```shell
127-
go run main.go
127+
docker build . -t meshery-smi-conformance:latest
128+
docker run -p 10008:10008 meshery-smi-conformance:latest
128129
```
129130

130131
<!--

smi-conformance/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM golang:1.14-alpine3.11 as build-img
2+
LABEL maintainer "Layer5.io"
3+
4+
ENV GO111MODULE=off
5+
6+
RUN apk update && apk add --no-cache git libc-dev gcc pkgconf && mkdir /home/meshery
7+
COPY ${PWD} /go/src/github.com/layer5io/learn-layer5/smi-conformance/
8+
WORKDIR /go/src/github.com/layer5io/learn-layer5/smi-conformance/
9+
# RUN git rev-parse HEAD > /home/meshery/version
10+
# RUN git describe --tags `git rev-list --tags --max-count=1` >> /home/com/version
11+
12+
RUN go mod vendor && go build -a -ldflags "-s -w" -o /home/meshery/smi_conformance main.go
13+
14+
FROM alpine:latest
15+
16+
RUN apk --no-cache add ca-certificates
17+
COPY --from=build-img /home/meshery/** /home/
18+
WORKDIR /home/
19+
EXPOSE 10008
20+
CMD ["sh","-c","./smi_conformance"]

smi-conformance/conformance/client.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package conformance
2+
3+
import (
4+
context "context"
5+
6+
"github.com/sirupsen/logrus"
7+
"google.golang.org/grpc"
8+
)
9+
10+
// ConformanceClient represents a gRPC adapter client
11+
type ConformanceClient struct {
12+
CClient ConformanceTestingClient
13+
conn *grpc.ClientConn
14+
}
15+
16+
// CreateClient creates a ConformanceClient for the given params
17+
func CreateClient(ctx context.Context, conformanceLocationURL string) (*ConformanceClient, error) {
18+
var opts []grpc.DialOption
19+
// creds, err := credentials.NewClientTLSFromFile(*caFile, *serverHostOverride)
20+
// if err != nil {
21+
// logrus.Errorf("Failed to create TLS credentials %v", err)
22+
// }
23+
// opts = append(opts, grpc.WithTransportCredentials(creds))
24+
// } else {
25+
opts = append(opts, grpc.WithInsecure())
26+
// }
27+
conn, err := grpc.Dial(conformanceLocationURL, opts...)
28+
if err != nil {
29+
logrus.Errorf("fail to dial: %v", err)
30+
}
31+
32+
cClient := NewConformanceTestingClient(conn)
33+
34+
return &ConformanceClient{
35+
conn: conn,
36+
CClient: cClient,
37+
}, nil
38+
}
39+
40+
// Close closes the ConformanceClient
41+
func (c *ConformanceClient) Close() error {
42+
if c.conn != nil {
43+
return c.conn.Close()
44+
}
45+
return nil
46+
}

0 commit comments

Comments
 (0)