Skip to content

Commit a52c034

Browse files
Merge pull request #1092 from percona/release-2.9.0
Release 2.9.0
2 parents 0157f87 + 06640a7 commit a52c034

File tree

1,330 files changed

+195517
-24280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,330 files changed

+195517
-24280
lines changed

.github/workflows/ci.yml

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ on:
2525
- "packaging/**"
2626
- "version/**"
2727

28+
push:
29+
branches:
30+
- main
31+
- dev
32+
paths-ignore:
33+
- "e2e-tests/**"
34+
- "packaging/**"
35+
- "version/**"
36+
2837
jobs:
2938
test:
3039
runs-on: ubuntu-latest
@@ -35,10 +44,10 @@ jobs:
3544
psmdb: ["6.0", "7.0", "8.0"]
3645
test: [logical, physical, incremental, external]
3746
env:
38-
PBM_BRANCH: ${{ github.event.inputs.pbm_branch || 'main' }}
47+
PBM_BRANCH: ${{ github.event.inputs.pbm_branch || github.ref_name }}
3948
GO_VER: ${{ github.event.inputs.go_ver || '1.22-bullseye' }}
4049
PR_NUMBER: ${{ github.event.number|| github.event.inputs.pr_ver }}
41-
50+
MAKE_TARGET: 'build-cover'
4251
steps:
4352
- name: Checkout testing repo
4453
uses: actions/checkout@v4
@@ -58,8 +67,50 @@ jobs:
5867
docker compose run test pytest -s --junitxml=junit.xml -k ${{ matrix.test }}
5968
working-directory: psmdb-testing/pbm-functional/pytest
6069

70+
- name: Fetch coverage files
71+
run: |
72+
docker compose run --rm golang_reports cp -r /gocoverdir/reports /test
73+
sudo chmod -R 777 reports
74+
working-directory: psmdb-testing/pbm-functional/pytest
75+
if: success() || failure()
76+
77+
- name: Upload coverage reports
78+
uses: actions/upload-artifact@v4
79+
with:
80+
name: reports-${{ matrix.test }}-${{ matrix.psmdb }}
81+
path: psmdb-testing/pbm-functional/pytest/reports/
82+
if: success() || failure()
83+
6184
- name: Publish Test Report
6285
uses: mikepenz/action-junit-report@v4
6386
if: success() || failure()
6487
with:
6588
report_paths: "**/junit.xml"
89+
90+
coverage:
91+
if: ${{ always() }}
92+
needs: test
93+
runs-on: ubuntu-latest
94+
steps:
95+
- uses: actions/checkout@v4
96+
- name: Set up Go
97+
uses: actions/setup-go@v5
98+
with:
99+
go-version-file: 'go.mod'
100+
check-latest: true
101+
- name: Download all coverage reports
102+
uses: actions/download-artifact@v4
103+
with:
104+
path: reports
105+
pattern: reports-*
106+
merge-multiple: true
107+
- name: Merge coverage reports
108+
run: |
109+
go tool covdata textfmt -i=./reports -o ./coverage.txt
110+
- name: Upload coverage to Codecov
111+
uses: codecov/codecov-action@v3
112+
with:
113+
files: ./coverage.txt
114+
flags: integration
115+
fail_ci_if_error: false
116+
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/codecov.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ name: 'codecov'
33
on:
44
push:
55
branches:
6+
- main
7+
- dev
8+
pull_request:
9+
branches:
10+
- main
611
- dev
712

813
jobs:
@@ -21,5 +26,6 @@ jobs:
2126
uses: codecov/codecov-action@v4
2227
with:
2328
file: cover.out
29+
flags: unittests
2430
fail_ci_if_error: false
2531
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/reviewdog.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,6 @@
11
name: reviewdog
22
on: [pull_request]
33
jobs:
4-
go-test:
5-
name: runner / go-test
6-
runs-on: ubuntu-latest
7-
steps:
8-
- uses: actions/checkout@v4
9-
- uses: actions/setup-go@v4
10-
with:
11-
go-version: "1.22"
12-
- name: test
13-
run: go test -v ./... -covermode=atomic -coverprofile=cover.out
14-
15-
- name: upload coverage report
16-
uses: codecov/codecov-action@v4
17-
with:
18-
file: cover.out
19-
fail_ci_if_error: false
20-
token: ${{ secrets.CODECOV_TOKEN }}
21-
224
shellcheck:
235
name: runner / shellcheck
246
runs-on: ubuntu-latest

cmd/pbm-agent/commands_test.go

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package main
2+
3+
import (
4+
"bytes"
5+
"os"
6+
"strings"
7+
"testing"
8+
9+
"github.com/spf13/cobra"
10+
11+
"github.com/percona/percona-backup-mongodb/pbm/version"
12+
)
13+
14+
func TestRootCmd_NoArgs(t *testing.T) {
15+
rootCmd, _ := setupTestCmd()
16+
err := rootCmd.Execute()
17+
if err == nil || !strings.Contains(err.Error(), "required flag mongodb-uri") {
18+
t.Fatal(err)
19+
}
20+
}
21+
22+
func TestRootCmd_Config(t *testing.T) {
23+
tmpConfig, cleanup := createTempConfigFile(`
24+
log:
25+
path: "/dev/stderr"
26+
level: "D"
27+
json: false
28+
`)
29+
defer cleanup()
30+
31+
rootCmd, _ := setupTestCmd("--config", tmpConfig)
32+
err := rootCmd.Execute()
33+
if err == nil || !strings.Contains(err.Error(), "required flag mongodb-uri") {
34+
t.Fatal(err)
35+
}
36+
}
37+
38+
func createTempConfigFile(content string) (string, func()) {
39+
temp, _ := os.CreateTemp("", "test-config-*.yaml")
40+
41+
_, _ = temp.WriteString(content)
42+
_ = temp.Close()
43+
44+
return temp.Name(), func() {
45+
_ = os.Remove(temp.Name())
46+
}
47+
}
48+
49+
func TestVersionCommand_Default(t *testing.T) {
50+
rootCmd, buf := setupTestCmd("version")
51+
err := rootCmd.Execute()
52+
if err != nil {
53+
t.Fatal(err)
54+
}
55+
56+
output := buf.String()
57+
58+
if !strings.Contains(output, "Version:") {
59+
t.Errorf("expected full version info in output, got: %s", output)
60+
}
61+
}
62+
63+
func TestVersionCommand_Short(t *testing.T) {
64+
rootCmd, buf := setupTestCmd("version", "--short")
65+
err := rootCmd.Execute()
66+
if err != nil {
67+
t.Fatal(err)
68+
}
69+
70+
output := buf.String()
71+
72+
if !strings.Contains(output, version.Current().Short()) {
73+
t.Errorf("expected short version info in output, got: %s", output)
74+
}
75+
}
76+
77+
func setupTestCmd(args ...string) (*cobra.Command, *bytes.Buffer) {
78+
cmd := rootCommand()
79+
cmd.AddCommand(versionCommand())
80+
81+
var buf bytes.Buffer
82+
cmd.SetOut(&buf)
83+
cmd.SetErr(&buf)
84+
cmd.SetArgs(args)
85+
86+
return cmd, &buf
87+
}

0 commit comments

Comments
 (0)