mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-05 02:59:44 -06:00
Add ORM Bats testing utilities (#2996)
This commit is contained in:
47
integration-tests/ORMDockerfile
Normal file
47
integration-tests/ORMDockerfile
Normal file
@@ -0,0 +1,47 @@
|
||||
FROM ubuntu:18.04
|
||||
|
||||
# install peewee
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt update -y && \
|
||||
apt install -y \
|
||||
curl \
|
||||
gnupg \
|
||||
software-properties-common && \
|
||||
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
|
||||
apt update -y && \
|
||||
apt install -y \
|
||||
python3.8 \
|
||||
python3-pip \
|
||||
git \
|
||||
mysql-client \
|
||||
libmysqlclient-dev \
|
||||
bats && \
|
||||
update-ca-certificates -f
|
||||
|
||||
# install go
|
||||
WORKDIR /root
|
||||
ENV GO_VERSION=1.17.1
|
||||
ENV GOPATH=$HOME/go
|
||||
ENV PATH=$PATH:$GOPATH/bin
|
||||
ENV PATH=$PATH:$GOPATH/bin:/usr/local/go/bin
|
||||
RUN curl -O "https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz" && \
|
||||
sha256sum "go${GO_VERSION}.linux-amd64.tar.gz" && \
|
||||
tar -xvf "go${GO_VERSION}.linux-amd64.tar.gz" -C /usr/local && \
|
||||
chown -R root:root /usr/local/go && \
|
||||
mkdir -p $HOME/go/{bin,src} && \
|
||||
go version
|
||||
|
||||
# install mysql connector and pymsql
|
||||
RUN pip3 install mysql-connector-python PyMySQL sqlalchemy
|
||||
|
||||
# install dolt from source
|
||||
WORKDIR /root/building
|
||||
COPY ./go .
|
||||
ENV GOFLAGS="-mod=readonly"
|
||||
RUN go build -o /usr/local/bin/dolt ./cmd/dolt
|
||||
|
||||
COPY orm-tests /orm-tests
|
||||
COPY orm-tests/orm-tests-entrypoint.sh /orm-tests/entrypoint.sh
|
||||
|
||||
WORKDIR /orm-tests
|
||||
ENTRYPOINT ["/orm-tests/entrypoint.sh"]
|
||||
26
integration-tests/orm-tests/README.md
Normal file
26
integration-tests/orm-tests/README.md
Normal file
@@ -0,0 +1,26 @@
|
||||
## ORM Client Tests
|
||||
|
||||
Different ORMs come with test packages that run against a standard MySQL database. These
|
||||
tests run an ORM's test suite against Dolt to continously test MySQL
|
||||
capabilities.
|
||||
|
||||
These tests can be run locally using Docker. From the root directory of this
|
||||
repo, run:
|
||||
|
||||
```bash
|
||||
$ docker build -t orm-tests -f ORMDockerfile
|
||||
$ docker run orm-tests:latest
|
||||
```
|
||||
|
||||
Running the containter should produce output like:
|
||||
|
||||
```bash
|
||||
Updating dolt config for tests:
|
||||
Config successfully updated.
|
||||
Config successfully updated.
|
||||
Config successfully updated.
|
||||
Config successfully updated.
|
||||
Running orm-tests:
|
||||
1..1
|
||||
not ok 1 peewee client test
|
||||
```
|
||||
10
integration-tests/orm-tests/orm-tests-entrypoint.sh
Executable file
10
integration-tests/orm-tests/orm-tests-entrypoint.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "Updating dolt config for tests:"
|
||||
dolt config --global --add metrics.disabled true
|
||||
dolt config --global --add metrics.host localhost
|
||||
dolt config --global --add user.name orm-test-runner
|
||||
dolt config --global --add user.email orm-test-runner@liquidata.co
|
||||
|
||||
echo "Running orm-tests:"
|
||||
bats /orm-tests/orm-tests.bats
|
||||
39
integration-tests/orm-tests/orm-tests.bats
Normal file
39
integration-tests/orm-tests/orm-tests.bats
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
setup() {
|
||||
REPO_NAME="dolt_repo_$$"
|
||||
mkdir $REPO_NAME
|
||||
cd $REPO_NAME
|
||||
|
||||
dolt init
|
||||
|
||||
let PORT="$$ % (65536-1024) + 1024"
|
||||
USER="dolt"
|
||||
dolt sql-server --host 0.0.0.0 --port=$PORT --user=$USER --loglevel=trace &
|
||||
SERVER_PID=$!
|
||||
|
||||
# Give the server a chance to start
|
||||
sleep 1
|
||||
|
||||
export MYSQL_PWD=""
|
||||
}
|
||||
|
||||
teardown() {
|
||||
cd ..
|
||||
kill $SERVER_PID
|
||||
rm -rf $REPO_NAME
|
||||
}
|
||||
|
||||
@test "peewee client test" {
|
||||
skip "Dolt does not pass all tests yet"
|
||||
|
||||
# peewee tests require the test database to be named peewee_test
|
||||
mysql -h 0.0.0.0 -u $USER --port=$PORT -e "CREATE DATABASE IF NOT EXISTS peewee_test"
|
||||
|
||||
# Setup and install pewee
|
||||
git clone https://github.com/coleifer/peewee
|
||||
cd peewee
|
||||
|
||||
python3 setup.py install
|
||||
python3 runtests.py -e mysql --mysql-host=0.0.0.0 --mysql-port=$PORT --mysql-user=$USER --mysql-password=""
|
||||
}
|
||||
Reference in New Issue
Block a user