Skip to content

Commit

Permalink
tests: adopt signalfx-go 1.32.0 (#3235)
Browse files Browse the repository at this point in the history
* Bump github.com/signalfx/signalfx-go from 1.30.0 to 1.32.0 in /tests

Bumps [github.com/signalfx/signalfx-go](https://github.com/signalfx/signalfx-go) from 1.30.0 to 1.32.0.
- [Release notes](https://github.com/signalfx/signalfx-go/releases)
- [Changelog](https://github.com/signalfx/signalfx-go/blob/master/CHANGELOG.md)
- [Commits](signalfx/signalfx-go@v1.30.0...v1.32.0)

---
updated-dependencies:
- dependency-name: github.com/signalfx/signalfx-go
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* adopt signalfx-go/signalflow/v2 client

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
rmfitzpatrick and dependabot[bot] authored Jun 6, 2023
1 parent 06507e9 commit 5112975
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 3,003 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ require (
github.com/signalfx/ingest-protocols v0.1.14 // indirect
github.com/signalfx/sapm-proto v0.12.0 // indirect
github.com/signalfx/signalfx-agent/pkg/apm v0.0.0-20230222185249-54e5d1064c5b // indirect
github.com/signalfx/signalfx-go v1.30.0 // indirect
github.com/signalfx/signalfx-go v1.32.0 // indirect
github.com/sijms/go-ora/v2 v2.7.6 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/snowflakedb/gosnowflake v1.6.19 // indirect
Expand Down
655 changes: 2 additions & 653 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/receiver/smartagentreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ require (
github.com/signalfx/ingest-protocols v0.1.14 // indirect
github.com/signalfx/sapm-proto v0.12.0 // indirect
github.com/signalfx/signalfx-agent/pkg/apm v0.0.0-20230104182534-9eee411fe305 // indirect
github.com/signalfx/signalfx-go v1.30.0 // indirect
github.com/signalfx/signalfx-go v1.32.0 // indirect
github.com/snowflakedb/gosnowflake v1.6.19 // indirect
github.com/soniah/gosnmp v0.0.0-20190220004421-68e8beac0db9 // indirect
github.com/spf13/pflag v1.0.5 // indirect
Expand Down
937 changes: 3 additions & 934 deletions pkg/receiver/smartagentreceiver/go.sum

Large diffs are not rendered by default.

50 changes: 30 additions & 20 deletions tests/endtoend/authscope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
sfxpb "github.com/signalfx/com_signalfx_metrics_protobuf/model"
sfx "github.com/signalfx/signalfx-go"
"github.com/signalfx/signalfx-go/metrics_metadata"
"github.com/signalfx/signalfx-go/signalflow"
"github.com/signalfx/signalfx-go/signalflow/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v2"
Expand Down Expand Up @@ -98,6 +98,9 @@ func TestIngestAuthScopeTokenGrantsRequiredMetricAndDimensionCapabilities(tt *te
collector, shutdown := tc.SplunkOtelCollector("postgres_config.yaml")
defer shutdown()

fmt.Println("sleeping 20s to give collector time to process and send metadata updates")
time.Sleep(20 * time.Second)

client, err := sfx.NewClient(ts.DefaultToken, sfx.APIUrl(ts.APIUrl))
require.NoError(t, err)
require.NotNil(t, client)
Expand Down Expand Up @@ -140,21 +143,23 @@ func TestIngestAuthScopeTokenGrantsRequiredEventCapabilities(tt *testing.T) {
collector, shutdown := tc.SplunkOtelCollector("event_forwarder_config.yaml")
defer shutdown()

client, err := sfx.NewClient(ts.DefaultToken, sfx.APIUrl(ts.APIUrl))
client, err := signalflow.NewClient(
signalflow.AccessToken(ts.DefaultToken),
signalflow.StreamURL(ts.SignalFlowUrl),
signalflow.OnError(func(err error) {
require.NoError(t, err)
}),
)
require.NoError(t, err)
require.NotNil(t, client)

sflow, err := client.SignalFlow(signalflow.StreamURL(ts.SignalFlowUrl))
require.NoError(t, err)
require.NotNil(t, sflow)

eventType := fmt.Sprintf("testevent%s", tc.ID)
program := fmt.Sprintf("events(eventType=%q).publish()", eventType)

comp, err := sflow.Execute(&signalflow.ExecuteRequest{Program: program})
comp, err := client.Execute(context.Background(), &signalflow.ExecuteRequest{Program: program})
require.NoError(t, err)
require.NotNil(t, comp)
defer comp.Stop()
defer comp.Stop(context.Background())

fmt.Println("sleeping 10s before sending event to Collector to allow computation to begin")
time.Sleep(10 * time.Second)
Expand All @@ -163,16 +168,20 @@ func TestIngestAuthScopeTokenGrantsRequiredEventCapabilities(tt *testing.T) {

done := make(chan struct{})
go func() {
for _, event := range comp.Events() {
expected := 10
for event := range comp.Events() {
raw := event.RawData()
require.Contains(t, raw, "metadata")
// added by configured resource processor
require.Contains(t, raw["metadata"], "testid")
metadata, ok := raw["metadata"].(map[string]any)
require.True(t, ok)
require.Equal(t, tc.ID, metadata["testid"])
close(done)
return
expected--
if expected == 0 {
close(done)
return
}
}
}()

Expand Down Expand Up @@ -229,23 +238,24 @@ func TestAPIAuthScopeTokenDoesntGrantRequiredEventCapabilities(t *testing.T) {
collector, shutdown := tc.SplunkOtelCollector("event_forwarder_config.yaml")
defer shutdown()

client, err := sfx.NewClient(
ts.DefaultToken, sfx.APIUrl(ts.APIUrl),
sflow, err := signalflow.NewClient(
signalflow.AccessToken(ts.DefaultToken),
signalflow.StreamURL(ts.SignalFlowUrl),
signalflow.OnError(func(err error) {
require.NoError(t, err)
}),
)
require.NoError(t, err)
require.NotNil(t, client)

sflow, err := client.SignalFlow(signalflow.StreamURL(ts.SignalFlowUrl))
require.NoError(t, err)
require.NotNil(t, sflow)

eventType := fmt.Sprintf("testevent%s", tc.ID)
program := fmt.Sprintf("events(eventType=%q).publish()", eventType)

comp, err := sflow.Execute(&signalflow.ExecuteRequest{Program: program})
comp, err := sflow.Execute(context.Background(), &signalflow.ExecuteRequest{Program: program})
require.NoError(t, err)
require.NotNil(t, comp)
defer comp.Stop()
defer comp.Stop(context.Background())

fmt.Println("sleeping 10s before sending event to Collector to allow computation to begin")
time.Sleep(10 * time.Second)
Expand All @@ -254,7 +264,7 @@ func TestAPIAuthScopeTokenDoesntGrantRequiredEventCapabilities(t *testing.T) {

done := make(chan struct{})
go func() {
for _, event := range comp.Events() {
for event := range comp.Events() {
close(done)
require.Fail(t, "should never have received with api token event: %v", event)
return
Expand Down Expand Up @@ -336,14 +346,14 @@ func assertQueryIdDimensionsWithQueryProperties(tc *testutils.Testcase, sfxClien
}

func sendEvents(t testing.TB, eventType string) {
dim := sfxpb.Dimension{Key: "dim_one", Value: "val_one"}
propVal := "a test event"
description := sfxpb.Property{Key: "description", Value: &sfxpb.PropertyValue{StrValue: &propVal}}

alert := sfxpb.EventCategory_USER_DEFINED

// I have found sending several events to be necessary for detecting in a fresh signalflow job
for i := 0; i < 10; i++ {
dim := sfxpb.Dimension{Key: "dim_one", Value: fmt.Sprintf("%d", i)}
event := sfxpb.Event{
EventType: eventType,
Dimensions: []*sfxpb.Dimension{&dim},
Expand Down
3 changes: 3 additions & 0 deletions tests/endtoend/testdata/event_forwarder_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ exporters:
enabled: false

service:
telemetry:
logs:
level: debug
pipelines:
logs:
receivers:
Expand Down
3 changes: 3 additions & 0 deletions tests/endtoend/testdata/postgres_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ exporters:
enabled: false

service:
telemetry:
logs:
level: debug
pipelines:
metrics:
receivers:
Expand Down
6 changes: 3 additions & 3 deletions tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ require (
github.com/google/uuid v1.3.0
github.com/shirou/gopsutil/v3 v3.23.5
github.com/signalfx/com_signalfx_metrics_protobuf v0.0.3
github.com/signalfx/signalfx-go v1.30.0
github.com/signalfx/signalfx-go v1.32.0
github.com/signalfx/signalfx-go/signalflow/v2 v2.1.0
github.com/stretchr/testify v1.8.4
github.com/testcontainers/testcontainers-go v0.20.1
go.opentelemetry.io/collector v0.78.2
Expand Down Expand Up @@ -78,7 +79,7 @@ require (
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
github.com/huandu/xstrings v1.3.3 // indirect
github.com/imdario/mergo v0.3.12 // indirect
Expand Down Expand Up @@ -121,7 +122,6 @@ require (
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/signalfx/golib/v3 v3.3.47 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.7.0 // indirect
Expand Down
Loading

0 comments on commit 5112975

Please sign in to comment.