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

Fix dependency on redis-cli and redis-server to pass tests #3014

Merged
merged 7 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 8 additions & 16 deletions csharp/DEVELOPER.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Developer Guide

This document describes how to set up your development environment to build and test the GLIDE for Redis C# wrapper.
This document describes how to set up your development environment to build and test the Valkey GLIDE C# wrapper.

### Development Overview

Expand All @@ -11,7 +11,7 @@ The C# client contains the following parts:
1. Rust part of the C# client located in `lib/src`; it communicates with [GLIDE core rust library](../glide-core/README.md).
2. C# part of the client located in `lib`; it translates Rust async API into .Net async API.
3. Integration tests for the C# client located in `tests` directory.
4. A dedicated benchmarking tool designed to evaluate and compare the performance of GLIDE for Redis and other .Net clients. It is located in `<repo root>/benchmarks/csharp`.
4. A dedicated benchmarking tool designed to evaluate and compare the performance of Valkey GLIDE and other .Net clients. It is located in `<repo root>/benchmarks/csharp`.

TODO: examples, UT, design docs

Expand All @@ -22,7 +22,7 @@ Software Dependencies:
- .Net SDK 6 or later
- git
- rustup
- redis
- valkey

Please also install the following packages to build [GLIDE core rust library](../glide-core/README.md):

Expand Down Expand Up @@ -53,9 +53,10 @@ For example, on Linux you can copy it to `/usr/bin`:
sudo cp protoc /usr/bin/
```

**Redis installation**
**Valkey installation**

See the [Valkey installation guide](https://valkey.io/topics/installation/) to install the Valkey server and CLI.

To install `redis-server` and `redis-cli` on your host, follow the [Redis Installation Guide](https://redis.io/docs/install/install-redis/).

**Dependencies installation for Ubuntu**

Expand All @@ -77,7 +78,7 @@ source "$HOME/.cargo/env"

#### Building and installation steps

Before starting this step, make sure you've installed all software requirments.
Before starting this step, make sure you've installed all software requirements.

1. Clone the repository
```bash
Expand All @@ -101,8 +102,7 @@ dotnet test

4. Run benchmark

1. Ensure that you have installed `redis-server` and `redis-cli` on your host. You can find the Redis installation guide at the following link: [Redis Installation Guide](https://redis.io/docs/install/install-redis/install-redis-on-linux/).

1. Ensure that you have installed `valkey-server` and `valkey-cli` on your host. You can find the valkey installation guide above.
2. Execute the following command from the root project folder:

```bash
Expand Down Expand Up @@ -136,14 +136,6 @@ cargo clippy --all-features --all-targets -- -D warnings
cargo fmt --all -- --check
```

### Submodules

After pulling new changes, ensure that you update the submodules by running the following command:

```bash
git submodule update
```

6. Test framework and style

Test package used in code xUnit v3. Testing code styles defined in .editorcofing (see dotnet_diagnostic.xUnit.. rules). Rules enforced by https://github.com/xunit/xunit.analyzers referenced by the main xunit.v3 NuGet package out of the box. If you choose to reference xunit.v3.core instead, you can reference xunit.analyzers explicitly. For additional info, please, refer to https://xunit.net and https://github.com/xunit/xunit
28 changes: 16 additions & 12 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
import eslint from "@eslint/js";
import prettierConfig from "eslint-config-prettier";
import tseslint from "typescript-eslint";
import jsdoc from "eslint-plugin-jsdoc";
avifenesh marked this conversation as resolved.
Show resolved Hide resolved

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
{ files: ["**/*.js"], ...tseslint.configs.disableTypeChecked },
{ files: [ "**/*.js" ], ...tseslint.configs.disableTypeChecked },
{
ignores: [
"*/ProtobufMessage.*",
"**/*.d.ts",
"node_modules/**",
"build-ts/**",
"**/build-ts/**",
"build/**",
"jest.config.js",
"docs/**"
"docs/**",
],
},
{
Expand Down Expand Up @@ -55,14 +55,18 @@ export default tseslint.config(
next: "*",
},
],
"@typescript-eslint/indent": ["error", 4, {
"SwitchCase": 1,
"ObjectExpression": 1,
"FunctionDeclaration": {"parameters": "first"},
"FunctionExpression": {"parameters": "first"},
"ignoredNodes": ["TSTypeParameterInstantiation"]
}],
"@typescript-eslint/indent": [
"error",
4,
{
SwitchCase: 1,
ObjectExpression: 1,
FunctionDeclaration: { parameters: "first" },
FunctionExpression: { parameters: "first" },
ignoredNodes: [ "TSTypeParameterInstantiation" ],
},
],
},
},
prettierConfig,
prettierConfig
);
3 changes: 2 additions & 1 deletion glide-core/redis-rs/redis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,9 @@ tempfile = "=3.6.0"
once_cell = "1"
anyhow = "1"
sscanf = "0.4.1"
serial_test = "2"
serial_test = "^2"
versions = "6.3"
which = "7.0.1"

[[test]]
name = "test_async"
Expand Down
8 changes: 7 additions & 1 deletion glide-core/redis-rs/redis/tests/support/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,13 @@ impl RedisCluster {
));
}

let mut cmd = process::Command::new("redis-cli");
let cli_command = ["valkey-cli", "redis-cli"]
.iter()
.find(|cmd| which::which(cmd).is_ok())
.map(|&cmd| cmd)
.unwrap_or_else(|| panic!("Neither valkey-cli nor redis-cli exists in the system."));

let mut cmd = process::Command::new(cli_command);
cmd.stdout(process::Stdio::null())
.arg("--cluster")
.arg("create")
Expand Down
30 changes: 19 additions & 11 deletions glide-core/redis-rs/redis/tests/support/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,25 @@ impl RedisServer {
modules: &[Module],
spawner: F,
) -> RedisServer {
let mut redis_cmd = process::Command::new("redis-server");
// Check wether the server available is valkey or redis
let server_command = ["valkey-server", "redis-server"]
.iter()
.find(|cmd| which::which(cmd).is_ok())
.map(|&cmd| cmd)
.unwrap_or_else(|| {
panic!("Neither valkey-server nor redis-server exists in the system.")
});
let mut server_cmd = process::Command::new(server_command);

if let Some(config_path) = config_file {
redis_cmd.arg(config_path);
server_cmd.arg(config_path);
}

// Load Redis Modules
for module in modules {
match module {
Module::Json => {
redis_cmd
server_cmd
.arg("--loadmodule")
.arg(env::var("REDIS_RS_REDIS_JSON_PATH").expect(
"Unable to find path to RedisJSON at REDIS_RS_REDIS_JSON_PATH, is it set?",
Expand All @@ -244,24 +252,24 @@ impl RedisServer {
};
}

redis_cmd
server_cmd
.stdout(process::Stdio::null())
.stderr(process::Stdio::null());
let tempdir = tempfile::Builder::new()
.prefix("redis")
.tempdir()
.expect("failed to create tempdir");
redis_cmd.arg("--logfile").arg(Self::log_file(&tempdir));
server_cmd.arg("--logfile").arg(Self::log_file(&tempdir));
match addr {
redis::ConnectionAddr::Tcp(ref bind, server_port) => {
redis_cmd
server_cmd
.arg("--port")
.arg(server_port.to_string())
.arg("--bind")
.arg(bind);

RedisServer {
process: spawner(&mut redis_cmd),
process: spawner(&mut server_cmd),
tempdir,
addr,
tls_paths: None,
Expand All @@ -273,7 +281,7 @@ impl RedisServer {
let auth_client = if mtls_enabled { "yes" } else { "no" };

// prepare redis with TLS
redis_cmd
server_cmd
.arg("--tls-port")
.arg(port.to_string())
.arg("--port")
Expand All @@ -300,20 +308,20 @@ impl RedisServer {
};

RedisServer {
process: spawner(&mut redis_cmd),
process: spawner(&mut server_cmd),
tempdir,
addr,
tls_paths: Some(tls_paths),
}
}
redis::ConnectionAddr::Unix(ref path) => {
redis_cmd
server_cmd
.arg("--port")
.arg("0")
.arg("--unixsocket")
.arg(path);
RedisServer {
process: spawner(&mut redis_cmd),
process: spawner(&mut server_cmd),
tempdir,
addr,
tls_paths: None,
Expand Down
4 changes: 2 additions & 2 deletions go/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Software Dependencies

**Valkey installation**

To install valkey-server and valkey-cli on your host, follow the [Valkey Installation Guide](https://github.com/valkey-io/valkey).
See the [Valkey installation guide](https://valkey.io/topics/installation/) to install the Valkey server and CLI.

**Dependencies installation for Ubuntu**

Expand Down Expand Up @@ -121,7 +121,7 @@ Before starting this step, make sure you've installed all software requirements.
make build
```
5. Run tests:
1. Ensure that you have installed valkey-server and valkey-cli on your host. You can find the Valkey installation guide at the following link: [Valkey Installation Guide](https://github.com/valkey-io/valkey).
1. Ensure that you have installed valkey-server and valkey-cli on your host. You can find the Valkey installation guide at the following link: [Valkey Installation Guide](https://valkey.io/topics/installation/).
2. Execute the following command from the go folder:
```bash
go test -race ./...
Expand Down
11 changes: 3 additions & 8 deletions node/.ort.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ excludes:
reason: "BUILD_TOOL_OF"
comment: "Template file for CD"

resolutions:
issues:
- message: "NPM failed to resolve dependencies for path 'hybrid-node-tests/commonjs-test/package.json': FileNotFoundException: .*valkey-glide/package.json.*"
reason: "BUILD_TOOL_ISSUE"
comment: "The 'hybrid-node-tests' are not built, so there is no 'package.json' in the expected location. The 'valkey-glide' package has already been scanned for licenses, so there's no need to scan it again."
- message: "NPM failed to resolve dependencies for path 'hybrid-node-tests/ecmascript-test/package.json': FileNotFoundException: .*valkey-glide/package.json.*"
reason: "BUILD_TOOL_ISSUE"
comment: "The 'hybrid-node-tests' are not built, so there is no 'package.json' in the expected location. The 'valkey-glide' package has already been scanned for licenses, so there's no need to scan it again."
- pattern: "hybrid-node-tests/**"
avifenesh marked this conversation as resolved.
Show resolved Hide resolved
reason: "TEST_OF"
comment: "Test files for hybrid node tests"
11 changes: 3 additions & 8 deletions node/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
```

**Valkey Server and CLI**
See the [Valkey installation guide](https://valkey.io/topics/installation/) to install the Valkey server and CLI.

#### Building and installation steps

Before starting this step, make sure you've installed all software requirments.
Expand Down Expand Up @@ -191,14 +194,6 @@ It has command history and bash-like search (`Ctrl+R`).

Shell hangs on exit (`Ctrl+D`) if you don't close the clients. Use `Ctrl+C` to kill it and/or close clients before exit.

### Submodules

After pulling new changes, ensure that you update the submodules by running the following command:

```bash
git submodule update
```

### Linters

Development on the Node wrapper may involve changes in either the TypeScript or Rust code. Each language has distinct linter tests that must be passed before committing changes.
Expand Down
Loading
Loading