Skip to content

Commit 672da94

Browse files
Merge pull request #1005 from tgnottingham/sqlite-postgres-converters
Add database conversion scripts
2 parents 2390e26 + 7566cda commit 672da94

File tree

8 files changed

+1755
-468
lines changed

8 files changed

+1755
-468
lines changed

.github/workflows/ci.yml

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ jobs:
131131
- name: Check benchmarks
132132
run: sh -x -c "ci/check-profiling.sh"
133133

134-
database-check-postgres:
135-
name: Database Check (postgres)
134+
database-check:
135+
name: Database Check
136136
runs-on: ubuntu-latest
137137
services:
138138
postgres:
@@ -156,27 +156,48 @@ jobs:
156156
with:
157157
toolchain: stable
158158

159+
- name: Build site
160+
run: cargo build --bin site
161+
159162
- name: Connect to PostgreSQL
160163
run: |
161-
cargo build --bin site
162164
timeout 5s ./target/debug/site 'postgresql://postgres:postgres@localhost:5432/postgres' 2>&1 | tee -a log || true
163165
grep -Fxq "Loading complete but no data identified; exiting." log
164166
165-
database-check-sqlite:
166-
name: Database Check (sqlite)
167-
runs-on: ubuntu-latest
168-
169-
steps:
170-
- name: Check out repository code
171-
uses: actions/checkout@v2
172-
173-
- name: Install stable
174-
uses: actions-rs/toolchain@v1
175-
with:
176-
toolchain: stable
177-
178167
- name: Connect to SQLite
179168
run: |
180-
cargo build --bin site
181169
timeout 5s ./target/debug/site 2>&1 | tee -a log || true
182170
grep -Fxq "Loading complete but no data identified; exiting." log
171+
172+
- name: Build Postgres to SQLite exporter
173+
run: cargo build --bin postgres-to-sqlite
174+
175+
- name: Export empty Postgres DB to SQLite
176+
run: ./target/debug/postgres-to-sqlite 'postgresql://postgres:postgres@localhost:5432/postgres' "$(mktemp)"
177+
178+
- name: Export empty Postgres DB to SQLite with date filter
179+
run: ./target/debug/postgres-to-sqlite --since-weeks-ago=1 'postgresql://postgres:postgres@localhost:5432/postgres' "$(mktemp)"
180+
181+
- name: Build SQLite to Postgres exporter
182+
run: cargo build --bin sqlite-to-postgres
183+
184+
- name: Export empty SQLite DB to Postgres
185+
run: ./target/debug/sqlite-to-postgres "$(mktemp)" 'postgresql://postgres:postgres@localhost:5432/postgres'
186+
187+
- name: Roundtrip export
188+
run: |
189+
sudo apt-get update
190+
sudo apt-get install -y wget python3-snappy sqlite3
191+
192+
wget -q 'http://perf-data.rust-lang.org/export.db.sz'
193+
python3 -m snappy -d export.db.sz > before.db
194+
195+
./target/debug/sqlite-to-postgres before.db 'postgresql://postgres:postgres@localhost:5432/postgres'
196+
sqlite3 before.db .dump > before.dump
197+
198+
rm before.db
199+
200+
./target/debug/postgres-to-sqlite 'postgresql://postgres:postgres@localhost:5432/postgres' after.db
201+
sqlite3 after.db .dump > after.dump
202+
203+
diff -w before.dump after.dump

Cargo.lock

Lines changed: 43 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ COPY ./database ./database
2424
COPY ./intern ./intern
2525

2626
RUN bash -c 'source $HOME/.cargo/env && cargo build --release -p site'
27-
RUN bash -c 'source $HOME/.cargo/env && cargo build --release --bin export-to-sqlite'
27+
RUN bash -c 'source $HOME/.cargo/env && cargo build --release --bin postgres-to-sqlite'
2828

2929
FROM ubuntu:20.04 as binary
3030

3131
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
3232
ca-certificates \
3333
git
3434

35-
COPY --from=build /target/release/export-to-sqlite /usr/local/bin/rustc-perf-export-to-sqlite
35+
COPY --from=build /target/release/postgres-to-sqlite /usr/local/bin/rustc-perf-postgres-to-sqlite
3636
COPY --from=build /target/release/site /usr/local/bin/rustc-perf-site
3737
COPY --from=build site/static /site/static
3838

database/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ async-trait = "0.1"
1515
tokio = { version = "1.6", features = ["sync", "macros"] }
1616
snap = "1"
1717
intern = { path = "../intern" }
18-
chrono = "0.4"
18+
chrono = { version = "0.4", features = ["serde"] }
1919
reqwest = { version = "0.11", features = ["blocking"] }
2020
postgres-native-tls = "0.5"
2121
native-tls = "0.2"
2222
lazy_static = "1"
2323
env_logger = "0.8"
2424
futures = "0.3.5"
2525
log = "0.4"
26+
bytes = "1"
27+
csv = "1"
28+
clap = "2.25"

0 commit comments

Comments
 (0)