Skip to content

Commit f7ac27e

Browse files
Merge branch 'PMM-7470_Wrong_IndexStatsCollections_flag' into release-0.20.2
2 parents 6421fe4 + 90e44aa commit f7ac27e

File tree

3 files changed

+43
-6
lines changed

3 files changed

+43
-6
lines changed

.github/workflows/go.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
steps:
4848
- name: Set up Go release
4949
if: matrix.go-version != 'tip'
50-
uses: percona-platform/setup-go@v2.1.1
50+
uses: actions/setup-go@v2
5151
with:
5252
go-version: ${{ matrix.go-version }}
5353

@@ -57,8 +57,8 @@ jobs:
5757
git clone --depth=1 https://go.googlesource.com/go $HOME/gotip
5858
cd $HOME/gotip/src
5959
./make.bash
60-
echo "::set-env name=GOROOT::$HOME/gotip"
61-
echo "::add-path::$HOME/gotip/bin"
60+
echo "GOROOT=$HOME/gotip" >> $GITHUB_ENV
61+
echo "$HOME/gotip/bin" >> $GITHUB_PATH
6262
6363
- name: Check out code into the Go module directory
6464
uses: actions/checkout@v2

main.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package main
1818

1919
import (
2020
"fmt"
21+
"log"
2122
"strings"
2223

2324
"github.com/alecthomas/kong"
@@ -72,6 +73,15 @@ func main() {
7273
return
7374
}
7475

76+
e, err := buildExporter(opts)
77+
if err != nil {
78+
log.Fatal(err)
79+
}
80+
81+
e.Run()
82+
}
83+
84+
func buildExporter(opts GlobalFlags) (*exporter.Exporter, error) {
7585
log := logrus.New()
7686

7787
levels := map[string]logrus.Level{
@@ -95,7 +105,7 @@ func main() {
95105
exporterOpts := &exporter.Opts{
96106
CollStatsCollections: strings.Split(opts.CollStatsCollections, ","),
97107
CompatibleMode: opts.CompatibleMode,
98-
IndexStatsCollections: strings.Split(opts.CollStatsCollections, ","),
108+
IndexStatsCollections: strings.Split(opts.IndexStatsCollections, ","),
99109
Logger: log,
100110
Path: opts.WebTelemetryPath,
101111
URI: opts.URI,
@@ -107,8 +117,8 @@ func main() {
107117

108118
e, err := exporter.New(exporterOpts)
109119
if err != nil {
110-
log.Fatal(err)
120+
return nil, err
111121
}
112122

113-
e.Run()
123+
return e, nil
114124
}

main_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package main
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
func TestBuildExporter(t *testing.T) {
10+
opts := GlobalFlags{
11+
CollStatsCollections: "c1,c2,c3",
12+
IndexStatsCollections: "i1,i2,i3",
13+
URI: "mongodb://usr:[email protected]/",
14+
GlobalConnPool: false, // to avoid testing the connection
15+
WebListenAddress: "localhost:12345",
16+
WebTelemetryPath: "/mymetrics",
17+
LogLevel: "debug",
18+
19+
DisableDiagnosticData: true,
20+
DisableReplicasetStatus: true,
21+
22+
CompatibleMode: true,
23+
}
24+
25+
_, err := buildExporter(opts)
26+
assert.NoError(t, err)
27+
}

0 commit comments

Comments
 (0)