Skip to content

Commit

Permalink
remove os.description check from supervisor e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaasman00 committed Oct 15, 2024
1 parent 04991a9 commit 5cddc29
Showing 1 changed file with 2 additions and 41 deletions.
43 changes: 2 additions & 41 deletions cmd/opampsupervisor/e2e_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

//go:build e2e

package main

import (
Expand Down Expand Up @@ -691,8 +689,6 @@ func TestSupervisorAgentDescriptionConfigApplies(t *testing.T) {
host, err := os.Hostname()
require.NoError(t, err)

description := getOSDescription(t)

// Get the binary name and version from the Collector binary
// using the `components` command that prints a YAML-encoded
// map of information about the Collector build. Some of this
Expand Down Expand Up @@ -750,12 +746,12 @@ func TestSupervisorAgentDescriptionConfigApplies(t *testing.T) {
stringKeyValue("env", "prod"),
stringKeyValue(semconv.AttributeHostArch, runtime.GOARCH),
stringKeyValue(semconv.AttributeHostName, host),
stringKeyValue(semconv.AttributeOSDescription, description),
stringKeyValue(semconv.AttributeOSType, runtime.GOOS),
},
}

require.Equal(t, expectedDescription, ad.AgentDescription)
require.Contains(t, ad.AgentDescription.IdentifyingAttributes, expectedDescription.IdentifyingAttributes)
require.Contains(t, ad.AgentDescription.NonIdentifyingAttributes, expectedDescription.NonIdentifyingAttributes)

time.Sleep(250 * time.Millisecond)
}
Expand Down Expand Up @@ -1462,38 +1458,3 @@ func findRandomPort() (int, error) {

return port, nil
}

func getOSDescription(t *testing.T) string {
switch runtime.GOOS {
case "linux":
output, err := exec.Command("lsb_release", "-a").Output()
require.NoError(t, err)
for _, line := range strings.Split(string(output), "\n") {
if raw, ok := strings.CutPrefix(line, "Description:"); ok {
return strings.TrimSpace(raw)
}
}
case "darwin":
output, err := exec.Command("sw_vers").Output()
require.NoError(t, err)
var productName string
var productVersion string
for _, line := range strings.Split(string(output), "\n") {
if raw, ok := strings.CutPrefix(line, "ProductName:"); ok {
productName = strings.TrimSpace(raw)
} else if raw, ok = strings.CutPrefix(line, "ProductVersion:"); ok {
productVersion = strings.TrimSpace(raw)
}
}
if productName != "" && productVersion != "" {
return productName + " " + productVersion
}
case "windows":
output, err := exec.Command("cmd", "/c", "ver").Output()
require.NoError(t, err)
if string(output) != "" {
return strings.TrimSpace(string(output))
}
}
return ""
}

0 comments on commit 5cddc29

Please sign in to comment.