Skip to content

Commit

Permalink
Merge branch 'engineering-66-current-naming' of https://github.com/ru…
Browse files Browse the repository at this point in the history
…myantseva/FerretDB into engineering-66-current-naming
  • Loading branch information
rumyantseva committed Jun 9, 2023
2 parents cf0a451 + fe271d4 commit 1e8cfd7
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 273 deletions.
1 change: 0 additions & 1 deletion .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
codecov:
require_ci_to_pass: true
notify:
after_n_builds: 2 # 1 for unit tests + at least 1 for integration tests
wait_for_ci: true

# https://docs.codecov.com/docs/coverage-configuration
Expand Down
26 changes: 15 additions & 11 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ jobs:
git diff --exit-code
integration:
name: Integration ${{ matrix.name }}
name: Integration ${{ matrix.name }} ${{ matrix.shard_index }}/${{ matrix.shard_total }}
runs-on:
group: paid
timeout-minutes: 45
timeout-minutes: 20

# Do not run this job in parallel for any PR change or branch/tag push
# to save some resources.
concurrency:
group: ${{ github.workflow }}-${{ matrix.name }}-${{ github.head_ref || github.ref_name }}
group: ${{ github.workflow }}-${{ matrix.name }}-${{ matrix.shard_index }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

if: github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'not ready')
Expand All @@ -158,9 +158,13 @@ jobs:
fail-fast: false
matrix:
include:
- { name: "MongoDB", task: "mongodb" }
- { name: "PostgreSQL", task: "pg" }
- { name: "SQLite", task: "sqlite" }
- { name: "MongoDB", task: "mongodb", shard_index: 1, shard_total: 1 }
- { name: "PostgreSQL", task: "pg", shard_index: 1, shard_total: 3 }
- { name: "PostgreSQL", task: "pg", shard_index: 2, shard_total: 3 }
- { name: "PostgreSQL", task: "pg", shard_index: 3, shard_total: 3 }
- { name: "SQLite", task: "sqlite", shard_index: 1, shard_total: 3 }
- { name: "SQLite", task: "sqlite", shard_index: 2, shard_total: 3 }
- { name: "SQLite", task: "sqlite", shard_index: 3, shard_total: 3 }

steps:
- name: Checkout code
Expand All @@ -187,8 +191,8 @@ jobs:
- name: Wait for and setup environment
run: bin/task env-setup

- name: Run ${{ matrix.task }} tests
run: bin/task test-integration-${{ matrix.task }}
- name: Run ${{ matrix.name }} tests (${{ matrix.shard_index }}/${{ matrix.shard_total }})
run: bin/task test-integration-${{ matrix.task }} SHARD_INDEX=${{ matrix.shard_index }} SHARD_TOTAL=${{ matrix.shard_total }}

# The token is not required but should make uploads more stable.
# If secrets are unavailable (for example, for a pull request from a fork), it fallbacks to the tokenless uploads.
Expand All @@ -202,15 +206,15 @@ jobs:
with:
token: 22159d7c-856d-4fe9-8fdb-5d9ecff35514
files: ./integration/integration-${{ matrix.task }}.txt
flags: integration,${{ matrix.task }}
flags: integration,${{ matrix.task }},shard-${{ matrix.shard_index }}
fail_ci_if_error: true
verbose: true

- name: Upload coverage information to coveralls
uses: coverallsapp/github-action@v2
with:
file: ./integration/integration-${{ matrix.task }}.txt
flag-name: integration-${{ matrix.task }}
flag-name: integration-${{ matrix.task }}-${{ matrix.shard_index }}
parallel: true

# we don't want them on CI
Expand All @@ -229,7 +233,7 @@ jobs:
runs-on: ubuntu-22.04

needs: [test, integration]
if: github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'not ready')
if: always() && (github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'not ready'))

steps:
- name: Submit coveralls
Expand Down
25 changes: 20 additions & 5 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,58 +189,73 @@ tasks:
dir: integration
cmds:
- >
go test -count=1 -timeout={{.INTEGRATIONTIME}} {{.RACEFLAG}} -tags={{.BUILDTAGS}} -shuffle=on -coverpkg=../...
go test -count=1 -run='{{.RUN}}' -timeout={{.INTEGRATIONTIME}} {{.RACEFLAG}} -tags={{.BUILDTAGS}} -shuffle=on -coverpkg=../...
-coverprofile=integration-pg.txt .
-target-backend=ferretdb-pg
-target-tls
-postgresql-url=postgres://username@127.0.0.1:5432/ferretdb
-compat-url='mongodb://username:password@127.0.0.1:47018/?tls=true&tlsCertificateKeyFile=../build/certs/client.pem&tlsCaFile=../build/certs/rootCA-cert.pem'
vars:
RUN:
sh: go run -C .. ./cmd/envtool tests shard --index={{.SHARD_INDEX | default 1}} --total={{.SHARD_TOTAL | default 1}}

test-integration-sqlite:
desc: "Run integration tests for `sqlite` handler"
dir: integration
cmds:
- >
go test -count=1 -timeout={{.INTEGRATIONTIME}} {{.RACEFLAG}} -tags={{.BUILDTAGS}} -shuffle=on -coverpkg=../...
go test -count=1 -run='{{.RUN}}' -timeout={{.INTEGRATIONTIME}} {{.RACEFLAG}} -tags={{.BUILDTAGS}} -shuffle=on -coverpkg=../...
-coverprofile=integration-sqlite.txt .
-target-backend=ferretdb-sqlite
-target-tls
-compat-url='mongodb://username:password@127.0.0.1:47018/?tls=true&tlsCertificateKeyFile=../build/certs/client.pem&tlsCaFile=../build/certs/rootCA-cert.pem'
-disable-filter-pushdown
vars:
RUN:
sh: go run -C .. ./cmd/envtool tests shard --index={{.SHARD_INDEX | default 1}} --total={{.SHARD_TOTAL | default 1}}

test-integration-tigris:
desc: "Run integration tests for `tigris` handler"
dir: integration
cmds:
- >
go test -count=1 -timeout={{.INTEGRATIONTIME}} {{.RACEFLAG}} -tags={{.BUILDTAGS}} -shuffle=on -coverpkg=../...
go test -count=1 -run='{{.RUN}}' -timeout={{.INTEGRATIONTIME}} {{.RACEFLAG}} -tags={{.BUILDTAGS}} -shuffle=on -coverpkg=../...
-coverprofile=integration-tigris.txt .
-target-backend=ferretdb-tigris
{{.UNIXSOCKETFLAG}}
-tigris-urls=127.0.0.1:8081,127.0.0.1:8091,127.0.0.1:8092,127.0.0.1:8093,127.0.0.1:8094
-compat-url=mongodb://127.0.0.1:47017/
vars:
RUN:
sh: go run -C .. ./cmd/envtool tests shard --index={{.SHARD_INDEX | default 1}} --total={{.SHARD_TOTAL | default 1}}

test-integration-hana:
desc: "Run integration tests for `hana` handler"
dir: integration
cmds:
- >
go test -count=1 -timeout={{.INTEGRATIONTIME}} {{.RACEFLAG}} -tags={{.BUILDTAGS}} -shuffle=on -coverpkg=../...
go test -count=1 -run='{{.RUN}}' -timeout={{.INTEGRATIONTIME}} {{.RACEFLAG}} -tags={{.BUILDTAGS}} -shuffle=on -coverpkg=../...
-coverprofile=integration-hana.txt .
-target-backend=ferretdb-hana
{{.UNIXSOCKETFLAG}}
-hana-url=$FERRETDB_HANA_URL
-compat-url=mongodb://127.0.0.1:47017/
vars:
RUN:
sh: go run -C .. ./cmd/envtool tests shard --index={{.SHARD_INDEX | default 1}} --total={{.SHARD_TOTAL | default 1}}

test-integration-mongodb:
desc: "Run integration tests for MongoDB"
dir: integration
cmds:
- >
go test -count=1 -timeout={{.INTEGRATIONTIME}} {{.RACEFLAG}} -tags={{.BUILDTAGS}} -shuffle=on -coverpkg=../...
go test -count=1 -run='{{.RUN}}' -timeout={{.INTEGRATIONTIME}} {{.RACEFLAG}} -tags={{.BUILDTAGS}} -shuffle=on -coverpkg=../...
-coverprofile=integration-mongodb.txt .
-target-url=mongodb://127.0.0.1:47017/
-target-backend=mongodb
vars:
RUN:
sh: go run -C .. ./cmd/envtool tests shard --index={{.SHARD_INDEX | default 1}} --total={{.SHARD_TOTAL | default 1}}

bench-unit-short:
desc: "Benchmark internal package for about 25 seconds (with default BENCHTIME)"
Expand Down
24 changes: 12 additions & 12 deletions cmd/envtool/envtool.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ func printDiagnosticData(setupError error, logger *zap.SugaredLogger) {
})
}

// mkdir creates all directories from given paths.
func mkdir(paths ...string) error {
// shellMkDir creates all directories from given paths.
func shellMkDir(paths ...string) error {
var errs error

for _, path := range paths {
Expand All @@ -342,8 +342,8 @@ func mkdir(paths ...string) error {
return errs
}

// rmdir removes all directories from given paths.
func rmdir(paths ...string) error {
// shellRmDir removes all directories from given paths.
func shellRmDir(paths ...string) error {
var errs error

for _, path := range paths {
Expand All @@ -355,8 +355,8 @@ func rmdir(paths ...string) error {
return errs
}

// read will show the content of a file.
func read(w io.Writer, paths ...string) error {
// shellRead will show the content of a file.
func shellRead(w io.Writer, paths ...string) error {
for _, path := range paths {
b, err := os.ReadFile(path)
if err != nil {
Expand Down Expand Up @@ -403,8 +403,8 @@ var cli struct {
PackageVersion struct{} `cmd:"" help:"Print package version"`
Tests struct {
Shard struct {
Index uint `required:""`
Total uint `help:"Total number of shards" required:""`
Index uint `help:"Shard index, starting from 1" required:""`
Total uint `help:"Total number of shards" required:""`
} `cmd:"" help:"Print sharded integration tests"`
} `cmd:""`
}
Expand Down Expand Up @@ -434,15 +434,15 @@ func main() {
case "setup":
err = setup(ctx, logger)
case "shell mkdir <path>":
err = mkdir(cli.Shell.Mkdir.Paths...)
err = shellMkDir(cli.Shell.Mkdir.Paths...)
case "shell rmdir <path>":
err = rmdir(cli.Shell.Rmdir.Paths...)
err = shellRmDir(cli.Shell.Rmdir.Paths...)
case "shell read <path>":
err = read(os.Stdout, cli.Shell.Read.Paths...)
err = shellRead(os.Stdout, cli.Shell.Read.Paths...)
case "package-version":
err = packageVersion(os.Stdout, versionFile)
case "tests shard":
err = shardIntegrationTests(os.Stdout, cli.Tests.Shard.Index, cli.Tests.Shard.Total)
err = testsShard(os.Stdout, cli.Tests.Shard.Index, cli.Tests.Shard.Total)
default:
err = fmt.Errorf("unknown command: %s", cmd)
}
Expand Down
22 changes: 10 additions & 12 deletions cmd/envtool/envtool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,32 @@ func TestPrintDiagnosticData(t *testing.T) {
})
}

func TestRmdirAbsentDir(t *testing.T) {
func TestShellMkDirRmDir(t *testing.T) {
t.Parallel()

err := rmdir("absent")
assert.NoError(t, err)
}

func TestMkdirAndRmdir(t *testing.T) {
t.Parallel()
t.Run("Absent", func(t *testing.T) {
err := shellRmDir("absent")
assert.NoError(t, err)
})

paths := []string{"ab/c", "ab"}

err := mkdir(paths...)
err := shellMkDir(paths...)
assert.NoError(t, err)

for _, path := range paths {
assert.DirExists(t, path)
}

err = rmdir(paths...)
err = shellRmDir(paths...)
assert.NoError(t, err)

for _, path := range paths {
assert.NoDirExists(t, path)
}
}

func TestRead(t *testing.T) {
func TestShellRead(t *testing.T) {
t.Parallel()

f, err := os.CreateTemp("", "test_read")
Expand All @@ -71,12 +69,12 @@ func TestRead(t *testing.T) {
assert.NoError(t, err)

var output bytes.Buffer
err = read(&output, f.Name())
err = shellRead(&output, f.Name())
assert.NoError(t, err)
assert.Equal(t, s, output.String())
}

func TestPrintVersion(t *testing.T) {
func TestPackageVersion(t *testing.T) {
t.Parallel()

f, err := os.CreateTemp("", "test_print_version")
Expand Down
Loading

0 comments on commit 1e8cfd7

Please sign in to comment.