Skip to content

Commit

Permalink
Update integration tests to new Helmit APIs (#1638)
Browse files Browse the repository at this point in the history
* Update integration tests to use Helmit/testify for testing

* Fix compilation errors in tests

* Add missing Wait() calls to test suite setup methods

* Add tear down methods to test suites

* Use test timeouts when waiting for availability in tests

* Store releases in test suite fields

* Fix device sim addresses in tests

* Fix linter errors in tests

* Fix incorrect inputs to Len assertions in config test suite

* Fix label selector in device simulator pod lookup in crashedtarget test

* Update benchmarks to latest Helmit version

* Fix compiler errors in benchmark utilities

* Update Helmit dependency and remove test/benchmark mains

* Add missing assertion to offline target test

* Add missing license headers on moved utility files

* Update to Helmit v1.0.0
  • Loading branch information
kuujo authored Mar 28, 2023
1 parent c6dd88f commit d7b4582
Show file tree
Hide file tree
Showing 55 changed files with 2,554 additions and 3,379 deletions.
11 changes: 3 additions & 8 deletions benchmark/gnmi/getbench.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,13 @@ package gnmi

import (
"context"
"github.com/onosproject/helmit/pkg/benchmark"
gnmiutils "github.com/onosproject/onos-config/test/utils/gnmi"
gnmiutils "github.com/onosproject/onos-config/benchmark/utils/gnmi"
gnmiapi "github.com/openconfig/gnmi/proto/gnmi"
"time"
)

// BenchmarkGet tests get of GNMI paths
func (s *BenchmarkSuite) BenchmarkGet(b *benchmark.Benchmark) error {
devicePath := gnmiutils.GetTargetPath(s.simulator.Name(), "/system/config/motd-banner")
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()

func (s *BenchmarkSuite) BenchmarkGet(ctx context.Context) error {
devicePath := gnmiutils.GetTargetPath(s.simulator.Name, "/system/config/motd-banner")
var onosConfigGetReq = &gnmiutils.GetRequest{
Ctx: ctx,
Client: s.client,
Expand Down
13 changes: 5 additions & 8 deletions benchmark/gnmi/setbench.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,15 @@ package gnmi

import (
"context"
"github.com/onosproject/helmit/pkg/benchmark"
gnmiutils "github.com/onosproject/onos-config/test/utils/gnmi"
"github.com/onosproject/onos-config/test/utils/proto"
petname "github.com/dustinkirkland/golang-petname"
gnmiutils "github.com/onosproject/onos-config/benchmark/utils/gnmi"
"github.com/onosproject/onos-config/benchmark/utils/proto"
gnmiapi "github.com/openconfig/gnmi/proto/gnmi"
"time"
)

// BenchmarkSet tests set of GNMI paths
func (s *BenchmarkSuite) BenchmarkSet(b *benchmark.Benchmark) error {
devicePath := gnmiutils.GetTargetPathWithValue(s.simulator.Name(), "/system/config/motd-banner", s.value.Next().String(), proto.StringVal)
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
func (s *BenchmarkSuite) BenchmarkSet(ctx context.Context) error {
devicePath := gnmiutils.GetTargetPathWithValue(s.simulator.Name, "/system/config/motd-banner", petname.Generate(2, " "), proto.StringVal)
var setReq = &gnmiutils.SetRequest{
Ctx: ctx,
Client: s.client,
Expand Down
56 changes: 38 additions & 18 deletions benchmark/gnmi/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ package gnmi

import (
"context"
petname "github.com/dustinkirkland/golang-petname"
"github.com/onosproject/helmit/pkg/benchmark"
"github.com/onosproject/helmit/pkg/helm"
"github.com/onosproject/helmit/pkg/input"
"github.com/onosproject/helmit/pkg/util/random"
"github.com/onosproject/onos-config/test/utils/charts"
"github.com/onosproject/onos-config/test/utils/gnmi"
"github.com/onosproject/onos-config/benchmark/utils/gnmi"
"github.com/onosproject/onos-test/pkg/onostest"
"github.com/openconfig/gnmi/client/gnmi"
"time"
Expand All @@ -20,28 +18,45 @@ import (
// BenchmarkSuite is an onos-config gNMI benchmark suite
type BenchmarkSuite struct {
benchmark.Suite
simulator *helm.HelmRelease
umbrella *helm.Release
simulator *helm.Release
client *client.Client
value input.Source
}

// SetupSuite :: benchmark
func (s *BenchmarkSuite) SetupSuite(c *input.Context) error {
umbrella := charts.CreateUmbrellaRelease().
func (s *BenchmarkSuite) SetupSuite(ctx context.Context) error {
release, err := s.Helm().Install("onos", "onos-umbrella").
RepoURL(onostest.OnosChartRepo).
Set("onos-topo.image.tag", "latest").
Set("onos-config.image.tag", "latest").
Set("onos-config-model.image.tag", "latest").
Set("onos-topo.replicaCount", 2).
Set("onos-config.replicaCount", 2)
return umbrella.Install(true)
Set("onos-config.replicaCount", 2).
Wait().
Get(ctx)
if err != nil {
return err
}
s.umbrella = release
return nil
}

// TearDownSuite :: benchmark
func (s *BenchmarkSuite) TearDownSuite(ctx context.Context) error {
return s.Helm().Uninstall(s.umbrella.Name).Do(ctx)
}

// SetupWorker :: benchmark
func (s *BenchmarkSuite) SetupWorker(c *input.Context) error {
s.value = input.RandomString(8)
s.simulator = helm.
Chart("device-simulator", onostest.OnosChartRepo).
Release(random.NewPetName(2))
if err := s.simulator.Install(true); err != nil {
func (s *BenchmarkSuite) SetupWorker(ctx context.Context) error {
release, err := s.Helm().
Install(petname.Generate(2, "-"), "device-simulator").
RepoURL(onostest.OnosChartRepo).
Wait().
Get(ctx)
if err != nil {
return err
}
s.simulator = release
gnmiClient, err := getGNMIClient()
if err != nil {
return err
Expand All @@ -51,9 +66,9 @@ func (s *BenchmarkSuite) SetupWorker(c *input.Context) error {
}

// TearDownWorker :: benchmark
func (s *BenchmarkSuite) TearDownWorker(c *input.Context) error {
func (s *BenchmarkSuite) TearDownWorker(ctx context.Context) error {
s.client.Close()
return s.simulator.Uninstall()
return s.Helm().Uninstall(s.simulator.Name).Do(ctx)
}

var _ benchmark.SetupWorker = &BenchmarkSuite{}
Expand All @@ -72,3 +87,8 @@ func getGNMIClient() (*client.Client, error) {
}
return gnmiClient.(*client.Client), nil
}

var _ benchmark.SetupSuite = (*BenchmarkSuite)(nil)
var _ benchmark.TearDownSuite = (*BenchmarkSuite)(nil)
var _ benchmark.SetupWorker = (*BenchmarkSuite)(nil)
var _ benchmark.TearDownWorker = (*BenchmarkSuite)(nil)
Loading

0 comments on commit d7b4582

Please sign in to comment.