Skip to content

Commit

Permalink
Merge c73e391 into 8e90c04
Browse files Browse the repository at this point in the history
  • Loading branch information
ray-milkey committed Sep 16, 2020
2 parents 8e90c04 + c73e391 commit ef4cb6d
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 279 deletions.
89 changes: 7 additions & 82 deletions benchmark/gnmi/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@ package gnmi

import (
"context"
"crypto/tls"
"github.com/onosproject/helmit/pkg/benchmark"
"github.com/onosproject/helmit/pkg/helm"
"github.com/onosproject/helmit/pkg/input"
"github.com/onosproject/helmit/pkg/kubernetes"
"github.com/onosproject/helmit/pkg/util/random"
"github.com/onosproject/onos-lib-go/pkg/certs"
"github.com/onosproject/onos-test/pkg/onostest"
gclient "github.com/openconfig/gnmi/client"
"github.com/onosproject/onos-config/test/utils/charts"
"github.com/onosproject/onos-config/test/utils/gnmi"
"github.com/openconfig/gnmi/client/gnmi"
"time"
)
Expand All @@ -37,52 +34,12 @@ type BenchmarkSuite struct {
value input.Source
}

const onosComponentName = "onos-config"
const testName = "gnmi-benchmark"

// SetupSuite :: benchmark
func (s *BenchmarkSuite) SetupSuite(c *benchmark.Context) error {
// Setup the Atomix controller
err := helm.Chart(onostest.ControllerChartName, onostest.AtomixChartRepo).
Release(onostest.AtomixName(testName, onosComponentName)).
Set("scope", "Namespace").
Install(true)
if err != nil {
return err
}

err = helm.Chart(onostest.RaftStorageControllerChartName, onostest.AtomixChartRepo).
Release(onostest.RaftReleaseName(onosComponentName)).
Set("scope", "Namespace").
Install(true)
if err != nil {
return err
}

// Install the onos-topo chart
err = helm.
Chart("onos-topo", onostest.AtomixChartRepo).
Release("onos-topo").
Set("replicaCount", 2).
Set("storage.controller", onostest.AtomixController(testName, onosComponentName)).
Set("image.tag", "latest").
Install(false)
if err != nil {
return err
}

// Install the onos-config chart
err = helm.
Chart("onos-config", onostest.OnosChartRepo).
Release("onos-config").
Set("replicaCount", 2).
Set("storage.controller", onostest.AtomixController(testName, onosComponentName)).
Set("image.tag", "latest").
Install(true)
if err != nil {
return err
}
return nil
umbrella := charts.CreateUmbrellaRelease().
Set("onos-topo.replicaCount", 2).
Set("onos-config.replicaCount", 2)
return umbrella.Install(true)
}

// SetupWorker :: benchmark
Expand Down Expand Up @@ -110,31 +67,11 @@ func (s *BenchmarkSuite) TearDownWorker(c *benchmark.Context) error {

var _ benchmark.SetupWorker = &BenchmarkSuite{}

func getDestination() (gclient.Destination, error) {
creds, err := getClientCredentials()
if err != nil {
return gclient.Destination{}, err
}
onosConfig := helm.Release("onos-config")
onosConfigClient := kubernetes.NewForReleaseOrDie(onosConfig)
services, err := onosConfigClient.CoreV1().Services().List()
if err != nil {
return gclient.Destination{}, err
}
service := services[0]
return gclient.Destination{
Addrs: []string{service.Ports()[0].Address(true)},
Target: service.Name,
TLS: creds,
Timeout: 10 * time.Second,
}, nil
}

// getGNMIClient makes a GNMI client to use for requests
func getGNMIClient() (*client.Client, error) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
dest, err := getDestination()
dest, err := gnmi.GetDestination()
if err != nil {
return nil, err
}
Expand All @@ -144,15 +81,3 @@ func getGNMIClient() (*client.Client, error) {
}
return gnmiClient.(*client.Client), nil
}

// getClientCredentials returns the credentials for a service client
func getClientCredentials() (*tls.Config, error) {
cert, err := tls.X509KeyPair([]byte(certs.DefaultClientCrt), []byte(certs.DefaultClientKey))
if err != nil {
return nil, err
}
return &tls.Config{
Certificates: []tls.Certificate{cert},
InsecureSkipVerify: true,
}, nil
}
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ module github.com/onosproject/onos-config
go 1.14

require (
cloud.google.com/go v0.43.0 // indirect
github.com/Pallinder/go-randomdata v1.2.0
github.com/atomix/go-client v0.2.3
cloud.google.com/go v0.43.0 // indirect
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/docker/docker v1.13.1
github.com/gogo/protobuf v1.3.1
github.com/golang/mock v1.3.1
github.com/golang/protobuf v1.3.3
github.com/google/pprof v0.0.0-20190723021845-34ac40c74b70 // indirect
github.com/google/uuid v1.1.1
github.com/googleapis/gnostic v0.3.0 // indirect
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/kr/pty v1.1.8 // indirect
github.com/mattn/go-colorable v0.1.4 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/onosproject/config-models/modelplugin/devicesim-1.0.0 v0.0.0-20200903015527-386223ad48bd
Expand All @@ -33,8 +35,7 @@ require (
github.com/spf13/viper v1.6.2
github.com/stretchr/testify v1.5.1
go.uber.org/multierr v1.4.0 // indirect
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4 // indirect
golang.org/x/tools v0.0.0-20200113040837-eac381796e91 // indirect
golang.org/x/mobile v0.0.0-20190806162312-597adff16ade // indirect
google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce // indirect
google.golang.org/grpc v1.31.1
gopkg.in/yaml.v2 v2.2.8
Expand Down
41 changes: 5 additions & 36 deletions test/cli/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/onosproject/helmit/pkg/helm"
"github.com/onosproject/helmit/pkg/kubernetes"
"github.com/onosproject/helmit/pkg/util/random"
"github.com/onosproject/onos-test/pkg/onostest"
"github.com/stretchr/testify/assert"
"strings"
"testing"
Expand Down Expand Up @@ -107,13 +108,11 @@ func (s *TestSuite) TestPluginsGetCLI(t *testing.T) {
time.Sleep(60 * time.Second)

// Get one of the onos-cli pods
release := helm.Chart("onos-cli", "https://charts.onosproject.org").
Release("onos-cli")
release := helm.Chart("onos-umbrella", onostest.OnosChartRepo).Release("onos-umbrella")
client := kubernetes.NewForReleaseOrDie(release)
pods, err := client.
CoreV1().
Pods().
List()
dep, err := client.AppsV1().Deployments().Get("onos-cli")
assert.NoError(t, err)
pods, err := dep.Pods().List()
assert.NoError(t, err)
pod := pods[0]

Expand All @@ -124,16 +123,6 @@ func (s *TestSuite) TestPluginsGetCLI(t *testing.T) {
plugins := parsePluginsCommandOutput(t, output)

testCases := []pluginsTestCase{
{
pluginName: "Stratum",
pluginVersion: "1.0.0",
pluginObject: "stratum.so.1.0.0",
yangName: "openconfig-interfaces-stratum",
attributes: pluginAttributes{
pluginVersion: "0.1.0",
pluginSource: "Open Networking Foundation",
},
},
{
pluginName: "TestDevice",
pluginVersion: "1.0.0",
Expand Down Expand Up @@ -164,26 +153,6 @@ func (s *TestSuite) TestPluginsGetCLI(t *testing.T) {
pluginSource: "OpenConfig working group",
},
},
{
pluginName: "Stratum",
pluginVersion: "1.0.0",
pluginObject: "stratum.so.1.0.0",
yangName: "openconfig-if-ip",
attributes: pluginAttributes{
pluginVersion: "3.0.0",
pluginSource: "OpenConfig working group",
},
},
{
pluginName: "Stratum",
pluginVersion: "1.0.0",
pluginObject: "stratum.so.1.0.0",
yangName: "openconfig-hercules-platform-node",
attributes: pluginAttributes{
pluginVersion: "0.2.0",
pluginSource: "OpenConfig working group",
},
},
}

// Run the test cases
Expand Down
51 changes: 3 additions & 48 deletions test/cli/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
package cli

import (
"github.com/onosproject/helmit/pkg/helm"
"github.com/onosproject/helmit/pkg/test"
"github.com/onosproject/onos-test/pkg/onostest"
"github.com/onosproject/onos-config/test/utils/charts"
)

type testSuite struct {
Expand All @@ -29,52 +28,8 @@ type TestSuite struct {
testSuite
}

const onosComponentName = "onos-config"
const testName = "cli-test"

// SetupTestSuite sets up the onos-config CLI test suite
func (s *TestSuite) SetupTestSuite() error {
err := helm.Chart(onostest.ControllerChartName, onostest.AtomixChartRepo).
Release(onostest.AtomixName(testName, onosComponentName)).
Set("scope", "Namespace").
Install(true)
if err != nil {
return err
}

err = helm.Chart(onostest.RaftStorageControllerChartName, onostest.AtomixChartRepo).
Release(onostest.RaftReleaseName(onosComponentName)).
Set("scope", "Namespace").
Install(true)
if err != nil {
return err
}

err = helm.Chart("onos-topo", onostest.OnosChartRepo).
Release("onos-topo").
Set("image.tag", "latest").
Set("storage.controller", onostest.AtomixController(testName, onosComponentName)).
Install(true)
if err != nil {
return err
}

err = helm.Chart("onos-config", onostest.OnosChartRepo).
Release("onos-config").
Set("image.tag", "latest").
Set("storage.controller", onostest.AtomixController(testName, onosComponentName)).
Install(true)
if err != nil {
return err
}

err = helm.Chart("onos-cli", onostest.OnosChartRepo).
Release("onos-cli").
Set("image.tag", "latest").
Install(true)
if err != nil {
return err
}

return nil
umbrella := charts.CreateUmbrellaRelease()
return umbrella.Install(true)
}
48 changes: 5 additions & 43 deletions test/gnmi/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,62 +15,24 @@
package gnmi

import (
"github.com/onosproject/onos-config/test/utils/charts"
"sync"

"github.com/onosproject/onos-test/pkg/onostest"

"github.com/onosproject/helmit/pkg/helm"
"github.com/onosproject/helmit/pkg/test"
)

type testSuite struct {
test.Suite
}

// TestSuite is the onos-config CLI test suite
// TestSuite is the onos-config GNMI test suite
type TestSuite struct {
testSuite
mux sync.Mutex
}

const onosComponentName = "onos-config"
const testName = "gnmi-test"

// SetupTestSuite sets up the onos-config CLI test suite
// SetupTestSuite sets up the onos-config GNMI test suite
func (s *TestSuite) SetupTestSuite() error {
err := helm.Chart(onostest.ControllerChartName, onostest.AtomixChartRepo).
Release(onostest.AtomixName(testName, onosComponentName)).
Set("scope", "Namespace").
Install(true)
if err != nil {
return err
}

err = helm.Chart(onostest.RaftStorageControllerChartName, onostest.AtomixChartRepo).
Release(onostest.RaftReleaseName(onosComponentName)).
Set("scope", "Namespace").
Install(true)
if err != nil {
return err
}

err = helm.Chart("onos-topo", onostest.OnosChartRepo).
Release("onos-topo").
Set("image.tag", "latest").
Set("storage.controller", onostest.AtomixController(testName, onosComponentName)).
Install(true)
if err != nil {
return err
}

err = helm.Chart("onos-config", onostest.OnosChartRepo).
Release("onos-config").
Set("image.tag", "latest").
Set("storage.controller", onostest.AtomixController(testName, onosComponentName)).
Install(true)
if err != nil {
return err
}

return nil
umbrella := charts.CreateUmbrellaRelease()
return umbrella.Install(true)
}
Loading

0 comments on commit ef4cb6d

Please sign in to comment.