Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Syncstorage inital sqlite support #1520

Draft
wants to merge 75 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
f646ddf
style: Rename MysqlError to SqlError as they are generic
Eragonfr Oct 29, 2024
f423a33
refactor: Don't use legacy numerics contant and methods
Eragonfr Oct 29, 2024
af22b24
style: Cargo fmt
Eragonfr Oct 31, 2024
07a816a
style: Keep Mysql specific error in Mysql code
Eragonfr Nov 2, 2024
2637fd4
style: Rename MysqlError to SqlError as they are generic
Eragonfr Oct 29, 2024
7ea1c74
feat: Add sqlite as a storage backend
Eragonfr Mar 10, 2024
5ce2884
feat: Better readme doc for sqlite
Eragonfr Mar 10, 2024
a3dcdfb
refactor: Shorter lines in markdown
Eragonfr Mar 10, 2024
a686396
ci: Add sqlite clippy to CI check
Eragonfr Mar 10, 2024
4bdec19
docs: Use mysql as default example backend
Eragonfr Apr 6, 2024
37b8e48
fix: Add missing Sqlite in Enum
Eragonfr Apr 6, 2024
4b9af62
ci: Ignore libsqlite3-sys RUSTSEC-2022-0090 CVE
Eragonfr May 9, 2024
4cd3ce7
ci: Explain why RUSTSEC-2022-0090 is ignored
Eragonfr May 12, 2024
3e6c01c
refactor: Add shared crate for common code of SQL backends
Eragonfr Jul 5, 2024
62c01c4
refactor: Run cargo fmt
Eragonfr Jul 5, 2024
0df32cd
First attempts at getting SQLite + Docker working
bcspragu Aug 9, 2024
9174625
Seemingly functional SQLite?
bcspragu Aug 9, 2024
487d1aa
Remove vestigial .dockerignore line
bcspragu Aug 9, 2024
8135fe6
Remove unused import
bcspragu Aug 9, 2024
98344e2
fix: Error message should mention sqlite feature flag
Eragonfr Aug 11, 2024
ccfcfd4
ci: Set features for cargo build
Eragonfr Aug 11, 2024
6224499
fix: Incorrect URL for tokenserver db pool init
Eragonfr Aug 15, 2024
08fecd6
Run cargo fmt
Eragonfr Aug 15, 2024
cdbf5ba
ci: Set features for cargo test
Eragonfr Aug 15, 2024
bc3308c
ci: Enable the correct features in dockerfile
Eragonfr Aug 16, 2024
a6954bc
ci: Add sqlite docker & e2e tests
Eragonfr Aug 16, 2024
2baa33d
ci: Fix identation errors
Eragonfr Aug 16, 2024
e80b0cd
Remove editor config file
Eragonfr Aug 16, 2024
97321cb
ci: I hate tab-based configuration files
Eragonfr Aug 16, 2024
10c5acd
ci: Require sqlite e2e for deploy python utils
Eragonfr Aug 16, 2024
3268ef6
fix: Pass some SQLite tests for syncstorage
Eragonfr Sep 9, 2024
f393be5
fix: Revert modifications in Makefile from 2c1b7cf
Eragonfr Sep 9, 2024
24aeee4
fix: Run cargo fmt
Eragonfr Sep 11, 2024
f2a2bba
ci: Rename db for e2e tests
Eragonfr Sep 22, 2024
c9e2a36
fix: test_sqlite need persistence between tests
Eragonfr Sep 22, 2024
120f47c
refactor: Move tokenserver SQL strings into subcrates
Eragonfr Sep 22, 2024
0f91726
refactor: Add fixme to (some) queries
Eragonfr Oct 19, 2024
26e814a
refactor: cargo fmt
Eragonfr Oct 19, 2024
d96db99
style: Better readability with spacing
Eragonfr Oct 29, 2024
0c80393
refactor: Only include error.rs for sql backends.
Eragonfr Oct 29, 2024
af8e97d
fix: Remove static lifetime from &str
Eragonfr Nov 2, 2024
2398821
fix: The cfg check is true if more than one feature is enabled
Eragonfr Nov 2, 2024
3273026
feat: Only allow for one database feature to be used for tokenserver
Eragonfr Nov 2, 2024
e5b2e5a
fix: Table id should be primary key integer
Eragonfr Nov 6, 2024
f677a25
fix: SQLite syntax for some more queries
Eragonfr Nov 6, 2024
8dae1e1
fix: replace GREATEST with MAX
Eragonfr Nov 12, 2024
8773d69
fix: Use REMOVE_NODE_SYNC_QUERY to remove node
Eragonfr Nov 13, 2024
8a915f9
ci: Try to fix SQLite e2e tests by closing the db between each transa…
Eragonfr Nov 13, 2024
75a9a26
feat: Put MySQL and Sqlite test connexions behind flag
Eragonfr Nov 20, 2024
3364a5b
Merge remote-tracking branch 'moz/master' into syncstorage-sqlite
Eragonfr Dec 9, 2024
c8f21bd
test: Try to open/close database before each transaction
Eragonfr Dec 18, 2024
11aa6b7
Revert "test: Try to open/close database before each transaction"
Eragonfr Dec 18, 2024
e929cd8
ci: Minimum allowed time for Pool idle time is 1 sec
Eragonfr Jan 2, 2025
ffd1bd9
ci: Add idle_timeout
Eragonfr Jan 2, 2025
ab6ee22
test: Try to open/close database before each transaction
Eragonfr Dec 18, 2024
ed0e727
ci: Disable connection pooling for e2e tests
Eragonfr Jan 3, 2025
5e8b8ed
feat: Enable WAL mode for SQLite
Eragonfr Feb 12, 2025
2734c54
test: Update unittest
Eragonfr Feb 12, 2025
0706a1e
ci: Set correct URI for sqlite e2e tests
Eragonfr Feb 12, 2025
18ffa79
meta: Add Pipfile to gitignore
Eragonfr Feb 12, 2025
3eb7202
test: Use WAL for SQLite e2e tests
Eragonfr Feb 12, 2025
aecd225
Merge remote-tracking branch 'moz/master' into syncstorage-sqlite
Eragonfr Feb 12, 2025
4abb7d4
refactor: Cargo fmt
Eragonfr Feb 12, 2025
fcfd4d6
test: Use sqlalchemy.text to prepare query
Eragonfr Feb 12, 2025
28663ae
test: refactor using black
Eragonfr Feb 12, 2025
2264ead
test: Works better if you import the correct thing
Eragonfr Feb 12, 2025
ab06887
test: Idk something something use @ instead of :
Eragonfr Feb 12, 2025
7940055
test: Reformat with lines max length at 80
Eragonfr Feb 12, 2025
4979ba0
feat: Add logging to show Sqlite db path
Eragonfr Mar 1, 2025
714e267
feat: remove third trailing slash in SQLite URIs
Eragonfr Mar 1, 2025
d1a20c5
refactor: Rename service_id to service in SQL queries
Eragonfr Mar 8, 2025
f09db26
fix: Last insert id for MySQL
Eragonfr Mar 8, 2025
1580f4c
ci: print debug
Eragonfr Mar 8, 2025
a38b892
test: Replace arbitrary wait with log reading
Eragonfr Mar 9, 2025
db5b1dc
test(WIP): Use SQLalchemy's ORM features for db independant tests
Eragonfr Mar 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cargo/audit.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[advisories]
ignore = [
"RUSTSEC-2024-0365", # Bound by diesel 1.4 (4GB limit n/a to tokenserver)
"RUSTSEC-2022-0090", # Bound by diesel 1.4.8, diesel_migrations 1.4.0, diesel_logger 0.1.1
"RUSTSEC-2024-0421", # Bound by diesel 1.4, `idna` < 0.1.5, Upgrade to >=1.0.0
]
96 changes: 91 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -53,18 +53,25 @@ commands:
- run:
name: Rust Clippy MySQL
command: |
cargo clippy --workspace --all-targets --no-default-features --features=syncstorage-db/mysql --features=py_verifier -- -D warnings
cargo clippy --workspace --all-targets --no-default-features --features=mysql,py_verifier -- -D warnings
rust-clippy-sqlite:
steps:
- run:
name: Rust Clippy SQLite
command: |
cargo clippy --workspace --all-targets --no-default-features --features=sqlite,py_verifier -- -D warnings
rust-clippy-spanner:
steps:
- run:
name: Rust Clippy Spanner
command: |
cargo clippy --workspace --all-targets --no-default-features --features=syncstorage-db/spanner --features=py_verifier -- -D warnings
cargo clippy --workspace --all-targets --no-default-features --features=spanner,py_verifier -- -D warnings
cargo-build:
steps:
- run:
name: cargo build
command: cargo build
# This only builds the mysql version as it was the old default
command: cargo build --workspace --all-targets --no-default-features --features=mysql,py_verifier
setup-mysql:
steps:
- run:
@@ -95,10 +102,10 @@ commands:
steps:
- run:
name: cargo test
command: cargo test --workspace --verbose
command: cargo test --workspace --verbose --no-default-features --features mysql,py_verifier
- run:
name: quota test
command: cargo test --workspace --verbose
command: cargo test --workspace --verbose --no-default-features --features mysql,py_verifier
environment:
SYNC_SYNCSTORAGE__ENFORCE_QUOTA: 1

@@ -116,6 +123,20 @@ commands:
environment:
SYNCSTORAGE_RS_IMAGE: app:build

run-e2e-sqlite-tests:
steps:
- run:
name: e2e tests (syncstorage sqlite)
command: >
/usr/local/bin/docker-compose
-f docker-compose.sqlite.yaml
-f docker-compose.e2e.sqlite.yaml
up
--exit-code-from sqlite-e2e-tests
--abort-on-container-exit
environment:
SYNCSTORAGE_RS_IMAGE: app:build

run-tokenserver-scripts-tests:
steps:
- run:
@@ -251,6 +272,38 @@ jobs:
paths:
- /home/circleci/cache

build-sqlite-image:
docker:
- image: cimg/rust:1.78.0 # RUST_VER
auth:
username: $DOCKER_USER
password: $DOCKER_PASS
resource_class: large
steps:
- setup_remote_docker:
docker_layer_caching: true
- checkout
- display-versions
- write-version
- run:
name: Build SQLite Docker image
command: docker build -t app:build --build-arg DATABASE_BACKEND=sqlite .
no_output_timeout: 30m
# save the built docker container into CircleCI's cache. This is
# required since Workflows do not have the same remote docker instance.
- run:
name: docker save app:build
command: |
mkdir -p /home/circleci/cache
docker save -o /home/circleci/cache/docker.tar "app:build"
- run:
name: Save docker-compose config
command: cp docker-compose*sqlite.yaml /home/circleci/cache
- save_cache:
key: sqlite-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}-{{ epoch }}
paths:
- /home/circleci/cache

build-spanner-image:
docker:
- image: cimg/rust:1.78.0 # RUST_VER
@@ -321,6 +374,25 @@ jobs:
command: cp /home/circleci/cache/docker-compose*.yaml .
- run-e2e-spanner-tests

sqlite-e2e-tests:
docker:
- image: docker/compose:1.24.0
auth:
username: $DOCKER_USER
password: $DOCKER_PASS
steps:
- setup_remote_docker
- display-versions
- restore_cache:
key: sqlite-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: Restore Docker image cache
command: docker load -i /home/circleci/cache/docker.tar
- run:
name: Restore docker-compose config
command: cp /home/circleci/cache/docker-compose*.yaml .
- run-e2e-sqlite-tests

deploy:
docker:
- image: docker:18.02.0-ce
@@ -422,6 +494,12 @@ workflows:
filters:
tags:
only: /.*/
- build-sqlite-image:
requires:
- build-and-test
filters:
tags:
only: /.*/
- mysql-e2e-tests:
requires:
- build-mysql-image
@@ -434,10 +512,17 @@ workflows:
filters:
tags:
only: /.*/
- sqlite-e2e-tests:
requires:
- build-sqlite-image
filters:
tags:
only: /.*/
- deploy:
requires:
- mysql-e2e-tests
- spanner-e2e-tests
- sqlite-e2e-tests
filters:
tags:
only: /.*/
@@ -448,6 +533,7 @@ workflows:
requires:
- mysql-e2e-tests
- spanner-e2e-tests
- sqlite-e2e-tests
filters:
tags:
only: /.*/
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -15,6 +15,8 @@ html_coverage
.hgignore
.idea
*.iml
Pipfile
Pipfile.lock
site-packages/*
lib-python/*
bin/*
@@ -31,9 +33,10 @@ target
service-account.json
.sentryclirc
.envrc
.env

config/local.toml
tools/tokenserver/loadtests/*.pem
tools/tokenserver/loadtests/*.pub
venv
venv/
.vscode/settings.json
Loading
Oops, something went wrong.