Skip to content

Commit

Permalink
Fix incorrect stability labels and add test (#6541)
Browse files Browse the repository at this point in the history
* Fix incorrect stability levels

* Add more tests
  • Loading branch information
thampiotr authored Feb 28, 2024
1 parent 078149d commit b52d037
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 4 deletions.
2 changes: 1 addition & 1 deletion component/otelcol/connector/host_info/host_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
func init() {
component.Register(component.Registration{
Name: "otelcol.connector.host_info",
Stability: featuregate.StabilityStable,
Stability: featuregate.StabilityExperimental,
Args: Arguments{},
Exports: otelcol.ConsumerExports{},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
func init() {
component.Register(component.Registration{
Name: "otelcol.processor.resourcedetection",
Stability: featuregate.StabilityStable,
Stability: featuregate.StabilityBeta,
Args: Arguments{},
Exports: otelcol.ConsumerExports{},

Expand Down
2 changes: 1 addition & 1 deletion component/pyroscope/java/java.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
func init() {
component.Register(component.Registration{
Name: "pyroscope.java",
Stability: featuregate.StabilityStable,
Stability: featuregate.StabilityBeta,
Args: Arguments{},

Build: func(opts component.Options, args component.Arguments) (component.Component, error) {
Expand Down
2 changes: 1 addition & 1 deletion component/pyroscope/java/java_stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func init() {
component.Register(component.Registration{
Name: "pyroscope.java",
Stability: featuregate.StabilityStable,
Stability: featuregate.StabilityBeta,
Args: Arguments{},

Build: func(opts component.Options, args component.Arguments) (component.Component, error) {
Expand Down
36 changes: 36 additions & 0 deletions pkg/flow/internal/testcomponents/experimental.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package testcomponents

import (
"context"

"github.com/go-kit/log"
"github.com/grafana/agent/component"
"github.com/grafana/agent/internal/featuregate"
)

func init() {
component.Register(component.Registration{
Name: "testcomponents.experimental",
Stability: featuregate.StabilityExperimental,

Build: func(opts component.Options, args component.Arguments) (component.Component, error) {
return &Experimental{log: opts.Logger}, nil
},
})
}

// Experimental is a test component that is marked as experimental. Used to verify stability level checking.
type Experimental struct {
log log.Logger
}

func (e *Experimental) Run(ctx context.Context) error {
e.log.Log("msg", "running experimental component")
<-ctx.Done()
return nil
}

func (e *Experimental) Update(args component.Arguments) error {
e.log.Log("msg", "updating experimental component")
return nil
}
14 changes: 14 additions & 0 deletions pkg/flow/testdata/import_error/import_error_3.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Use of an imported component with too low stability level propagates the error

-- main.river --

import.string "testImport" {
content = ` declare "a" {
testcomponents.experimental "unstable" {}
}`
}

testImport.a "cc" {}

-- error --
component "testcomponents.experimental" is at stability level "experimental", which is below the minimum allowed stability level "beta"
18 changes: 18 additions & 0 deletions pkg/flow/testdata/import_error/import_error_4.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Use of a nested declare component with too low stability level propagates the error

-- main.river --

declare "a" {

declare "b" {
testcomponents.experimental "unstable" {}
}

b "cc" {}

}

a "cc" {}

-- error --
component "testcomponents.experimental" is at stability level "experimental", which is below the minimum allowed stability level "beta"
38 changes: 38 additions & 0 deletions pkg/flow/testdata/import_file/import_file_14.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Import module with an unused component that has too low stability level

-- main.river --
testcomponents.count "inc" {
frequency = "10ms"
max = 10
}

import.file "testImport" {
filename = "module.river"
}

testImport.a "cc" {
input = testcomponents.count.inc.count
}

testcomponents.summation "sum" {
input = testImport.a.cc.output
}

-- module.river --

declare "unused" {
testcomponents.experimental "unused" {}
}

declare "a" {
argument "input" {}

testcomponents.passthrough "pt" {
input = argument.input.value
lag = "1ms"
}

export "output" {
value = testcomponents.passthrough.pt.output
}
}
84 changes: 84 additions & 0 deletions pkg/flow/testdata/import_file/import_file_15.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
Import nested module with an unused component with too low stability level

-- main.river --
testcomponents.count "inc" {
frequency = "10ms"
max = 10
}

import.file "testImport" {
filename = "module.river"
}

testImport.a "cc" {
input = testcomponents.count.inc.count
}

testcomponents.summation "sum" {
input = testImport.a.cc.output
}

-- module.river --
import.file "testImport" {
filename = "nested_module.river"
}

declare "a" {
argument "input" {}

testImport.a "cc" {
input = argument.input.value
}

export "output" {
value = testImport.a.cc.output
}
}

-- nested_module.river --
declare "a" {
argument "input" {}

testcomponents.passthrough "pt" {
input = argument.input.value
lag = "1ms"
}

export "output" {
value = testcomponents.passthrough.pt.output
}
}

-- other_nested_module.river --
declare "unused" {
testcomponents.experimental "unused" {}
}

declare "a" {
argument "input" {}

export "output" {
value = -argument.input.value
}
}

-- update/module.river --
import.file "testImport" {
filename = "other_nested_module.river"
}

declare "unused" {
testcomponents.experimental "unused" {}
}

declare "a" {
argument "input" {}

testImport.a "cc" {
input = argument.input.value
}

export "output" {
value = testImport.a.cc.output
}
}

0 comments on commit b52d037

Please sign in to comment.