Skip to content

Commit

Permalink
Drop builtin builder configuration integration tests.
Browse files Browse the repository at this point in the history
Drop the integration tests for the builtin builder configuration.
We assume that it is a working config because it is generated from
with the source tree and should be covered by collector tests. Add a
unit test to ensure some basic sanity for the builtin configuration.

This fixes #6076.

Signed-off-by: James Peach <jpeach@cloudflare.com>
  • Loading branch information
jpeach committed Sep 27, 2022
1 parent e981169 commit 4cbe77e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
1 change: 1 addition & 0 deletions cmd/builder/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ require (
)

require (
github.com/benbjohnson/clock v1.1.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
Expand Down
1 change: 1 addition & 0 deletions cmd/builder/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ github.com/aws/aws-sdk-go-v2/service/sso v1.4.2/go.mod h1:NBvT9R1MEF+Ud6ApJKM0G+
github.com/aws/aws-sdk-go-v2/service/sts v1.7.2/go.mod h1:8EzeIqfWt2wWT4rJVu3f21TfrhJ8AEMzVybRNSb/b4g=
github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
Expand Down
25 changes: 25 additions & 0 deletions cmd/builder/internal/builder/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ import (
"strings"
"testing"

"github.com/knadh/koanf"
"github.com/knadh/koanf/parsers/yaml"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
"go.uber.org/zap/zaptest"

"go.opentelemetry.io/collector/cmd/builder/internal/config"
)

func TestParseModules(t *testing.T) {
Expand Down Expand Up @@ -141,6 +146,26 @@ func TestNewDefaultConfig(t *testing.T) {
require.NoError(t, cfg.Validate())
}

func TestNewBuiltinConfig(t *testing.T) {
k := koanf.New(".")

require.NoError(t, k.Load(config.DefaultProvider(), yaml.Parser()))

cfg := Config{Logger: zaptest.NewLogger(t)}

require.NoError(t, k.UnmarshalWithConf("", &cfg, koanf.UnmarshalConf{Tag: "mapstructure"}))
assert.NoError(t, cfg.ParseModules())
assert.NoError(t, cfg.Validate())

// Unlike the config initialized in NewDefaultConfig(), we expect
// the builtin default to be practically useful, so there must be
// a set of modules present.
assert.NotZero(t, len(cfg.Receivers))
assert.NotZero(t, len(cfg.Exporters))
assert.NotZero(t, len(cfg.Extensions))
assert.NotZero(t, len(cfg.Processors))
}

func TestSkipGoValidation(t *testing.T) {
cfg := Config{
Distribution: Distribution{
Expand Down
9 changes: 1 addition & 8 deletions cmd/builder/test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ test_build_config() {

echo "Starting test '${test}' at `date`" >> "${out}/test.log"

if [ -z "$build_config" ] ; then
go run . --go "${GOBIN}" --output-path "${out}" --name otelcol-built-test > "${out}/builder.log" 2>&1
else
go run . --go "${GOBIN}" --config "$build_config" --output-path "${out}" --name otelcol-built-test > "${out}/builder.log" 2>&1
fi
go run . --go "${GOBIN}" --config "$build_config" --output-path "${out}" --name otelcol-built-test > "${out}/builder.log" 2>&1

if [ $? != 0 ]; then
echo "❌ FAIL ${test}. Failed to compile the test ${test}. Build logs:"
Expand Down Expand Up @@ -112,9 +108,6 @@ echo "Running the tests in ${base}"

failed=false

# Test that an empty build configuration builds a working default collector.
test_build_config "default"

for test in $tests
do
test_build_config "$test" "./test/${test}.builder.yaml"
Expand Down

0 comments on commit 4cbe77e

Please sign in to comment.