-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix incorrect stability labels and add test (#6541)
* Fix incorrect stability levels * Add more tests
- Loading branch information
Showing
9 changed files
with
194 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |