Skip to content

Commit

Permalink
Merge pull request #31 from kumarabd/kumarabd/feature/smi-grpc
Browse files Browse the repository at this point in the history
added grpc and docker for smi-conformance
  • Loading branch information
leecalcote authored Aug 5, 2020
2 parents 6a4cb85 + c078c04 commit a245e6f
Show file tree
Hide file tree
Showing 12 changed files with 1,420 additions and 89 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,11 @@ To manually invoke SMI Conformance test for a deployed service mesh, you can app

# To check for smi conformance of a deployed service mesh
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.
Execute the following command in `./smi-conformance` to run the smi-conformace tests:-
Build and run with the below commands to create a container for running the smi-conformace tests:-

```shell
go run main.go
docker build . -t meshery-smi-conformance:latest
docker run -p 10008:10008 meshery-smi-conformance:latest
```

<!--
Expand Down
20 changes: 20 additions & 0 deletions smi-conformance/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM golang:1.14-alpine3.11 as build-img
LABEL maintainer "Layer5.io"

ENV GO111MODULE=off

RUN apk update && apk add --no-cache git libc-dev gcc pkgconf && mkdir /home/meshery
COPY ${PWD} /go/src/github.com/layer5io/learn-layer5/smi-conformance/
WORKDIR /go/src/github.com/layer5io/learn-layer5/smi-conformance/
# RUN git rev-parse HEAD > /home/meshery/version
# RUN git describe --tags `git rev-list --tags --max-count=1` >> /home/com/version

RUN go mod vendor && go build -a -ldflags "-s -w" -o /home/meshery/smi_conformance main.go

FROM alpine:latest

RUN apk --no-cache add ca-certificates
COPY --from=build-img /home/meshery/** /home/
WORKDIR /home/
EXPOSE 10008
CMD ["sh","-c","./smi_conformance"]
46 changes: 46 additions & 0 deletions smi-conformance/conformance/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package conformance

import (
context "context"

"github.com/sirupsen/logrus"
"google.golang.org/grpc"
)

// ConformanceClient represents a gRPC adapter client
type ConformanceClient struct {
CClient ConformanceTestingClient
conn *grpc.ClientConn
}

// CreateClient creates a ConformanceClient for the given params
func CreateClient(ctx context.Context, conformanceLocationURL string) (*ConformanceClient, error) {
var opts []grpc.DialOption
// creds, err := credentials.NewClientTLSFromFile(*caFile, *serverHostOverride)
// if err != nil {
// logrus.Errorf("Failed to create TLS credentials %v", err)
// }
// opts = append(opts, grpc.WithTransportCredentials(creds))
// } else {
opts = append(opts, grpc.WithInsecure())
// }
conn, err := grpc.Dial(conformanceLocationURL, opts...)
if err != nil {
logrus.Errorf("fail to dial: %v", err)
}

cClient := NewConformanceTestingClient(conn)

return &ConformanceClient{
conn: conn,
CClient: cClient,
}, nil
}

// Close closes the ConformanceClient
func (c *ConformanceClient) Close() error {
if c.conn != nil {
return c.conn.Close()
}
return nil
}
Loading

0 comments on commit a245e6f

Please sign in to comment.