Skip to content

Commit

Permalink
Merge pull request #34 from kumarabd/kumarabd/feature/smi-grpc-fix
Browse files Browse the repository at this point in the history
fixed docker and result
  • Loading branch information
leecalcote authored Aug 6, 2020
2 parents 66e79a0 + 539df95 commit 4ac3201
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 57 deletions.
4 changes: 2 additions & 2 deletions smi-conformance/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ FROM alpine:latest
RUN apk --no-cache add ca-certificates && mkdir /home/test-yamls && mkdir /home/test-yamls/traffic-access && mkdir /home/test-yamls/traffic-spec && mkdir /home/test-yamls/traffic-split
COPY --from=build-img /home/meshery/** /home/
COPY --from=build-img /go/src/github.com/layer5io/learn-layer5/smi-conformance/test-gen/test-yamls/traffic-access/** /home/test-yamls/traffic-access/
COPY --from=build-img /go/src/github.com/layer5io/learn-layer5/smi-conformance/test-gen/test-yamls/test-split/** /home/test-yamls/traffic-split/
COPY --from=build-img /go/src/github.com/layer5io/learn-layer5/smi-conformance/test-gen/test-yamls/test-spec/** /home/test-yamls/traffic-spec/
COPY --from=build-img /go/src/github.com/layer5io/learn-layer5/smi-conformance/test-gen/test-yamls/traffic-split/** /home/test-yamls/traffic-split/
COPY --from=build-img /go/src/github.com/layer5io/learn-layer5/smi-conformance/test-gen/test-yamls/traffic-spec/** /home/test-yamls/traffic-spec/
WORKDIR /home/
EXPOSE 10008
CMD ["sh","-c","./smi_conformance"]
119 changes: 64 additions & 55 deletions smi-conformance/test-gen/test_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"testing"
"time"

harness "github.com/kudobuilder/kuttl/pkg/apis/testharness/v1beta1"
"github.com/kudobuilder/kuttl/pkg/report"
Expand All @@ -29,70 +30,78 @@ type Results struct {
}

func RunTest(meshConfig ServiceMesh, annotations map[string]string) Results {
manifestDirs := []string{}
output := Results{}
results := &report.Testsuites{}

// Run all testCases
testToRun := ""
// Run only traffic-split
// testToRun := "traffic-split"
c := make(chan Results)
go func() {
manifestDirs := []string{}
results := &report.Testsuites{}
output := Results{}

startKIND := false
options := harness.TestSuite{}
// Run all testCases
testToRun := ""
// Run only traffic-split
// testToRun := "traffic-split"

args := []string{"./test-yamls/"}
startKIND := false
options := harness.TestSuite{}

options.TestDirs = args
options.Timeout = 30
options.Parallel = 1
options.TestDirs = manifestDirs
options.StartKIND = startKIND
options.SkipDelete = true
args := []string{"./test-yamls/"}

if options.KINDContext == "" {
options.KINDContext = harness.DefaultKINDContext
}

if len(args) != 0 {
options.TestDirs = args
}

// annotations := make(map[string]string)
// Namespace Injection
// annotations["linkerd.io/inject"] = "enabled"

serviceMeshConfObj := SMIConformance{
SMObj: meshConfig,
}
options.Timeout = 30
options.Parallel = 1
options.TestDirs = manifestDirs
options.StartKIND = startKIND
options.SkipDelete = true

if options.KINDContext == "" {
options.KINDContext = harness.DefaultKINDContext
}

testHandlers := make(map[string]map[string]test.CustomTest)
testHandlers["traffic-access"] = serviceMeshConfObj.TrafficAccessGetTests()
testHandlers["traffic-spec"] = serviceMeshConfObj.TrafficSpecGetTests()
testHandlers["traffic-split"] = serviceMeshConfObj.TrafficSplitGetTests()

testutils.RunTests("kudo", testToRun, options.Parallel, func(t *testing.T) {
harness := test.Harness{
TestSuite: options,
T: t,
SuiteCustomTests: testHandlers,
NamespaceAnnotations: annotations,
if len(args) != 0 {
options.TestDirs = args
}

// Runs the test using the inCluster kubeConfig (runs only when the code is running inside the pod)
harness.InCluster = true

s, _ := json.MarshalIndent(options, "", " ")
fmt.Printf("Running integration tests with following options:\n%s\n", string(s))
results = harness.Run()
data, _ := json.Marshal(results)
// Results of the test
fmt.Printf("Results :\n%v\n", string(data))
err := json.Unmarshal([]byte(data), &output)
if err != nil {
fmt.Printf("Unable to unmarshal results")
// annotations := make(map[string]string)
// Namespace Injection
// annotations["linkerd.io/inject"] = "enabled"

serviceMeshConfObj := SMIConformance{
SMObj: meshConfig,
}
})

return output
testHandlers := make(map[string]map[string]test.CustomTest)
testHandlers["traffic-access"] = serviceMeshConfObj.TrafficAccessGetTests()
testHandlers["traffic-spec"] = serviceMeshConfObj.TrafficSpecGetTests()
testHandlers["traffic-split"] = serviceMeshConfObj.TrafficSplitGetTests()

testutils.RunTests("kudo", testToRun, options.Parallel, func(t *testing.T) {
harness := test.Harness{
TestSuite: options,
T: t,
SuiteCustomTests: testHandlers,
NamespaceAnnotations: annotations,
}

// Runs the test using the inCluster kubeConfig (runs only when the code is running inside the pod)
harness.InCluster = true

s, _ := json.MarshalIndent(options, "", " ")
fmt.Printf("Running integration tests with following options:\n%s\n", string(s))
results = harness.Run()
data, _ := json.Marshal(results)
// Results of the test
fmt.Printf("Results :\n%v\n", string(data))
err := json.Unmarshal([]byte(data), &output)
if err != nil {
fmt.Printf("Unable to unmarshal results")
}
c <- output
time.Sleep(5 * time.Second)
})
}()
select {
case x := <-c:
return x
}
}

0 comments on commit 4ac3201

Please sign in to comment.