From b310b5f430ef36ac562eea5647ed8f21300e753a Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Thu, 31 Oct 2024 13:53:21 -0700 Subject: [PATCH 1/6] Bump protoc Signed-off-by: Yury-Fridlyand --- .github/workflows/install-rust-and-protoc/action.yml | 2 +- .github/workflows/java-cd.yml | 4 ++-- .github/workflows/java.yml | 4 ++-- .github/workflows/pypi-cd.yml | 4 ++-- CHANGELOG.md | 1 + java/DEVELOPER.md | 12 ++++++------ java/client/build.gradle | 10 +++++----- python/DEVELOPER.md | 12 ++++++------ python/requirements.txt | 2 +- 9 files changed, 26 insertions(+), 25 deletions(-) diff --git a/.github/workflows/install-rust-and-protoc/action.yml b/.github/workflows/install-rust-and-protoc/action.yml index e1222ffd9d..e8b21ab523 100644 --- a/.github/workflows/install-rust-and-protoc/action.yml +++ b/.github/workflows/install-rust-and-protoc/action.yml @@ -28,5 +28,5 @@ runs: - name: Install protoc (protobuf) uses: arduino/setup-protoc@v3 with: - version: "25.1" + version: "25.5" repo-token: ${{ inputs.github-token }} diff --git a/.github/workflows/java-cd.yml b/.github/workflows/java-cd.yml index d3f2038313..c1930d0faf 100644 --- a/.github/workflows/java-cd.yml +++ b/.github/workflows/java-cd.yml @@ -104,7 +104,7 @@ jobs: - name: Install protoc (protobuf) uses: arduino/setup-protoc@v3 with: - version: "26.1" + version: "28.1" repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Create secret key ring file @@ -243,7 +243,7 @@ jobs: - name: Install protoc (protobuf) uses: arduino/setup-protoc@v3 with: - version: "26.1" + version: "28.1" repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Start standalone Valkey server diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index 2c31562f78..58d496ac26 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -95,7 +95,7 @@ jobs: - name: Install protoc (protobuf) uses: arduino/setup-protoc@v3 with: - version: "26.1" + version: "28.1" repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Build java client @@ -163,7 +163,7 @@ jobs: - name: Install protoc (protobuf) uses: arduino/setup-protoc@v3 with: - version: "26.1" + version: "28.1" repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Install Java diff --git a/.github/workflows/pypi-cd.yml b/.github/workflows/pypi-cd.yml index 5d547ac7f5..889b771a64 100644 --- a/.github/workflows/pypi-cd.yml +++ b/.github/workflows/pypi-cd.yml @@ -170,8 +170,8 @@ jobs: echo "Running on unsupported architecture: $ARCH. Expected one of: ['x86_64', 'aarch64']" exit 1 fi - curl -LO $PB_REL/download/v3.20.3/protoc-3.20.3-linux-${PROTOC_ARCH}.zip - unzip protoc-3.20.3-linux-${PROTOC_ARCH}.zip -d $HOME/.local + curl -LO $PB_REL/download/v4.25.5/protoc-4.25.5-linux-${PROTOC_ARCH}.zip + unzip protoc-4.25.5-linux-${PROTOC_ARCH}.zip -d $HOME/.local export PATH="$PATH:$HOME/.local/bin" - name: Build Python wheels (macos) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fa3bf7597..48d07a8991 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ * Python: Add `JSON.RESP` command ([#2451](https://github.com/valkey-io/valkey-glide/pull/2451)) * Node: Add `JSON.STRLEN` and `JSON.STRAPPEND` command ([#2537](https://github.com/valkey-io/valkey-glide/pull/2537)) * Python: Fix example ([#2556](https://github.com/valkey-io/valkey-glide/issues/2556)) +* Java, Python: Bump protobuf (protoc) version ([#2561](https://github.com/valkey-io/valkey-glide/pull/2561)) #### Breaking Changes diff --git a/java/DEVELOPER.md b/java/DEVELOPER.md index d8bc19b99c..2941328470 100644 --- a/java/DEVELOPER.md +++ b/java/DEVELOPER.md @@ -17,7 +17,7 @@ The Valkey GLIDE Java wrapper consists of both Java and Rust code. Rust bindings - git - GCC - pkg-config -- protoc (protobuf compiler) >= 26.1 +- protoc (protobuf compiler) >= 28.1 - openssl - openssl-dev - rustup @@ -64,17 +64,17 @@ Continue with **Install protobuf compiler** below. To install protobuf for MacOS, run: ```bash brew install protobuf -# Check that the protobuf compiler version 26.1 or higher is installed +# Check that the protobuf compiler version 28.1 or higher is installed protoc --version ``` For the remaining systems, do the following: ```bash PB_REL="https://github.com/protocolbuffers/protobuf/releases" -curl -LO $PB_REL/download/v26.1/protoc-26.1-linux-x86_64.zip -unzip protoc-26.1-linux-x86_64.zip -d $HOME/.local +curl -LO $PB_REL/download/v28.1/protoc-28.1-linux-x86_64.zip +unzip protoc-28.1-linux-x86_64.zip -d $HOME/.local export PATH="$PATH:$HOME/.local/bin" -# Check that the protobuf compiler version 26.1 or higher is installed +# Check that the protobuf compiler version 28.1 or higher is installed protoc --version ``` @@ -165,7 +165,7 @@ Some troubleshooting issues: - Failed to find `cargo` after `rustup`. - No Protobuf compiler (protoc) found. - If build fails because of rust compiler fails, make sure submodules are updated using `git submodule update`. -- If protobuf 26.0 or earlier is detected, upgrade to the latest protobuf release. +- If protobuf 28.0 or earlier is detected, upgrade to the latest protobuf release. ## Running Examples App diff --git a/java/client/build.gradle b/java/client/build.gradle index 364b09ca1e..10ed60def9 100644 --- a/java/client/build.gradle +++ b/java/client/build.gradle @@ -14,7 +14,7 @@ repositories { } dependencies { - implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '4.27.1' + implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '4.28.1' implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.13.0' implementation group: 'io.netty', name: 'netty-handler', version: '4.1.100.Final' @@ -39,11 +39,11 @@ dependencies { ext { checkProtocVersion = { String output -> - // Line in format like: libprotoc 26.1 + // Line in format like: libprotoc 28.1 int majorVersion = Integer.parseInt(output.split(" ")[1].split("\\.")[0].trim()); int minorVersion = Integer.parseInt(output.split(" ")[1].split("\\.")[1].trim()); - if (majorVersion < 26 || (majorVersion == 26 && minorVersion < 1)) { - throw new GradleException("Protobuf compiler (protoc) version 26.1 or newer is required. Current version: $output"); + if (majorVersion < 28) { + throw new GradleException("Protobuf compiler (protoc) version 28.0 or newer is required. Current version: $output"); } return output.split(" ")[1] } @@ -62,7 +62,7 @@ tasks.register('protobuf', Exec) { } } catch (Exception e) { if (e.getMessage().startsWith("A problem occurred starting process")) { - throw new GradleException("No Protobuf compiler (protoc) found. Protobuf compiler version 26.1 or newer is required."); + throw new GradleException("No Protobuf compiler (protoc) found. Protobuf compiler version 28.0 or newer is required."); } throw e } diff --git a/python/DEVELOPER.md b/python/DEVELOPER.md index 66127913c3..f0b098a74f 100644 --- a/python/DEVELOPER.md +++ b/python/DEVELOPER.md @@ -14,7 +14,7 @@ Before building the package from source, make sure that you have installed the l - git - GCC - pkg-config -- protoc (protobuf compiler) >= v3.20.0 +- protoc (protobuf compiler) >= v4.25.5 - openssl - openssl-dev - rustup @@ -35,9 +35,9 @@ rustc --version # Install protobuf compiler PB_REL="https://github.com/protocolbuffers/protobuf/releases" # For other arch type from x86 example below, the signature of the curl url should be protoc---.zip, -# e.g. protoc-3.20.3-linux-aarch_64.zip for ARM64. -curl -LO $PB_REL/download/v3.20.3/protoc-3.20.3-linux-x86_64.zip -unzip protoc-3.20.3-linux-x86_64.zip -d $HOME/.local +# e.g. protoc-4.25.5-linux-aarch_64.zip for ARM64. +curl -LO $PB_REL/download/v4.25.5/protoc-4.25.5-linux-x86_64.zip +unzip protoc-4.25.5-linux-x86_64.zip -d $HOME/.local export PATH="$PATH:$HOME/.local/bin" # Check that the protobuf compiler is installed protoc --version @@ -59,8 +59,8 @@ source "$HOME/.cargo/env" rustc --version # Install protobuf compiler PB_REL="https://github.com/protocolbuffers/protobuf/releases" -curl -LO $PB_REL/download/v3.20.3/protoc-3.20.3-linux-x86_64.zip -unzip protoc-3.20.3-linux-x86_64.zip -d $HOME/.local +curl -LO $PB_REL/download/v4.25.5/protoc-4.25.5-linux-x86_64.zip +unzip protoc-4.25.5-linux-x86_64.zip -d $HOME/.local export PATH="$PATH:$HOME/.local/bin" # Check that the protobuf compiler is installed protoc --version diff --git a/python/requirements.txt b/python/requirements.txt index 63b2be3603..ddeb77cd65 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -1,6 +1,6 @@ async-timeout==4.0.2;python_version<"3.11" maturin==0.13.0 -protobuf==3.20.* +protobuf==4.25.* pytest==7.1.2 pytest-asyncio==0.19.0 typing_extensions==4.8.0;python_version<"3.11" From 7795c23ec38c38fdde4849342318361d915399ad Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Wed, 20 Nov 2024 17:12:56 -0800 Subject: [PATCH 2/6] Apply suggestions from code review Co-authored-by: Andrew Carbonetto Signed-off-by: Yury-Fridlyand --- .github/workflows/java-cd.yml | 4 ++-- .github/workflows/java.yml | 4 ++-- .github/workflows/pypi-cd.yml | 4 ++-- java/DEVELOPER.md | 10 +++++----- java/client/build.gradle | 2 +- python/DEVELOPER.md | 12 ++++++------ python/requirements.txt | 2 +- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/java-cd.yml b/.github/workflows/java-cd.yml index 70ad2cc322..7033141881 100644 --- a/.github/workflows/java-cd.yml +++ b/.github/workflows/java-cd.yml @@ -102,7 +102,7 @@ jobs: - name: Install protoc (protobuf) uses: arduino/setup-protoc@v3 with: - version: "28.1" + version: "28.2" repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Create secret key ring file @@ -245,7 +245,7 @@ jobs: - name: Install protoc (protobuf) uses: arduino/setup-protoc@v3 with: - version: "28.1" + version: "28.2" repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Start standalone Valkey server diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index 250e24c4c6..449c9f1a65 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -103,7 +103,7 @@ jobs: - name: Install protoc (protobuf) uses: arduino/setup-protoc@v3 with: - version: "28.1" + version: "28.2" repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Build java client @@ -184,7 +184,7 @@ jobs: - name: Install protoc (protobuf) uses: arduino/setup-protoc@v3 with: - version: "28.1" + version: "28.2" repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Build java wrapper diff --git a/.github/workflows/pypi-cd.yml b/.github/workflows/pypi-cd.yml index f91767c2f8..6a4b6398d2 100644 --- a/.github/workflows/pypi-cd.yml +++ b/.github/workflows/pypi-cd.yml @@ -166,8 +166,8 @@ jobs: echo "Running on unsupported architecture: $ARCH. Expected one of: ['x86_64', 'aarch64']" exit 1 fi - curl -LO $PB_REL/download/v4.25.5/protoc-4.25.5-linux-${PROTOC_ARCH}.zip - unzip protoc-4.25.5-linux-${PROTOC_ARCH}.zip -d $HOME/.local + curl -LO $PB_REL/download/v3.25.5/protoc-3.25.5-linux-${PROTOC_ARCH}.zip + unzip protoc-3.25.5-linux-${PROTOC_ARCH}.zip -d $HOME/.local export PATH="$PATH:$HOME/.local/bin" - name: Build Python wheels (macos) diff --git a/java/DEVELOPER.md b/java/DEVELOPER.md index 2941328470..3a275425fc 100644 --- a/java/DEVELOPER.md +++ b/java/DEVELOPER.md @@ -17,7 +17,7 @@ The Valkey GLIDE Java wrapper consists of both Java and Rust code. Rust bindings - git - GCC - pkg-config -- protoc (protobuf compiler) >= 28.1 +- protoc (protobuf compiler) >= 28.2 - openssl - openssl-dev - rustup @@ -64,17 +64,17 @@ Continue with **Install protobuf compiler** below. To install protobuf for MacOS, run: ```bash brew install protobuf -# Check that the protobuf compiler version 28.1 or higher is installed +# Check that the protobuf compiler version 28.2 or higher is installed protoc --version ``` For the remaining systems, do the following: ```bash PB_REL="https://github.com/protocolbuffers/protobuf/releases" -curl -LO $PB_REL/download/v28.1/protoc-28.1-linux-x86_64.zip -unzip protoc-28.1-linux-x86_64.zip -d $HOME/.local +curl -LO $PB_REL/download/v28.2/protoc-28.2-linux-x86_64.zip +unzip protoc-28.2-linux-x86_64.zip -d $HOME/.local export PATH="$PATH:$HOME/.local/bin" -# Check that the protobuf compiler version 28.1 or higher is installed +# Check that the protobuf compiler version 28.2 or higher is installed protoc --version ``` diff --git a/java/client/build.gradle b/java/client/build.gradle index 10ed60def9..4867e04697 100644 --- a/java/client/build.gradle +++ b/java/client/build.gradle @@ -14,7 +14,7 @@ repositories { } dependencies { - implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '4.28.1' + implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '4.28.2' implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.13.0' implementation group: 'io.netty', name: 'netty-handler', version: '4.1.100.Final' diff --git a/python/DEVELOPER.md b/python/DEVELOPER.md index f0b098a74f..d984e0101c 100644 --- a/python/DEVELOPER.md +++ b/python/DEVELOPER.md @@ -14,7 +14,7 @@ Before building the package from source, make sure that you have installed the l - git - GCC - pkg-config -- protoc (protobuf compiler) >= v4.25.5 +- protoc (protobuf compiler) >= v3.25.5 - openssl - openssl-dev - rustup @@ -35,9 +35,9 @@ rustc --version # Install protobuf compiler PB_REL="https://github.com/protocolbuffers/protobuf/releases" # For other arch type from x86 example below, the signature of the curl url should be protoc---.zip, -# e.g. protoc-4.25.5-linux-aarch_64.zip for ARM64. -curl -LO $PB_REL/download/v4.25.5/protoc-4.25.5-linux-x86_64.zip -unzip protoc-4.25.5-linux-x86_64.zip -d $HOME/.local +# e.g. protoc-3.25.5-linux-aarch_64.zip for ARM64. +curl -LO $PB_REL/download/v3.25.5/protoc-3.25.5-linux-x86_64.zip +unzip protoc-3.25.5-linux-x86_64.zip -d $HOME/.local export PATH="$PATH:$HOME/.local/bin" # Check that the protobuf compiler is installed protoc --version @@ -59,8 +59,8 @@ source "$HOME/.cargo/env" rustc --version # Install protobuf compiler PB_REL="https://github.com/protocolbuffers/protobuf/releases" -curl -LO $PB_REL/download/v4.25.5/protoc-4.25.5-linux-x86_64.zip -unzip protoc-4.25.5-linux-x86_64.zip -d $HOME/.local +curl -LO $PB_REL/download/v3.25.5/protoc-3.25.5-linux-x86_64.zip +unzip protoc-3.25.5-linux-x86_64.zip -d $HOME/.local export PATH="$PATH:$HOME/.local/bin" # Check that the protobuf compiler is installed protoc --version diff --git a/python/requirements.txt b/python/requirements.txt index b69c14a568..0537d78911 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -1,6 +1,6 @@ async-timeout==4.0.2;python_version<"3.11" maturin==0.13.0 -protobuf==4.25.* +protobuf==3.25.* pytest pytest-asyncio typing_extensions==4.8.0;python_version<"3.11" From a561315ee463fbffd17a69345b539887ae8fd8a7 Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Wed, 20 Nov 2024 17:18:51 -0800 Subject: [PATCH 3/6] revert python Signed-off-by: Yury-Fridlyand --- .../install-rust-and-protoc/action.yml | 2 +- .github/workflows/pypi-cd.yml | 4 +- CHANGELOG.md | 2 +- python/DEVELOPER.md | 12 +- python/python/glide/config.py | 18 ++ python/python/tests/conftest.py | 31 +++ python/python/tests/test_config.py | 15 ++ .../python/tests/test_read_from_strategy.py | 226 ++++++++++++++++++ python/python/tests/utils/cluster.py | 2 +- python/requirements.txt | 2 +- 10 files changed, 302 insertions(+), 12 deletions(-) create mode 100644 python/python/tests/test_read_from_strategy.py diff --git a/.github/workflows/install-rust-and-protoc/action.yml b/.github/workflows/install-rust-and-protoc/action.yml index 7531b9c6f4..31987ba04a 100644 --- a/.github/workflows/install-rust-and-protoc/action.yml +++ b/.github/workflows/install-rust-and-protoc/action.yml @@ -27,5 +27,5 @@ runs: - name: Install protoc (protobuf) uses: arduino/setup-protoc@v3 with: - version: "25.5" + version: "25.1" repo-token: ${{ inputs.github-token }} diff --git a/.github/workflows/pypi-cd.yml b/.github/workflows/pypi-cd.yml index 6a4b6398d2..b72da2a211 100644 --- a/.github/workflows/pypi-cd.yml +++ b/.github/workflows/pypi-cd.yml @@ -166,8 +166,8 @@ jobs: echo "Running on unsupported architecture: $ARCH. Expected one of: ['x86_64', 'aarch64']" exit 1 fi - curl -LO $PB_REL/download/v3.25.5/protoc-3.25.5-linux-${PROTOC_ARCH}.zip - unzip protoc-3.25.5-linux-${PROTOC_ARCH}.zip -d $HOME/.local + curl -LO $PB_REL/download/v3.20.3/protoc-3.20.3-linux-${PROTOC_ARCH}.zip + unzip protoc-3.20.3-linux-${PROTOC_ARCH}.zip -d $HOME/.local export PATH="$PATH:$HOME/.local/bin" - name: Build Python wheels (macos) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9f9e5f624..9c11bc0fb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,7 +80,7 @@ * Node: Add `JSON.STRLEN` and `JSON.STRAPPEND` command ([#2537](https://github.com/valkey-io/valkey-glide/pull/2537)) * Node: Add `FT.SEARCH` ([#2551](https://github.com/valkey-io/valkey-glide/pull/2551)) * Python: Fix example ([#2556](https://github.com/valkey-io/valkey-glide/issues/2556)) -* Java, Python: Bump protobuf (protoc) version ([#2561](https://github.com/valkey-io/valkey-glide/pull/2561)) +* Java: Bump protobuf (protoc) version ([#2561](https://github.com/valkey-io/valkey-glide/pull/2561)) * Core: Add support for sending multi-slot JSON.MSET and JSON.MGET commands ([#2587]https://github.com/valkey-io/valkey-glide/pull/2587) * Node: Add `JSON.DEBUG` command ([#2572](https://github.com/valkey-io/valkey-glide/pull/2572)) * Node: Add `JSON.NUMINCRBY` and `JSON.NUMMULTBY` command ([#2555](https://github.com/valkey-io/valkey-glide/pull/2555)) diff --git a/python/DEVELOPER.md b/python/DEVELOPER.md index d984e0101c..66127913c3 100644 --- a/python/DEVELOPER.md +++ b/python/DEVELOPER.md @@ -14,7 +14,7 @@ Before building the package from source, make sure that you have installed the l - git - GCC - pkg-config -- protoc (protobuf compiler) >= v3.25.5 +- protoc (protobuf compiler) >= v3.20.0 - openssl - openssl-dev - rustup @@ -35,9 +35,9 @@ rustc --version # Install protobuf compiler PB_REL="https://github.com/protocolbuffers/protobuf/releases" # For other arch type from x86 example below, the signature of the curl url should be protoc---.zip, -# e.g. protoc-3.25.5-linux-aarch_64.zip for ARM64. -curl -LO $PB_REL/download/v3.25.5/protoc-3.25.5-linux-x86_64.zip -unzip protoc-3.25.5-linux-x86_64.zip -d $HOME/.local +# e.g. protoc-3.20.3-linux-aarch_64.zip for ARM64. +curl -LO $PB_REL/download/v3.20.3/protoc-3.20.3-linux-x86_64.zip +unzip protoc-3.20.3-linux-x86_64.zip -d $HOME/.local export PATH="$PATH:$HOME/.local/bin" # Check that the protobuf compiler is installed protoc --version @@ -59,8 +59,8 @@ source "$HOME/.cargo/env" rustc --version # Install protobuf compiler PB_REL="https://github.com/protocolbuffers/protobuf/releases" -curl -LO $PB_REL/download/v3.25.5/protoc-3.25.5-linux-x86_64.zip -unzip protoc-3.25.5-linux-x86_64.zip -d $HOME/.local +curl -LO $PB_REL/download/v3.20.3/protoc-3.20.3-linux-x86_64.zip +unzip protoc-3.20.3-linux-x86_64.zip -d $HOME/.local export PATH="$PATH:$HOME/.local/bin" # Check that the protobuf compiler is installed protoc --version diff --git a/python/python/glide/config.py b/python/python/glide/config.py index db85202876..b33c037cbf 100644 --- a/python/python/glide/config.py +++ b/python/python/glide/config.py @@ -41,6 +41,11 @@ class ReadFrom(Enum): Spread the requests between all replicas in a round robin manner. If no replica is available, route the requests to the primary. """ + AZ_AFFINITY = ProtobufReadFrom.AZAffinity + """ + Spread the read requests between replicas in the same client's AZ (Aviliablity zone) in a round robin manner, + falling back to other replicas or the primary if needed + """ class ProtocolVersion(Enum): @@ -135,6 +140,7 @@ def __init__( client_name: Optional[str] = None, protocol: ProtocolVersion = ProtocolVersion.RESP3, inflight_requests_limit: Optional[int] = None, + client_az: Optional[str] = None, ): """ Represents the configuration settings for a Glide client. @@ -172,6 +178,12 @@ def __init__( self.client_name = client_name self.protocol = protocol self.inflight_requests_limit = inflight_requests_limit + self.client_az = client_az + + if read_from == ReadFrom.AZ_AFFINITY and not client_az: + raise ValueError( + "client_az mus t be set when read_from is set to AZ_AFFINITY" + ) def _create_a_protobuf_conn_request( self, cluster_mode: bool = False @@ -204,6 +216,8 @@ def _create_a_protobuf_conn_request( request.protocol = self.protocol.value if self.inflight_requests_limit: request.inflight_requests_limit = self.inflight_requests_limit + if self.client_az: + request.client_az = self.client_az return request @@ -293,6 +307,7 @@ def __init__( protocol: ProtocolVersion = ProtocolVersion.RESP3, pubsub_subscriptions: Optional[PubSubSubscriptions] = None, inflight_requests_limit: Optional[int] = None, + client_az: Optional[str] = None, ): super().__init__( addresses=addresses, @@ -303,6 +318,7 @@ def __init__( client_name=client_name, protocol=protocol, inflight_requests_limit=inflight_requests_limit, + client_az=client_az, ) self.reconnect_strategy = reconnect_strategy self.database_id = database_id @@ -442,6 +458,7 @@ def __init__( ] = PeriodicChecksStatus.ENABLED_DEFAULT_CONFIGS, pubsub_subscriptions: Optional[PubSubSubscriptions] = None, inflight_requests_limit: Optional[int] = None, + client_az: Optional[str] = None, ): super().__init__( addresses=addresses, @@ -452,6 +469,7 @@ def __init__( client_name=client_name, protocol=protocol, inflight_requests_limit=inflight_requests_limit, + client_az=client_az, ) self.periodic_checks = periodic_checks self.pubsub_subscriptions = pubsub_subscriptions diff --git a/python/python/tests/conftest.py b/python/python/tests/conftest.py index 437fbd8fbb..f733361107 100644 --- a/python/python/tests/conftest.py +++ b/python/python/tests/conftest.py @@ -9,6 +9,7 @@ GlideClusterClientConfiguration, NodeAddress, ProtocolVersion, + ReadFrom, ServerCredentials, ) from glide.exceptions import ClosingError, RequestError @@ -132,6 +133,7 @@ def create_clusters(tls, load_module, cluster_endpoints, standalone_endpoints): cluster_mode=True, load_module=load_module, addresses=cluster_endpoints, + replica_count=2, ) pytest.standalone_cluster = ValkeyCluster( tls=tls, @@ -248,6 +250,8 @@ async def create_client( GlideClientConfiguration.PubSubSubscriptions ] = None, inflight_requests_limit: Optional[int] = None, + read_from: ReadFrom = ReadFrom.PRIMARY, + client_az: Optional[str] = None, ) -> Union[GlideClient, GlideClusterClient]: # Create async socket client use_tls = request.config.getoption("--tls") @@ -265,6 +269,8 @@ async def create_client( request_timeout=timeout, pubsub_subscriptions=cluster_mode_pubsub, inflight_requests_limit=inflight_requests_limit, + read_from=read_from, + client_az=client_az, ) return await GlideClusterClient.create(cluster_config) else: @@ -281,6 +287,8 @@ async def create_client( request_timeout=timeout, pubsub_subscriptions=standalone_mode_pubsub, inflight_requests_limit=inflight_requests_limit, + read_from=read_from, + client_az=client_az, ) return await GlideClient.create(config) @@ -381,3 +389,26 @@ async def test_meow_meow(...): reason=f"This feature added in version {min_version}", allow_module_level=True, ) + + +# @pytest.fixture(scope="module") +# def multiple_replicas_cluster(request): +# """ +# Fixture to create a special cluster with 4 replicas for specific tests. +# """ +# tls = request.config.getoption("--tls") +# load_module = request.config.getoption("--load-module") +# cluster_endpoints = request.config.getoption("--cluster-endpoints") + +# if not cluster_endpoints: +# multiple_replica_cluster = ValkeyCluster( +# tls=tls, +# cluster_mode=True, +# load_module=load_module, +# addresses=cluster_endpoints, +# replica_count=4, +# ) +# yield multiple_replica_cluster +# multiple_replica_cluster.__del__() +# else: +# yield None diff --git a/python/python/tests/test_config.py b/python/python/tests/test_config.py index 93c280245f..3b22adb09c 100644 --- a/python/python/tests/test_config.py +++ b/python/python/tests/test_config.py @@ -52,3 +52,18 @@ def test_periodic_checks_interval_to_protobuf(): config.periodic_checks = PeriodicChecksManualInterval(30) request = config._create_a_protobuf_conn_request(cluster_mode=True) assert request.periodic_checks_manual_interval.duration_in_sec == 30 + + +def test_convert_config_with_azaffinity_to_protobuf(): + az = "us-east-1a" + config = BaseClientConfiguration( + [NodeAddress("127.0.0.1")], + use_tls=True, + read_from=ReadFrom.AZ_AFFINITY, + client_az=az, + ) + request = config._create_a_protobuf_conn_request() + assert isinstance(request, ConnectionRequest) + assert request.tls_mode is TlsMode.SecureTls + assert request.read_from == ProtobufReadFrom.AZAffinity + assert request.client_az == az diff --git a/python/python/tests/test_read_from_strategy.py b/python/python/tests/test_read_from_strategy.py new file mode 100644 index 0000000000..429234ec82 --- /dev/null +++ b/python/python/tests/test_read_from_strategy.py @@ -0,0 +1,226 @@ +# Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 + +import re + +import pytest +from glide.async_commands.core import InfoSection +from glide.config import ProtocolVersion, ReadFrom +from glide.constants import OK +from glide.glide_client import GlideClusterClient +from glide.routes import AllNodes, SlotIdRoute, SlotType +from tests.conftest import create_client +from tests.utils.utils import get_first_result + + +@pytest.mark.asyncio +# @pytest.mark.usefixtures("multiple_replicas_cluster") +class TestAZAffinity: + async def _get_num_replicas(self, client: GlideClusterClient) -> int: + info_replicas = get_first_result( + await client.info([InfoSection.REPLICATION]) + ).decode() + match = re.search(r"connected_slaves:(\d+)", info_replicas) + if match: + return int(match.group(1)) + else: + raise ValueError( + "Could not find the number of replicas in the INFO REPLICATION response" + ) + + @pytest.mark.skip_if_version_below("8.0.0") + @pytest.mark.parametrize("cluster_mode", [True]) + @pytest.mark.parametrize("protocol", [ProtocolVersion.RESP2, ProtocolVersion.RESP3]) + async def test_routing_with_az_affinity_strategy_to_1_replica( + self, + request, + cluster_mode: bool, + protocol: ProtocolVersion, + # multiple_replicas_cluster, + ): + """Test that the client with az affinity strategy will only route to the 1 replica with the same az""" + az = "us-east-1a" + GET_CALLS = 3 + get_cmdstat = f"cmdstat_get:calls={GET_CALLS}" + + client_for_config_set = await create_client( + request, + cluster_mode, + # addresses=multiple_replicas_cluster.nodes_addr, + protocol=protocol, + timeout=2000, + ) + + # Reset the availability zone for all nodes + await client_for_config_set.custom_command( + ["CONFIG", "SET", "availability-zone", ""], + route=AllNodes(), + ) + assert await client_for_config_set.config_resetstat() == OK + + # 12182 is the slot of "foo" + await client_for_config_set.custom_command( + ["CONFIG", "SET", "availability-zone", az], + route=SlotIdRoute(SlotType.REPLICA, 12182), + ) + + client_for_testing_az = await create_client( + request, + cluster_mode, + # addresses=multiple_replicas_cluster.nodes_addr, + protocol=protocol, + read_from=ReadFrom.AZ_AFFINITY, + timeout=2000, + client_az=az, + ) + + for _ in range(GET_CALLS): + await client_for_testing_az.get("foo") + + info_result = await client_for_testing_az.info( + [InfoSection.SERVER, InfoSection.COMMAND_STATS], AllNodes() + ) + + # Check that only the replica with az has all the GET calls + matching_entries_count = sum( + 1 + for value in info_result.values() + if get_cmdstat in value.decode() and az in value.decode() + ) + assert matching_entries_count == 1 + + # Check that the other replicas have no availability zone set + changed_az_count = sum( + 1 + for node in info_result.values() + if f"availability_zone:{az}" in node.decode() + ) + assert changed_az_count == 1 + await client_for_testing_az.close() + await client_for_config_set.close() + + @pytest.mark.skip_if_version_below("8.0.0") + @pytest.mark.parametrize("cluster_mode", [True]) + @pytest.mark.parametrize("protocol", [ProtocolVersion.RESP2, ProtocolVersion.RESP3]) + async def test_routing_by_slot_to_replica_with_az_affinity_strategy_to_all_replicas( + self, + request, + cluster_mode: bool, + protocol: ProtocolVersion, + # multiple_replicas_cluster, + ): + """Test that the client with AZ affinity strategy routes in a round-robin manner to all replicas within the specified AZ""" + + az = "us-east-1a" + client_for_config_set = await create_client( + request, + cluster_mode, + # addresses=multiple_replicas_cluster.nodes_addr, + protocol=protocol, + timeout=2000, + ) + assert await client_for_config_set.config_resetstat() == OK + await client_for_config_set.custom_command( + ["CONFIG", "SET", "availability-zone", az], AllNodes() + ) + + client_for_testing_az = await create_client( + request, + cluster_mode, + # addresses=multiple_replicas_cluster.nodes_addr, + protocol=protocol, + read_from=ReadFrom.AZ_AFFINITY, + timeout=2000, + client_az=az, + ) + azs = await client_for_testing_az.custom_command( + ["CONFIG", "GET", "availability-zone"], AllNodes() + ) + + # Check that all replicas have the availability zone set to the az + assert all( + ( + node[1].decode() == az + if isinstance(node, list) + else node[b"availability-zone"].decode() == az + ) + for node in azs.values() + ) + + n_replicas = await self._get_num_replicas(client_for_testing_az) + GET_CALLS = 4 * n_replicas + get_cmdstat = f"cmdstat_get:calls={GET_CALLS // n_replicas}" + + for _ in range(GET_CALLS): + await client_for_testing_az.get("foo") + + info_result = await client_for_testing_az.info( + [InfoSection.COMMAND_STATS, InfoSection.SERVER], AllNodes() + ) + + # Check that all replicas have the same number of GET calls + matching_entries_count = sum( + 1 + for value in info_result.values() + if get_cmdstat in value.decode() and az in value.decode() + ) + assert matching_entries_count == n_replicas + + await client_for_config_set.close() + await client_for_testing_az.close() + + @pytest.mark.skip_if_version_below("8.0.0") + @pytest.mark.parametrize("cluster_mode", [True]) + @pytest.mark.parametrize("protocol", [ProtocolVersion.RESP2, ProtocolVersion.RESP3]) + async def test_az_affinity_non_existing_az( + self, + request, + cluster_mode: bool, + protocol: ProtocolVersion, + # multiple_replicas_cluster, + ): + GET_CALLS = 4 + + client_for_testing_az = await create_client( + request, + cluster_mode, + # addresses=multiple_replicas_cluster.nodes_addr, + protocol=protocol, + read_from=ReadFrom.AZ_AFFINITY, + timeout=2000, + client_az="non-existing-az", + ) + assert await client_for_testing_az.config_resetstat() == OK + + for _ in range(GET_CALLS): + await client_for_testing_az.get("foo") + + n_replicas = await self._get_num_replicas(client_for_testing_az) + # We expect the calls to be distributed evenly among the replicas + get_cmdstat = f"cmdstat_get:calls={GET_CALLS // n_replicas}" + + info_result = await client_for_testing_az.info( + [InfoSection.COMMAND_STATS, InfoSection.SERVER], AllNodes() + ) + + matching_entries_count = sum( + 1 for value in info_result.values() if get_cmdstat in value.decode() + ) + assert matching_entries_count == n_replicas + + await client_for_testing_az.close() + + @pytest.mark.skip_if_version_below("8.0.0") + @pytest.mark.parametrize("cluster_mode", [True]) + @pytest.mark.parametrize("protocol", [ProtocolVersion.RESP2, ProtocolVersion.RESP3]) + async def test_az_affinity_requires_client_az( + self, request, cluster_mode: bool, protocol: ProtocolVersion + ): + """Test that setting read_from to AZ_AFFINITY without client_az raises an error.""" + with pytest.raises(ValueError): + await create_client( + request, + cluster_mode=cluster_mode, + protocol=protocol, + read_from=ReadFrom.AZ_AFFINITY, + timeout=2000, + ) diff --git a/python/python/tests/utils/cluster.py b/python/python/tests/utils/cluster.py index e0bfb231ae..fa17742e7b 100644 --- a/python/python/tests/utils/cluster.py +++ b/python/python/tests/utils/cluster.py @@ -45,7 +45,7 @@ def __init__( stderr=subprocess.PIPE, text=True, ) - output, err = p.communicate(timeout=40) + output, err = p.communicate(timeout=80) if p.returncode != 0: raise Exception(f"Failed to create a cluster. Executed: {p}:\n{err}") self.parse_cluster_script_start_output(output) diff --git a/python/requirements.txt b/python/requirements.txt index 0537d78911..93c90b2cac 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -1,6 +1,6 @@ async-timeout==4.0.2;python_version<"3.11" maturin==0.13.0 -protobuf==3.25.* +protobuf==3.20.* pytest pytest-asyncio typing_extensions==4.8.0;python_version<"3.11" From 99cbcc3d9ceb9e3e72e2f8ba245838b2485df815 Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Wed, 20 Nov 2024 17:19:31 -0800 Subject: [PATCH 4/6] fix merge Signed-off-by: Yury-Fridlyand --- .../python/tests/test_read_from_strategy.py | 226 ------------------ 1 file changed, 226 deletions(-) delete mode 100644 python/python/tests/test_read_from_strategy.py diff --git a/python/python/tests/test_read_from_strategy.py b/python/python/tests/test_read_from_strategy.py deleted file mode 100644 index 429234ec82..0000000000 --- a/python/python/tests/test_read_from_strategy.py +++ /dev/null @@ -1,226 +0,0 @@ -# Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 - -import re - -import pytest -from glide.async_commands.core import InfoSection -from glide.config import ProtocolVersion, ReadFrom -from glide.constants import OK -from glide.glide_client import GlideClusterClient -from glide.routes import AllNodes, SlotIdRoute, SlotType -from tests.conftest import create_client -from tests.utils.utils import get_first_result - - -@pytest.mark.asyncio -# @pytest.mark.usefixtures("multiple_replicas_cluster") -class TestAZAffinity: - async def _get_num_replicas(self, client: GlideClusterClient) -> int: - info_replicas = get_first_result( - await client.info([InfoSection.REPLICATION]) - ).decode() - match = re.search(r"connected_slaves:(\d+)", info_replicas) - if match: - return int(match.group(1)) - else: - raise ValueError( - "Could not find the number of replicas in the INFO REPLICATION response" - ) - - @pytest.mark.skip_if_version_below("8.0.0") - @pytest.mark.parametrize("cluster_mode", [True]) - @pytest.mark.parametrize("protocol", [ProtocolVersion.RESP2, ProtocolVersion.RESP3]) - async def test_routing_with_az_affinity_strategy_to_1_replica( - self, - request, - cluster_mode: bool, - protocol: ProtocolVersion, - # multiple_replicas_cluster, - ): - """Test that the client with az affinity strategy will only route to the 1 replica with the same az""" - az = "us-east-1a" - GET_CALLS = 3 - get_cmdstat = f"cmdstat_get:calls={GET_CALLS}" - - client_for_config_set = await create_client( - request, - cluster_mode, - # addresses=multiple_replicas_cluster.nodes_addr, - protocol=protocol, - timeout=2000, - ) - - # Reset the availability zone for all nodes - await client_for_config_set.custom_command( - ["CONFIG", "SET", "availability-zone", ""], - route=AllNodes(), - ) - assert await client_for_config_set.config_resetstat() == OK - - # 12182 is the slot of "foo" - await client_for_config_set.custom_command( - ["CONFIG", "SET", "availability-zone", az], - route=SlotIdRoute(SlotType.REPLICA, 12182), - ) - - client_for_testing_az = await create_client( - request, - cluster_mode, - # addresses=multiple_replicas_cluster.nodes_addr, - protocol=protocol, - read_from=ReadFrom.AZ_AFFINITY, - timeout=2000, - client_az=az, - ) - - for _ in range(GET_CALLS): - await client_for_testing_az.get("foo") - - info_result = await client_for_testing_az.info( - [InfoSection.SERVER, InfoSection.COMMAND_STATS], AllNodes() - ) - - # Check that only the replica with az has all the GET calls - matching_entries_count = sum( - 1 - for value in info_result.values() - if get_cmdstat in value.decode() and az in value.decode() - ) - assert matching_entries_count == 1 - - # Check that the other replicas have no availability zone set - changed_az_count = sum( - 1 - for node in info_result.values() - if f"availability_zone:{az}" in node.decode() - ) - assert changed_az_count == 1 - await client_for_testing_az.close() - await client_for_config_set.close() - - @pytest.mark.skip_if_version_below("8.0.0") - @pytest.mark.parametrize("cluster_mode", [True]) - @pytest.mark.parametrize("protocol", [ProtocolVersion.RESP2, ProtocolVersion.RESP3]) - async def test_routing_by_slot_to_replica_with_az_affinity_strategy_to_all_replicas( - self, - request, - cluster_mode: bool, - protocol: ProtocolVersion, - # multiple_replicas_cluster, - ): - """Test that the client with AZ affinity strategy routes in a round-robin manner to all replicas within the specified AZ""" - - az = "us-east-1a" - client_for_config_set = await create_client( - request, - cluster_mode, - # addresses=multiple_replicas_cluster.nodes_addr, - protocol=protocol, - timeout=2000, - ) - assert await client_for_config_set.config_resetstat() == OK - await client_for_config_set.custom_command( - ["CONFIG", "SET", "availability-zone", az], AllNodes() - ) - - client_for_testing_az = await create_client( - request, - cluster_mode, - # addresses=multiple_replicas_cluster.nodes_addr, - protocol=protocol, - read_from=ReadFrom.AZ_AFFINITY, - timeout=2000, - client_az=az, - ) - azs = await client_for_testing_az.custom_command( - ["CONFIG", "GET", "availability-zone"], AllNodes() - ) - - # Check that all replicas have the availability zone set to the az - assert all( - ( - node[1].decode() == az - if isinstance(node, list) - else node[b"availability-zone"].decode() == az - ) - for node in azs.values() - ) - - n_replicas = await self._get_num_replicas(client_for_testing_az) - GET_CALLS = 4 * n_replicas - get_cmdstat = f"cmdstat_get:calls={GET_CALLS // n_replicas}" - - for _ in range(GET_CALLS): - await client_for_testing_az.get("foo") - - info_result = await client_for_testing_az.info( - [InfoSection.COMMAND_STATS, InfoSection.SERVER], AllNodes() - ) - - # Check that all replicas have the same number of GET calls - matching_entries_count = sum( - 1 - for value in info_result.values() - if get_cmdstat in value.decode() and az in value.decode() - ) - assert matching_entries_count == n_replicas - - await client_for_config_set.close() - await client_for_testing_az.close() - - @pytest.mark.skip_if_version_below("8.0.0") - @pytest.mark.parametrize("cluster_mode", [True]) - @pytest.mark.parametrize("protocol", [ProtocolVersion.RESP2, ProtocolVersion.RESP3]) - async def test_az_affinity_non_existing_az( - self, - request, - cluster_mode: bool, - protocol: ProtocolVersion, - # multiple_replicas_cluster, - ): - GET_CALLS = 4 - - client_for_testing_az = await create_client( - request, - cluster_mode, - # addresses=multiple_replicas_cluster.nodes_addr, - protocol=protocol, - read_from=ReadFrom.AZ_AFFINITY, - timeout=2000, - client_az="non-existing-az", - ) - assert await client_for_testing_az.config_resetstat() == OK - - for _ in range(GET_CALLS): - await client_for_testing_az.get("foo") - - n_replicas = await self._get_num_replicas(client_for_testing_az) - # We expect the calls to be distributed evenly among the replicas - get_cmdstat = f"cmdstat_get:calls={GET_CALLS // n_replicas}" - - info_result = await client_for_testing_az.info( - [InfoSection.COMMAND_STATS, InfoSection.SERVER], AllNodes() - ) - - matching_entries_count = sum( - 1 for value in info_result.values() if get_cmdstat in value.decode() - ) - assert matching_entries_count == n_replicas - - await client_for_testing_az.close() - - @pytest.mark.skip_if_version_below("8.0.0") - @pytest.mark.parametrize("cluster_mode", [True]) - @pytest.mark.parametrize("protocol", [ProtocolVersion.RESP2, ProtocolVersion.RESP3]) - async def test_az_affinity_requires_client_az( - self, request, cluster_mode: bool, protocol: ProtocolVersion - ): - """Test that setting read_from to AZ_AFFINITY without client_az raises an error.""" - with pytest.raises(ValueError): - await create_client( - request, - cluster_mode=cluster_mode, - protocol=protocol, - read_from=ReadFrom.AZ_AFFINITY, - timeout=2000, - ) From c8d155d8b4da1156b4ba2d56a085a29b71df3613 Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Wed, 20 Nov 2024 17:21:06 -0800 Subject: [PATCH 5/6] fix merge Signed-off-by: Yury-Fridlyand --- python/python/glide/config.py | 18 ---------------- python/python/tests/conftest.py | 31 ---------------------------- python/python/tests/test_config.py | 15 -------------- python/python/tests/utils/cluster.py | 2 +- 4 files changed, 1 insertion(+), 65 deletions(-) diff --git a/python/python/glide/config.py b/python/python/glide/config.py index b33c037cbf..db85202876 100644 --- a/python/python/glide/config.py +++ b/python/python/glide/config.py @@ -41,11 +41,6 @@ class ReadFrom(Enum): Spread the requests between all replicas in a round robin manner. If no replica is available, route the requests to the primary. """ - AZ_AFFINITY = ProtobufReadFrom.AZAffinity - """ - Spread the read requests between replicas in the same client's AZ (Aviliablity zone) in a round robin manner, - falling back to other replicas or the primary if needed - """ class ProtocolVersion(Enum): @@ -140,7 +135,6 @@ def __init__( client_name: Optional[str] = None, protocol: ProtocolVersion = ProtocolVersion.RESP3, inflight_requests_limit: Optional[int] = None, - client_az: Optional[str] = None, ): """ Represents the configuration settings for a Glide client. @@ -178,12 +172,6 @@ def __init__( self.client_name = client_name self.protocol = protocol self.inflight_requests_limit = inflight_requests_limit - self.client_az = client_az - - if read_from == ReadFrom.AZ_AFFINITY and not client_az: - raise ValueError( - "client_az mus t be set when read_from is set to AZ_AFFINITY" - ) def _create_a_protobuf_conn_request( self, cluster_mode: bool = False @@ -216,8 +204,6 @@ def _create_a_protobuf_conn_request( request.protocol = self.protocol.value if self.inflight_requests_limit: request.inflight_requests_limit = self.inflight_requests_limit - if self.client_az: - request.client_az = self.client_az return request @@ -307,7 +293,6 @@ def __init__( protocol: ProtocolVersion = ProtocolVersion.RESP3, pubsub_subscriptions: Optional[PubSubSubscriptions] = None, inflight_requests_limit: Optional[int] = None, - client_az: Optional[str] = None, ): super().__init__( addresses=addresses, @@ -318,7 +303,6 @@ def __init__( client_name=client_name, protocol=protocol, inflight_requests_limit=inflight_requests_limit, - client_az=client_az, ) self.reconnect_strategy = reconnect_strategy self.database_id = database_id @@ -458,7 +442,6 @@ def __init__( ] = PeriodicChecksStatus.ENABLED_DEFAULT_CONFIGS, pubsub_subscriptions: Optional[PubSubSubscriptions] = None, inflight_requests_limit: Optional[int] = None, - client_az: Optional[str] = None, ): super().__init__( addresses=addresses, @@ -469,7 +452,6 @@ def __init__( client_name=client_name, protocol=protocol, inflight_requests_limit=inflight_requests_limit, - client_az=client_az, ) self.periodic_checks = periodic_checks self.pubsub_subscriptions = pubsub_subscriptions diff --git a/python/python/tests/conftest.py b/python/python/tests/conftest.py index f733361107..437fbd8fbb 100644 --- a/python/python/tests/conftest.py +++ b/python/python/tests/conftest.py @@ -9,7 +9,6 @@ GlideClusterClientConfiguration, NodeAddress, ProtocolVersion, - ReadFrom, ServerCredentials, ) from glide.exceptions import ClosingError, RequestError @@ -133,7 +132,6 @@ def create_clusters(tls, load_module, cluster_endpoints, standalone_endpoints): cluster_mode=True, load_module=load_module, addresses=cluster_endpoints, - replica_count=2, ) pytest.standalone_cluster = ValkeyCluster( tls=tls, @@ -250,8 +248,6 @@ async def create_client( GlideClientConfiguration.PubSubSubscriptions ] = None, inflight_requests_limit: Optional[int] = None, - read_from: ReadFrom = ReadFrom.PRIMARY, - client_az: Optional[str] = None, ) -> Union[GlideClient, GlideClusterClient]: # Create async socket client use_tls = request.config.getoption("--tls") @@ -269,8 +265,6 @@ async def create_client( request_timeout=timeout, pubsub_subscriptions=cluster_mode_pubsub, inflight_requests_limit=inflight_requests_limit, - read_from=read_from, - client_az=client_az, ) return await GlideClusterClient.create(cluster_config) else: @@ -287,8 +281,6 @@ async def create_client( request_timeout=timeout, pubsub_subscriptions=standalone_mode_pubsub, inflight_requests_limit=inflight_requests_limit, - read_from=read_from, - client_az=client_az, ) return await GlideClient.create(config) @@ -389,26 +381,3 @@ async def test_meow_meow(...): reason=f"This feature added in version {min_version}", allow_module_level=True, ) - - -# @pytest.fixture(scope="module") -# def multiple_replicas_cluster(request): -# """ -# Fixture to create a special cluster with 4 replicas for specific tests. -# """ -# tls = request.config.getoption("--tls") -# load_module = request.config.getoption("--load-module") -# cluster_endpoints = request.config.getoption("--cluster-endpoints") - -# if not cluster_endpoints: -# multiple_replica_cluster = ValkeyCluster( -# tls=tls, -# cluster_mode=True, -# load_module=load_module, -# addresses=cluster_endpoints, -# replica_count=4, -# ) -# yield multiple_replica_cluster -# multiple_replica_cluster.__del__() -# else: -# yield None diff --git a/python/python/tests/test_config.py b/python/python/tests/test_config.py index 3b22adb09c..93c280245f 100644 --- a/python/python/tests/test_config.py +++ b/python/python/tests/test_config.py @@ -52,18 +52,3 @@ def test_periodic_checks_interval_to_protobuf(): config.periodic_checks = PeriodicChecksManualInterval(30) request = config._create_a_protobuf_conn_request(cluster_mode=True) assert request.periodic_checks_manual_interval.duration_in_sec == 30 - - -def test_convert_config_with_azaffinity_to_protobuf(): - az = "us-east-1a" - config = BaseClientConfiguration( - [NodeAddress("127.0.0.1")], - use_tls=True, - read_from=ReadFrom.AZ_AFFINITY, - client_az=az, - ) - request = config._create_a_protobuf_conn_request() - assert isinstance(request, ConnectionRequest) - assert request.tls_mode is TlsMode.SecureTls - assert request.read_from == ProtobufReadFrom.AZAffinity - assert request.client_az == az diff --git a/python/python/tests/utils/cluster.py b/python/python/tests/utils/cluster.py index fa17742e7b..e0bfb231ae 100644 --- a/python/python/tests/utils/cluster.py +++ b/python/python/tests/utils/cluster.py @@ -45,7 +45,7 @@ def __init__( stderr=subprocess.PIPE, text=True, ) - output, err = p.communicate(timeout=80) + output, err = p.communicate(timeout=40) if p.returncode != 0: raise Exception(f"Failed to create a cluster. Executed: {p}:\n{err}") self.parse_cluster_script_start_output(output) From ed9cf15c9f8aa1b16450c92b6f853e905b5aa7d6 Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Tue, 3 Dec 2024 10:25:24 -0800 Subject: [PATCH 6/6] changelog Signed-off-by: Yury-Fridlyand --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e52f9b2161..dd3059aaef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +#### Changes + +#### Breaking Changes + +#### Fixes + +#### Operational Enhancements + +## 1.2.0 (2024-11-27) + #### Changes * Node: Client API for retrieving internal statistics ([#2727](https://github.com/valkey-io/valkey-glide/pull/2727)) * Python: Client API for retrieving internal statistics ([#2707](https://github.com/valkey-io/valkey-glide/pull/2707))