-
Notifications
You must be signed in to change notification settings - Fork 10
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
Package review PR #1
base: test
Are you sure you want to change the base?
Changes from all commits
5237a10
a96c08a
be97a25
5ebc1cb
8557b55
1729520
be80d9d
ed4d0f9
2db0e4b
778c219
b11970e
bdf5f0d
8f5e3fc
5545680
42d015c
481ecac
ff60817
1c1b6ab
d00fa99
053d5e9
fbdfb5b
a2343b7
753575a
3f85cae
159c938
bebf72a
ef4e215
6ca68c5
b7504e9
3ebb15b
ec72262
2816474
3c285d5
ffb722f
5b0df15
c66243d
0d2ad8a
85e20fd
0b9a90d
a180f42
736a48a
6d0a4b6
dee8a7e
145f9b2
282599d
687bec7
f299216
4d38649
fde4d37
f5aa39e
57a7901
12031b2
31d21c0
b301baa
a33e0e3
7c25468
34d6fb0
1b0d819
f10a4e5
eaa218f
d8a0508
a5ec8de
4a8af80
8b94c17
3589d30
98ccdc6
9baf6fc
6a514bf
1c949fb
ab158bb
a9b578e
1bb7d25
591ab10
20efd95
14ad3d0
56f631f
8077d58
8f1c9f4
1e6c23b
e94a2e7
12fa935
e308fed
d23399a
60513c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
name: ci | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
VALKEY_REPO_URL: https://github.com/valkey-io/valkey.git | ||
|
||
jobs: | ||
build-ubuntu-latest: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
server_version: ['unstable', '8.0.0'] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set the server verison for python integeration tests | ||
run: echo "SERVER_VERSION=${{ matrix.server_version }}" >> $GITHUB_ENV | ||
- name: Run cargo and clippy format check | ||
run: | | ||
cargo fmt --check | ||
cargo clippy --profile release --all-targets -- -D clippy::all | ||
- name: Release Build | ||
run: | | ||
if [ "${{ matrix.server_version }}" = "8.0.0" ]; then | ||
RUSTFLAGS="-D warnings" cargo build --all --all-targets --release --features valkey_8_0 | ||
else | ||
RUSTFLAGS="-D warnings" cargo build --all --all-targets --release | ||
fi | ||
- name: Run unit tests | ||
run: cargo test --features enable-system-alloc | ||
- name: Make valkey-server binary | ||
run: | | ||
mkdir -p "tests/.build/binaries/${{ matrix.server_version }}" | ||
cd tests/.build | ||
git clone "${{ env.VALKEY_REPO_URL }}" | ||
cd valkey | ||
git checkout ${{ matrix.server_version }} | ||
make -j | ||
cp src/valkey-server ../binaries/${{ matrix.server_version }}/ | ||
- name: Set up Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.8' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Update module path | ||
run: echo "MODULE_PATH=$(realpath target/release/libvalkey_bloom.so)" >> $GITHUB_ENV | ||
- name: Run integration tests | ||
run: python -m pytest --cache-clear -v "tests/" | ||
|
||
build-macos-latest: | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Run cargo and clippy format check | ||
run: | | ||
cargo fmt --check | ||
cargo clippy --profile release --all-targets -- -D clippy::all | ||
- name: Release Build | ||
run: RUSTFLAGS="-D warnings" cargo build --all --all-targets --release | ||
- name: Run unit tests | ||
run: cargo test --features enable-system-alloc | ||
|
||
asan-build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
server_version: ['unstable', '8.0.0'] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set the server verison for python integeration tests | ||
run: echo "SERVER_VERSION=${{ matrix.server_version }}" >> $GITHUB_ENV | ||
- name: Run cargo and clippy format check | ||
run: | | ||
cargo fmt --check | ||
cargo clippy --profile release --all-targets -- -D clippy::all | ||
- name: Release Build | ||
run: | | ||
if [ "${{ matrix.server_version }}" = "8.0.0" ]; then | ||
RUSTFLAGS="-D warnings" cargo build --all --all-targets --release --features valkey_8_0 | ||
else | ||
RUSTFLAGS="-D warnings" cargo build --all --all-targets --release | ||
fi | ||
- name: Run unit tests | ||
run: cargo test --features enable-system-alloc | ||
- name: Make Valkey-server binary with asan | ||
run: | | ||
mkdir -p "tests/.build/binaries/${{ matrix.server_version }}" | ||
cd tests/.build | ||
git clone "${{ env.VALKEY_REPO_URL }}" | ||
cd valkey | ||
git checkout ${{ matrix.server_version }} | ||
make distclean | ||
make -j SANITIZER=address SERVER_CFLAGS='-Werror' BUILD_TLS=module | ||
cp src/valkey-server ../binaries/${{ matrix.server_version }}/ | ||
- name: Set up Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.8' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Update module path | ||
run: echo "MODULE_PATH=$(realpath target/release/libvalkey_bloom.so)" >> $GITHUB_ENV | ||
- name: Run integration tests | ||
run: | | ||
python -m pytest --capture=sys --cache-clear -v "tests/" -m "not skip_for_asan" 2>&1 | tee test_output.tmp | ||
|
||
if grep -q "LeakSanitizer: detected memory leaks" test_output.tmp; then | ||
RED='\033[0;31m' | ||
echo -e "${RED}Memory leaks detected in the following tests:" | ||
LEAKING_TESTS=$(grep -B 2 "LeakSanitizer: detected memory leaks" test_output.tmp | \ | ||
grep -v "LeakSanitizer" | \ | ||
grep ".*\.py::") | ||
LEAK_COUNT=$(echo "$LEAKING_TESTS" | wc -l) | ||
echo "$LEAKING_TESTS" | while read -r line; do | ||
echo "::error::Test with leak: $line" | ||
done | ||
echo -e "\n$LEAK_COUNT python integration tests have leaks detected in them" | ||
rm test_output.tmp | ||
exit 1 | ||
fi | ||
rm test_output.tmp |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Cargo.lock | ||
target | ||
tests/.build | ||
__pycache__ | ||
test-data | ||
.attach_pid* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Hello! This file is just a placeholder, since this is the "unstable" branch | ||
of Valkey-Bloom, the place where all the development happens. | ||
|
||
There is no release notes for this branch, it gets forked into another branch | ||
every time there is a partial feature freeze in order to eventually create | ||
a new stable release. | ||
|
||
Usually "unstable" is stable enough for you to use it in development environments | ||
however you should never use it in production environments. You can find the | ||
latest stable release here: | ||
|
||
https://github.com/valkey-io/valkey-bloom/releases | ||
|
||
Happy hacking! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
[package] | ||
name = "valkey-bloom" | ||
authors = ["Karthik Subbarao"] | ||
version = "0.1.0-dev" | ||
edition = "2021" | ||
license = "BSD-3-Clause" | ||
repository = "https://github.com/valkey-io/valkey-bloom" | ||
readme = "README.md" | ||
description = "A bloom filter module for Valkey" | ||
homepage = "https://github.com/valkey-io/valkey-bloom" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
valkey-module = { version = "0.1.5", features = ["min-valkey-compatibility-version-8-0", "min-redis-compatibility-version-7-2"]} | ||
valkey-module-macros = "0" | ||
linkme = "0" | ||
bloomfilter = { version = "3.0.1", features = ["serde"] } | ||
lazy_static = "1.4.0" | ||
libc = "0.2" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need libc? |
||
serde = { version = "1.0", features = ["derive"] } | ||
bincode = "1.3" | ||
|
||
[dev-dependencies] | ||
rand = "0.8" | ||
rstest = "0.23.0" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
name = "valkey_bloom" | ||
|
||
[profile.dev] | ||
opt-level = 0 | ||
debug = 2 | ||
debug-assertions = true | ||
|
||
[features] | ||
default = ["min-valkey-compatibility-version-8-0"] | ||
enable-system-alloc = ["valkey-module/enable-system-alloc"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the intention with this configuration? |
||
min-valkey-compatibility-version-8-0 = [] | ||
valkey_8_0 = [] # Valkey-bloom is intended to be loaded on server versions >= Valkey 8.1 and by default it is built this way (unless this flag is provided). It is however compatible with Valkey version 8.0 if the user explicitly provides this feature flag in their cargo build command. | ||
use-redismodule-api = [] # We don't support this feature flag which is why it is empty. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2024-present, Valkey contributors | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
* Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,74 @@ | ||
# valkey-bloom | ||
# valkey-bloom | ||
|
||
Valkey-Bloom (BSD-3-Clause) is a Rust Valkey-Module which brings a native and space efficient probabilistic Module data type to Valkey. With this, users can create filters (space-efficient probabilistic Module data type) to add elements, perform “check” operation to test whether an element exists, auto scale their filters, perform RDB Save and load operations, etc. | ||
|
||
Valkey-Bloom is built using `bloomfilter::Bloom` (https://crates.io/crates/bloomfilter which has a BSD-2-Clause license). | ||
|
||
It is compatible with the BloomFilter (BF.*) command APIs in Redis offerings. | ||
|
||
## Supported commands | ||
``` | ||
BF.EXISTS | ||
BF.ADD | ||
BF.MEXISTS | ||
BF.MADD | ||
BF.CARD | ||
BF.RESERVE | ||
BF.INFO | ||
BF.INSERT | ||
BF.LOAD | ||
``` | ||
|
||
## Build instructions | ||
``` | ||
curl https://sh.rustup.rs -sSf | sh | ||
sudo yum install clang | ||
git clone https://github.com/valkey-io/valkey-bloom.git | ||
cd valkey-bloom | ||
cargo build --all --all-targets --release | ||
valkey-server --loadmodule ./target/release/libvalkey_bloom.so | ||
``` | ||
|
||
#### Local development script to build, run format checks, run unit / integration tests, and for cargo release: | ||
``` | ||
# Builds the valkey-server (unstable) for integration testing. | ||
SERVER_VERSION=unstable | ||
./build.sh | ||
# Same as above, but uses valkey-server (8.0.0) for integration testing. | ||
SERVER_VERSION=8.0.0 | ||
./build.sh | ||
# Build with asan, you may need to remove the old valkey binary if you have used ./build.sh before. You can do this by deleting the `.build` folder in the `tests` folder | ||
ASAN_BUILD=true | ||
./build.sh | ||
``` | ||
|
||
## Load the Module | ||
To test the module with a Valkey, you can load the module in the following ways: | ||
|
||
#### Using valkey.conf: | ||
``` | ||
1. Add the following to valkey.conf: | ||
loadmodule /path/to/libvalkey_bloom.so | ||
2. Start valkey-server: | ||
valkey-server /path/to/valkey.conf | ||
``` | ||
|
||
#### Starting Valkey with the `--loadmodule` option: | ||
```text | ||
valkey-server --loadmodule /path/to/libvalkey_bloom.so | ||
``` | ||
|
||
#### Using the Valkey command `MODULE LOAD`: | ||
``` | ||
1. Connect to a running Valkey instance using valkey-cli | ||
2. Execute Valkey command: | ||
MODULE LOAD /path/to/libvalkey_bloom.so | ||
``` | ||
## Feature Flags | ||
|
||
* valkey_8_0: valkey-bloom is intended to be loaded on server versions >= Valkey 8.1 and by default it is built this way (unless this flag is provided). It is however compatible with Valkey version 8.0 if the user explicitly provides this feature flag in their cargo build command. | ||
``` | ||
cargo build --release --features valkey_8_0 | ||
``` | ||
|
||
This can also be done by specifiyng SERVER_VERSION=8.0.0 and then running `./build.sh` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I am a new developer looking at this file, how do I understand the intent of this file without documentation? Are these configurations obvious? What documentation did you read to write this file?