Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

PMM-8308 track process exec path #208

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions commands/summary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ package commands
import (
"archive/zip"
"context"
"encoding/json"
"io/ioutil"
"os"
"path/filepath"
"testing"

"github.com/percona/pmm/api/agentlocalpb"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -97,4 +99,61 @@ func TestSummary(t *testing.T) {

assert.True(t, hasPprofDir)
})

t.Run("Summary - test process_exec_path", func(t *testing.T) {
t.Parallel()
if os.Getenv("DEVCONTAINER") == "" {
t.Skip("can be tested only inside devcontainer")
}

cmd := &summaryCommand{
Filename: filename,
Pprof: false,
SkipServer: true,
}
res, err := cmd.Run()
require.NoError(t, err)
expected := &summaryResult{
Filename: filename,
}

// Check there is a pprof dir with data inside the zip file
reader, err := zip.OpenReader(filename)
assert.NoError(t, err)
assert.Equal(t, expected, res)

hasStatusFile := false
var statusFile *zip.File

for _, file := range reader.File {
if file.Name == "client/status.json" {
statusFile = file
hasStatusFile = true

break
}
}

assert.True(t, hasStatusFile)

jsonFile, err := statusFile.Open()
assert.NoError(t, err)
defer assert.NoError(t, jsonFile.Close())
jsonByteValueFile, _ := ioutil.ReadAll(jsonFile)

var status agentlocalpb.StatusResponse
err = json.Unmarshal(jsonByteValueFile, &status)
assert.NoError(t, err)

agentHasProcessExecPath := false
for _, agentInfo := range status.AgentsInfo {
if agentInfo.ProcessExecPath != "" {
agentHasProcessExecPath = true

break
}
}

assert.True(t, agentHasProcessExecPath)
})
}
12 changes: 11 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/AlekSi/pointer v1.2.0
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d
github.com/go-openapi/runtime v0.23.3
github.com/percona/pmm v0.0.0-20220425171601-f7d00530d1ae
github.com/percona/pmm v0.0.0-20220425124851-849463b9263a
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.7.1
Expand All @@ -30,13 +30,23 @@ require (
github.com/go-openapi/swag v0.21.1 // indirect
github.com/go-openapi/validate v0.21.0 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/mwitkow/go-proto-validators v0.3.2 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
go.mongodb.org/mongo-driver v1.9.0 // indirect
golang.org/x/net v0.0.0-20220412020605-290c469a71a5 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20220414192740-2d67ff6cf2b4 // indirect
google.golang.org/grpc v1.45.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
Loading