Skip to content

Commit 62445f9

Browse files
authored
Run Maelstrom in CI (oxia-db#336)
1 parent d5f91e6 commit 62445f9

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

.github/workflows/pr_build_and_test.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ concurrency:
2626
group: ${{ github.workflow }}-${{ github.ref }}
2727
cancel-in-progress: true
2828

29+
env:
30+
MAELSTROM_VERSION: "0.2.3"
31+
2932
jobs:
3033

3134
build:
@@ -108,3 +111,45 @@ jobs:
108111
run: kubectl -n oxia logs -l app.kubernetes.io/component=coordinator
109112
- name: Print perf logs
110113
run: kubectl -n oxia logs perf
114+
115+
maelstrom:
116+
name: Maelstrom
117+
runs-on: ubuntu-latest
118+
steps:
119+
- uses: actions/checkout@v3
120+
121+
- name: Set up Go
122+
uses: actions/setup-go@v3
123+
with:
124+
go-version: 1.19
125+
126+
- name: Set up JDK 17
127+
uses: actions/setup-java@v3
128+
with:
129+
distribution: temurin
130+
java-version: 17
131+
132+
- name: Install Gnuplot
133+
run: |
134+
sudo apt-get install -y gnuplot
135+
136+
- run: make
137+
- run: make maelstrom
138+
139+
- name: Download Maelstrom
140+
run: |
141+
curl -O -L https://github.com/jepsen-io/maelstrom/releases/download/v${MAELSTROM_VERSION}/maelstrom.tar.bz2
142+
tar xf maelstrom.tar.bz2
143+
144+
- name: Run Maelstrom test
145+
run: |
146+
cd maelstrom
147+
./maelstrom test -w lin-kv --bin ../bin/oxia-maelstrom \
148+
--time-limit 60 --concurrency 2n --latency 10 --latency-dist uniform
149+
150+
- name: Upload test results
151+
uses: actions/upload-artifact@v3
152+
if: failure()
153+
with:
154+
name: maelstrom-result
155+
path: maelstrom/store

maelstrom/main.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package main
1717
import (
1818
"bufio"
1919
"fmt"
20+
"github.com/pkg/errors"
2021
"github.com/rs/zerolog"
2122
"github.com/rs/zerolog/log"
2223
"github.com/spf13/cobra"
@@ -64,6 +65,16 @@ var thisNode string
6465
var allNodes []string
6566

6667
func handleInit(scanner *bufio.Scanner) {
68+
for {
69+
if err := receiveInit(scanner); err != nil {
70+
continue
71+
}
72+
73+
return
74+
}
75+
}
76+
77+
func receiveInit(scanner *bufio.Scanner) error {
6778
if !scanner.Scan() {
6879
log.Fatal().Msg("no init received")
6980
}
@@ -72,7 +83,9 @@ func handleInit(scanner *bufio.Scanner) {
7283
log.Info().RawJSON("line", []byte(line)).Msg("Got line")
7384
reqType, req, _ := parseRequest(line)
7485
if reqType != MsgTypeInit {
75-
log.Fatal().Msg("unexpected request")
86+
log.Error().Interface("req", req).
87+
Msg("Unexpected request while waiting for init")
88+
return errors.New("invalid message type")
7689
}
7790

7891
init := req.(*Message[Init])
@@ -94,6 +107,8 @@ func handleInit(scanner *bufio.Scanner) {
94107
InReplyTo: &init.Body.MsgId,
95108
}},
96109
})
110+
111+
return nil
97112
}
98113

99114
func main() {

0 commit comments

Comments
 (0)