Skip to content

Commit 1fabd26

Browse files
committed
Add E2E test
1 parent 750435e commit 1fabd26

File tree

4 files changed

+65
-3
lines changed

4 files changed

+65
-3
lines changed

cmd/opampsupervisor/e2e_test.go

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,12 +617,38 @@ func TestSupervisorConfiguresCapabilities(t *testing.T) {
617617
}
618618

619619
func TestSupervisorBootstrapsCollector(t *testing.T) {
620+
tests := []struct {
621+
name string
622+
cfg string
623+
env []string
624+
precheck func(t *testing.T)
625+
}{
626+
{
627+
name: "With service.AllowNoPipelines",
628+
cfg: "nocap",
629+
},
630+
{
631+
name: "Without service.AllowNoPipelines",
632+
cfg: "no_fg",
633+
env: []string{
634+
"COLLECTOR_BIN=../../bin/otelcontribcol_" + runtime.GOOS + "_" + runtime.GOARCH,
635+
},
636+
precheck: func(t *testing.T) {
637+
if runtime.GOOS == "windows" {
638+
t.Skip("This test requires a shell script, which may not be supported by Windows")
639+
}
640+
},
641+
},
642+
}
643+
644+
for _, tt := range tests {
645+
t.Run(tt.name, func(t *testing.T) {
620646
agentDescription := atomic.Value{}
621647

622648
// Load the Supervisor config so we can get the location of
623649
// the Collector that will be run.
624650
var cfg config.Supervisor
625-
cfgFile := getSupervisorConfig(t, "nocap", map[string]string{})
651+
cfgFile := getSupervisorConfig(t, tt.cfg, map[string]string{})
626652
k := koanf.New("::")
627653
err := k.Load(file.Provider(cfgFile.Name()), yaml.Parser())
628654
require.NoError(t, err)
@@ -637,7 +663,14 @@ func TestSupervisorBootstrapsCollector(t *testing.T) {
637663
// information will be used as defaults for the telemetry
638664
// attributes.
639665
agentPath := cfg.Agent.Executable
640-
componentsInfo, err := exec.Command(agentPath, "components").Output()
666+
t.Log(agentPath)
667+
wd, _ := os.Getwd()
668+
t.Log(wd)
669+
cmd := exec.Command(agentPath, "components")
670+
for _, env := range tt.env {
671+
cmd.Env = append(cmd.Env, env)
672+
}
673+
componentsInfo, err := cmd.Output()
641674
require.NoError(t, err)
642675
k = koanf.New("::")
643676
err = k.Load(rawbytes.Provider(componentsInfo), yaml.Parser())
@@ -688,6 +721,8 @@ func TestSupervisorBootstrapsCollector(t *testing.T) {
688721
// binary.
689722
return agentName == command && agentVersion == version
690723
}, 5*time.Second, 250*time.Millisecond)
724+
})
725+
}
691726
}
692727

693728
func TestSupervisorBootstrapsCollectorAvailableComponents(t *testing.T) {

cmd/opampsupervisor/supervisor/supervisor.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,8 @@ func (s *Supervisor) getFeatureGates() error {
386386
return err
387387
}
388388

389-
stdout, _, err := cmd.StartOneShot()
389+
stdout, stderr, err := cmd.StartOneShot()
390+
fmt.Println(stdout, stderr)
390391
if err != nil {
391392
return err
392393
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright The OpenTelemetry Authors
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
${COLLECTOR_BIN} "$@" | grep -v "service.AllowNoPipelines"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
server:
2+
endpoint: ws://{{.url}}/v1/opamp
3+
4+
capabilities:
5+
reports_available_components: false
6+
reports_effective_config: false
7+
reports_own_metrics: false
8+
reports_own_logs: false
9+
reports_own_traces: false
10+
reports_health: false
11+
accepts_remote_config: false
12+
reports_remote_config: false
13+
14+
storage:
15+
directory: '{{.storage_dir}}'
16+
17+
agent:
18+
executable: ./testdata/collector/no_pipelines_fg.sh
19+
env:
20+
COLLECTOR_BIN: ../../bin/otelcontribcol_{{.goos}}_{{.goarch}}{{.extension}}

0 commit comments

Comments
 (0)