mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-02-14 10:19:54 +00:00
Refactor Remote Host Collection (#1633)
* refactor remote collectors * add remotecollect params struct * remove commented checkrbac function * removed unused function * add temp comments * refactor to not require RemoteCollect method per collector * removed unneeded param * removed unneeded param * more refactor * more refactor * remove unneeded function * remove debug print * fix analyzer results * move rbac to separate file * be more specific with rbac function name * fix imports * fix node list file * make k8s rest client config consistent with in cluster collection * add ctx and otel tracing * add test for allCollectedData * move runHostCollectorsInPod to spec instead of metadata * make generate * fix broken references to supportbundle metadata * add e2e tests * update loader tests * fix tests * fix hostos remote collector spec * update remoteHostCollectrs.yaml --------- Co-authored-by: Dexter Yan <yanshaocong@gmail.com>
This commit is contained in:
41
test/e2e/support-bundle/host_remote_collector_e2e_test.go
Normal file
41
test/e2e/support-bundle/host_remote_collector_e2e_test.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package e2e
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"testing"
|
||||
|
||||
"sigs.k8s.io/e2e-framework/pkg/envconf"
|
||||
"sigs.k8s.io/e2e-framework/pkg/features"
|
||||
)
|
||||
|
||||
func TestHostRemoteCollector(t *testing.T) {
|
||||
feature := features.New("Host OS Remote Collector Test").
|
||||
Assess("run support bundle command successfully", func(ctx context.Context, t *testing.T, c *envconf.Config) context.Context {
|
||||
var out bytes.Buffer
|
||||
supportbundleName := "host-os-remote-collector"
|
||||
cmd := exec.CommandContext(ctx, sbBinary(), "spec/remoteHostCollectors.yaml", "--interactive=false", fmt.Sprintf("-o=%s", supportbundleName))
|
||||
cmd.Stdout = &out
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to run the binary: %v", err)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
err := os.Remove(fmt.Sprintf("%s.tar.gz", supportbundleName))
|
||||
if err != nil {
|
||||
t.Fatalf("Error removing file: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
// At this point, we only care that the binary ran successfully, no need to check folder contents.
|
||||
t.Logf("Binary executed successfully: %s", out.String())
|
||||
|
||||
return ctx
|
||||
}).Feature()
|
||||
|
||||
testenv.Test(t, feature)
|
||||
}
|
||||
@@ -2,7 +2,7 @@ apiVersion: troubleshoot.sh/v1beta2
|
||||
kind: SupportBundle
|
||||
metadata:
|
||||
name: sb
|
||||
runHostCollectorsInPod: true # default is false
|
||||
spec:
|
||||
runHostCollectorsInPod: true
|
||||
hostCollectors:
|
||||
- hostOS: {}
|
||||
|
||||
34
test/e2e/support-bundle/spec/remoteHostCollectors.yaml
Normal file
34
test/e2e/support-bundle/spec/remoteHostCollectors.yaml
Normal file
@@ -0,0 +1,34 @@
|
||||
apiVersion: troubleshoot.sh/v1beta2
|
||||
kind: SupportBundle
|
||||
metadata:
|
||||
name: "remote-host-collectors"
|
||||
spec:
|
||||
runHostCollectorsInPod: true
|
||||
hostCollectors:
|
||||
- ipv4Interfaces: {}
|
||||
- hostServices: {}
|
||||
- cpu: {}
|
||||
- hostOS: {}
|
||||
- memory: {}
|
||||
- blockDevices: {}
|
||||
- kernelConfigs: {}
|
||||
- copy:
|
||||
collectorName: etc-resolv
|
||||
path: /etc/resolv.conf
|
||||
- dns:
|
||||
collectorName: replicated-app-resolve
|
||||
hostnames:
|
||||
- replicated.app
|
||||
- diskUsage:
|
||||
collectorName: root-disk-usage
|
||||
path: /
|
||||
- diskUsage:
|
||||
collectorName: tmp
|
||||
path: /tmp
|
||||
- http:
|
||||
collectorName: get-replicated-app
|
||||
get:
|
||||
url: https://replicated.app
|
||||
- run:
|
||||
collectorName: uptime
|
||||
command: uptime
|
||||
Reference in New Issue
Block a user