Skip to content

Commit 72e476e

Browse files
committed
Test Database Lab
1 parent 7cace86 commit 72e476e

File tree

4 files changed

+77
-0
lines changed

4 files changed

+77
-0
lines changed

test/1.synthetic.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
4+
DIR=${0%/*}
5+
source "${DIR}/_prerequisites.ubuntu.sh"
6+
source "${DIR}/_zfs.file.sh"
7+
8+
sudo docker run \
9+
--name dblab_pg_initdb \
10+
--label dblab_sync \
11+
--env PGDATA=/var/lib/postgresql/pgdata \
12+
--env POSTGRES_HOST_AUTH_METHOD=trust \
13+
--volume /var/lib/dblab/data:/var/lib/postgresql/pgdata \
14+
--detach \
15+
postgres:12-alpine
16+
17+
while true; do
18+
sudo docker exec -it dblab_pg_initdb psql -U postgres -c 'select' && break
19+
sleep 1
20+
done
21+
22+
sudo docker exec -it dblab_pg_initdb psql -U postgres -c 'create database test'
23+
24+
# 1,000,000 accounts, ~0.14 GiB of data.
25+
sudo docker exec -it dblab_pg_initdb pgbench -U postgres -i -s 10 test
26+
27+
sudo docker stop dblab_pg_initdb
28+
sudo docker rm dblab_pg_initdb

test/_cleanup.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
4+
ZFS_FILE="$(pwd)/zfs_file"
5+
6+
sudo docker rm -f dblab_pg_initdb || true
7+
sudo zpool destroy test_pool || true
8+
sudo umount /var/lib/dblab/data || true
9+
sudo rm -f "${ZFS_FILE}"

test/_prerequisites.ubuntu.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
4+
curl --version || sudo apt-get update && sudo apt-get install -y \
5+
apt-transport-https \
6+
ca-certificates \
7+
curl \
8+
gnupg-agent \
9+
software-properties-common
10+
11+
# ZFS
12+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
13+
14+
sudo add-apt-repository \
15+
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
16+
$(lsb_release -cs) \
17+
stable"
18+
19+
docker --version || sudo apt-get update && sudo apt-get install -y \
20+
docker-ce \
21+
docker-ce-cli \
22+
containerd.io \
23+
zfsutils-linux

test/_zfs.file.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
4+
ZFS_FILE="$(pwd)/zfs_file"
5+
6+
truncate --size 1GB "${ZFS_FILE}"
7+
8+
sudo zpool create -f \
9+
-O compression=on \
10+
-O atime=off \
11+
-O recordsize=8k \
12+
-O logbias=throughput \
13+
-m /var/lib/dblab/data \
14+
test_pool \
15+
"${ZFS_FILE}"
16+
17+
zfs list

0 commit comments

Comments
 (0)