Skip to content

Commit dbb6a7d

Browse files
authored
Add mongo-core-test (#1206)
1 parent 256c742 commit dbb6a7d

9 files changed

Lines changed: 63 additions & 25 deletions

File tree

.github/workflows/dance.yml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,21 @@ jobs:
4343
strategy:
4444
fail-fast: false
4545
matrix:
46-
config:
47-
- dotnet-example
48-
- java-example
49-
- nodejs-example
50-
- python-example
51-
52-
- mongo-tools
53-
54-
- ycsb-workloada
55-
- ycsb-workloada2
56-
- ycsb-workloadb
57-
- ycsb-workloadb2
58-
- ycsb-workloadc
59-
- ycsb-workloadc2
46+
include:
47+
- { config: dotnet-example }
48+
- { config: java-example }
49+
- { config: nodejs-example }
50+
- { config: python-example }
51+
52+
- { config: mongo-tools }
53+
- { config: mongo-core-test, verbose: true } # verbose to view test output on CI
54+
55+
- { config: ycsb-workloada }
56+
- { config: ycsb-workloada2 }
57+
- { config: ycsb-workloadb }
58+
- { config: ycsb-workloadb2 }
59+
- { config: ycsb-workloadc }
60+
- { config: ycsb-workloadc2 }
6061

6162
steps:
6263
- name: Install Tailscale
@@ -95,7 +96,7 @@ jobs:
9596
run: bin/task init build
9697

9798
- name: Dance!
98-
run: bin/task dance CONFIG=${{ matrix.config }}.yml
99+
run: bin/task dance CONFIG=${{ matrix.config }}.yml VERBOSE_FLAG=${{ matrix.verbose || 'false' }}
99100
env:
100101
DANCE_PUSH: ${{ secrets.DANCE_PUSH }}
101102

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
branch = master
3131
[submodule "mongo-core-test"]
3232
path = projects/mongo-core-test
33-
url = https://github.com/mongodb-developer/mongo-core-test.git
33+
url = https://github.com/FerretDB/mongo-core-test.git
3434
branch = main
3535

3636
[submodule "enmeshed-runtime"]

Taskfile.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ vars:
55
DB: ""
66
CONFIG: ""
77
RACE_FLAG: -race={{and (ne OS "windows") (ne ARCH "arm") (ne ARCH "riscv64")}}
8+
VERBOSE_FLAG: false
89

910
tasks:
1011
init-tools:
@@ -86,7 +87,7 @@ tasks:
8687
deps: [build]
8788
dir: projects
8889
cmds:
89-
- ../bin/dance --database={{.DB}} {{.CONFIG}}
90+
- ../bin/dance --verbose={{.VERBOSE_FLAG}} --database={{.DB}} {{.CONFIG}}
9091

9192
lint:
9293
desc: "Run linters"

internal/configload/configload.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ func templateData(uri url.URL) (map[string]any, error) {
122122
"MONGODB_URI_SHA1": sha1URI.String(),
123123
"MONGODB_URI_SHA256": sha256URI.String(),
124124
"MONGODB_URI_DOCKER_HOST": dockerHostURI.String(),
125+
"MONGODB_PORT": port,
125126
}, nil
126127
}
127128

internal/configload/runner.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ type runnerParams interface {
2929

3030
// runnerParamsCommand represents `command` runner parameters in the project configuration YAML file.
3131
type runnerParamsCommand struct {
32-
Dir string `yaml:"dir"`
33-
Setup string `yaml:"setup"`
34-
Tests []struct {
32+
Dir string `yaml:"dir"`
33+
Setup string `yaml:"setup"`
34+
Teardown string `yaml:"teardown"`
35+
Tests []struct {
3536
Name string `yaml:"name"`
3637
Cmd string `yaml:"cmd"`
3738
} `yaml:"tests"`
@@ -44,8 +45,9 @@ func (rp *runnerParamsCommand) convert() (config.RunnerParams, error) {
4445
}
4546

4647
res := &config.RunnerParamsCommand{
47-
Dir: rp.Dir,
48-
Setup: rp.Setup,
48+
Dir: rp.Dir,
49+
Setup: rp.Setup,
50+
Teardown: rp.Teardown,
4951
}
5052

5153
for _, t := range rp.Tests {

internal/runner/command/command.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ func (c *command) Run(ctx context.Context) (res map[string]config.TestResult, er
114114
defer func() {
115115
c.l.InfoContext(ctx, "Running teardown")
116116

117-
if b, err = execScript(ctx, c.p.Dir, "teardown", c.p.Teardown, c.verbose); err != nil {
117+
// canceled context should not prevent teardown
118+
if b, err = execScript(context.WithoutCancel(ctx), c.p.Dir, "teardown", c.p.Teardown, c.verbose); err != nil {
118119
err = fmt.Errorf("%s\n%w", b, err)
119120
}
120121
}()

internal/runner/command/command_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ func TestCommand(t *testing.T) {
9393
c, err := New(p, slog.Default(), false)
9494
require.NoError(t, err)
9595

96-
_, err = c.Run(ctx)
96+
canceledCtx, cancel := context.WithCancel(ctx)
97+
98+
cancel()
99+
100+
_, err = c.Run(canceledCtx)
97101
require.ErrorContains(t, err, "exit status 2")
98102
})
99103

projects/mongo-core-test.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
runner: command
3+
params:
4+
dir: mongo-core-test
5+
setup: |
6+
env COMPOSE_FILE='mongo8.yml' TEST_DIRECTORY=$(readlink -f ../mongo/jstests) docker compose up -d legacy-mongo
7+
teardown: |
8+
env COMPOSE_FILE='mongo8.yml' docker compose down legacy-mongo
9+
10+
tests:
11+
- name: noauth
12+
cmd: >
13+
env
14+
COMPOSE_FILE='mongo8.yml'
15+
TEST_DIRECTORY=$(readlink -f ../mongo/jstests)
16+
MONGO_PORT='{{.MONGODB_PORT}}'
17+
MONGO_USERNAME=''
18+
MONGO_PASSWORD=''
19+
python3 run.py 8
20+
21+
results:
22+
mongodb:
23+
stats:
24+
pass: 1
25+
26+
ferretdb2:
27+
stats:
28+
pass: 1

0 commit comments

Comments
 (0)