forked from cashapp/spirit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for running tests with docker-compose
TODO: 1. Tests with replicas 2. Docs (holding off docs till support is complete) See also: cashapp#187
- Loading branch information
Showing
11 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: MySQL 8.0 Build and Run /w docker-compose | ||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build and Run Spirit | ||
run: docker compose -f docker/compose.yml -f docker/buildandrun.yml up --abort-on-container-exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: MySQL 8.0.28 (Aurora version) /w docker-compose | ||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Test | ||
run: docker compose -f docker/compose.yml -f docker/8.0.28.yml -f docker/test.yml up --abort-on-container-exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: MySQL 8.0.33 (RBR minimal) /w docker-compose | ||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Test | ||
run: docker compose -f docker/compose.yml -f docker/8.0.33-rbr-minimal.yml -f docker/test.yml up --abort-on-container-exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM golang:1.22 | ||
|
||
WORKDIR /app | ||
COPY ../go.mod go.sum ./ | ||
RUN go mod download | ||
COPY .. . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env sh | ||
set -e | ||
|
||
go build ./cmd/spirit | ||
./spirit --host "mysql:3306" --database=test --table=t1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
services: | ||
mysql: | ||
image: mysql:8.0.28 | ||
platform: linux/amd64 | ||
ports: [ '8028:3306' ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
services: | ||
mysql: | ||
ports: [ '8333:3306' ] | ||
command: --binlog-row-image=MINIMAL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use mysql; | ||
set password='msandbox'; | ||
|
||
create role if not exists R_DO_IT_ALL; | ||
grant all on *.* to R_DO_IT_ALL; | ||
create user if not exists msandbox@'%' identified by 'msandbox'; | ||
|
||
grant R_DO_IT_ALL to msandbox@'%' ; | ||
set default role R_DO_IT_ALL to msandbox@'%'; | ||
|
||
create schema if not exists test; | ||
|
||
create table if not exists test.t1 | ||
( | ||
id int not null primary key auto_increment, | ||
b int not null, | ||
c int not null | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
services: | ||
buildandrun: | ||
build: | ||
context: ../. | ||
dockerfile: Dockerfile | ||
command: ./buildandrun.sh | ||
depends_on: | ||
mysql: | ||
condition: service_healthy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
services: | ||
mysql: | ||
image: mysql:8.0.33 | ||
ports: [ '8033:3306' ] | ||
# to supress mbind: Operation not permitted in CI | ||
# https://stackoverflow.com/a/55706057 | ||
cap_add: | ||
- SYS_NICE | ||
environment: | ||
MYSQL_ROOT_PASSWORD: msandbox | ||
MYSQL_USER: msandbox | ||
MYSQL_PASSWORD: msandbox | ||
MYSQL_DATABASE: test | ||
healthcheck: | ||
test: mysqladmin ping -h 127.0.0.1 -u $$MYSQL_USER --password=$$MYSQL_PASSWORD | ||
start_period: 1s | ||
interval: 1s | ||
timeout: 2s | ||
retries: 60 | ||
volumes: | ||
- ./bootstrap.sql:/docker-entrypoint-initdb.d/bootstrap.sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
services: | ||
test: | ||
build: | ||
context: ../ | ||
dockerfile: Dockerfile | ||
command: go test -race -v ./... | ||
depends_on: | ||
mysql: | ||
condition: service_healthy | ||
environment: | ||
MYSQL_DSN: msandbox:msandbox@tcp(mysql)/test |