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

Update CONFIG GET and CONFIG SET documentation and tests #2919

Merged
merged 27 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8339482
Update documentation for CONFIG GET and CONFIG SET commands for Java …
jonathanl-bq Jan 6, 2025
e58bfd6
Update documentation for BaseTransaction CONFIG GET and CONFIG SET
jonathanl-bq Jan 6, 2025
2c4cca3
Add transaction test for CONFIG SET and CONFIG GET with multiple para…
jonathanl-bq Jan 6, 2025
ff274c8
Update Python client CONFIG SET and CONFIG GET docs and tests
jonathanl-bq Jan 7, 2025
accc928
Update Python transaction CONFIG GET and CONFIG SET docs
jonathanl-bq Jan 7, 2025
e9aa5f2
Update Node client docs and tests for CONFIG SET and CONFIG GET
jonathanl-bq Jan 7, 2025
03df33e
Update CHANGELOG
jonathanl-bq Jan 7, 2025
57b80eb
Fix linter issue
jonathanl-bq Jan 7, 2025
296d5cc
Merge branch 'main' into update-config-get-config-set-docs
jonathanl-bq Jan 7, 2025
94967ef
Fix Prettier issues
jonathanl-bq Jan 7, 2025
8fd4ad2
Apply Spotless
jonathanl-bq Jan 7, 2025
f9a38a3
Add missing cluster argument for Node SharedTests
jonathanl-bq Jan 7, 2025
b75e286
Try changing cluster-node-timeout instead of logfile to avoid immutab…
jonathanl-bq Jan 7, 2025
62ec79d
Fix test failures for Node client
jonathanl-bq Jan 8, 2025
1dd027b
Fix linting errors
jonathanl-bq Jan 8, 2025
594b918
Sort expected result for CONFIG GET and CONFIG SET transaction test
jonathanl-bq Jan 8, 2025
c08410a
Assign sorted array to new variable
jonathanl-bq Jan 8, 2025
aa604c9
Apply Black linter
jonathanl-bq Jan 8, 2025
833e9aa
Update Python tests to avoid immutable config error
jonathanl-bq Jan 8, 2025
fe096b0
Apply Black linter
jonathanl-bq Jan 8, 2025
0547a8f
Fix typo
jonathanl-bq Jan 8, 2025
9408c87
Fix typo in Python tests
jonathanl-bq Jan 8, 2025
7928f92
Run Black linter
jonathanl-bq Jan 8, 2025
1a0c1c0
Fix failing Node test
jonathanl-bq Jan 8, 2025
9baf9f4
Remove swap file
jonathanl-bq Jan 9, 2025
13604e8
Combine CONFIG GET and CONFIG SET tests in SharedTests.ts
jonathanl-bq Jan 9, 2025
a007819
Fix build error
jonathanl-bq Jan 9, 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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* Go: Add `ZPopMin` and `ZPopMax` ([#2850](https://github.com/valkey-io/valkey-glide/pull/2850))
* Java: Add binary version of `ZRANK WITHSCORE` ([#2896](https://github.com/valkey-io/valkey-glide/pull/2896))
* Go: Add `ZCARD` ([#2838](https://github.com/valkey-io/valkey-glide/pull/2838))
* Java, Node, Python: Update documentation for CONFIG SET and CONFIG GET ([#2919](https://github.com/valkey-io/valkey-glide/pull/2919))
* Go: Add `BZPopMin` ([#2849](https://github.com/valkey-io/valkey-glide/pull/2849))

#### Breaking Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public interface ServerManagementClusterCommands {

/**
* Get the values of configuration parameters.<br>
* Starting from server version 7, command supports multiple parameters.<br>
* The command will be sent to a random node.
*
* @see <a href="https://valkey.io/commands/config-get/">valkey.io</a> for details.
Expand All @@ -186,7 +187,8 @@ public interface ServerManagementClusterCommands {
CompletableFuture<Map<String, String>> configGet(String[] parameters);

/**
* Get the values of configuration parameters.
* Get the values of configuration parameters.<br>
* Starting from server version 7, command supports multiple parameters.
*
* @see <a href="https://valkey.io/commands/config-get/">valkey.io</a> for details.
* @param parameters An <code>array</code> of configuration parameter names to retrieve values
Expand All @@ -210,6 +212,7 @@ public interface ServerManagementClusterCommands {

/**
* Sets configuration parameters to the specified values.<br>
* Starting from server version 7, command supports multiple parameters.<br>
* The command will be sent to all nodes.
*
* @see <a href="https://valkey.io/commands/config-set/">valkey.io</a> for details.
Expand All @@ -226,7 +229,8 @@ public interface ServerManagementClusterCommands {
CompletableFuture<String> configSet(Map<String, String> parameters);

/**
* Sets configuration parameters to the specified values.
* Sets configuration parameters to the specified values.<br>
* Starting from server version 7, command supports multiple parameters.
*
* @see <a href="https://valkey.io/commands/config-set/">valkey.io</a> for details.
* @param parameters A <code>map</code> consisting of configuration parameters and their
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ public interface ServerManagementCommands {
CompletableFuture<String> configResetStat();

/**
* Get the values of configuration parameters.
* Get the values of configuration parameters.<br>
* Starting from server version 7, command supports multiple parameters.
*
* @see <a href="https://valkey.io/commands/config-get/">valkey.io</a> for details.
* @param parameters An <code>array</code> of configuration parameter names to retrieve values
Expand All @@ -105,7 +106,8 @@ public interface ServerManagementCommands {
CompletableFuture<Map<String, String>> configGet(String[] parameters);

/**
* Sets configuration parameters to the specified values.
* Sets configuration parameters to the specified values.<br>
* Starting from server version 7, command supports multiple parameters.
*
* @see <a href="https://valkey.io/commands/config-set/">valkey.io</a> for details.
* @param parameters A <code>map</code> consisting of configuration parameters and their
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1648,7 +1648,8 @@ public <ArgType> T sunionstore(@NonNull ArgType destination, @NonNull ArgType[]
}

/**
* Reads the configuration parameters of the running server.
* Reads the configuration parameters of the running server.<br>
* Starting from server version 7, command supports multiple parameters.
*
* @implNote {@link ArgType} is limited to {@link String} or {@link GlideString}, any other type
* will throw {@link IllegalArgumentException}.
Expand All @@ -1665,7 +1666,8 @@ public <ArgType> T configGet(@NonNull ArgType[] parameters) {
}

/**
* Sets configuration parameters to the specified values.
* Sets configuration parameters to the specified values.<br>
* Starting from server version 7, command supports multiple parameters.
*
* @implNote {@link ArgType} is limited to {@link String} or {@link GlideString}, any other type
* will throw {@link IllegalArgumentException}.
Expand Down
45 changes: 34 additions & 11 deletions java/integTest/src/test/java/glide/TransactionTestUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -813,17 +813,40 @@ private static Object[] serverManagementCommands(BaseTransaction<?> transaction)
.flushdb(ASYNC)
.dbsize();

return new Object[] {
OK, // configSet(Map.of("timeout", "1000"))
Map.of("timeout", "1000"), // configGet(new String[] {"timeout"})
OK, // configResetStat()
"Redis ver. " + SERVER_VERSION + '\n', // lolwut(1)
OK, // flushall()
OK, // flushall(ASYNC)
OK, // flushdb()
OK, // flushdb(ASYNC)
0L, // dbsize()
};
if (SERVER_VERSION.isGreaterThanOrEqualTo("7.0.0")) {
transaction
.configSet(Map.of("timeout", "2000", "rdb-save-incremental-fsync", "no"))
.configGet(new String[] {"timeout", "rdb-save-incremental-fsync"});
}

var expectedResults =
new Object[] {
OK, // configSet(Map.of("timeout", "1000"))
Map.of("timeout", "1000"), // configGet(new String[] {"timeout"})
OK, // configResetStat()
"Redis ver. " + SERVER_VERSION + '\n', // lolwut(1)
OK, // flushall()
OK, // flushall(ASYNC)
OK, // flushdb()
OK, // flushdb(ASYNC)
0L, // dbsize()
};

if (SERVER_VERSION.isGreaterThanOrEqualTo("7.0.0")) {
expectedResults =
concatenateArrays(
expectedResults,
new Object[] {
OK, // configSet(Map.of("timeout", "2000", "rdb-save-incremental-fsync", "no"))
Map.of(
"timeout",
"2000",
"rdb-save-incremental-fsync",
"no"), // configGet(new String[] {"timeout", "rdb-save-incremental-fsync"})
});
}

return expectedResults;
}

private static Object[] connectionManagementCommands(BaseTransaction<?> transaction) {
Expand Down
2 changes: 2 additions & 0 deletions node/src/GlideClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ export class GlideClient extends BaseClient {

/**
* Reads the configuration parameters of the running server.
* Starting from server version 7, command supports multiple parameters.
*
* @see {@link https://valkey.io/commands/config-get/|valkey.io} for details.
*
Expand Down Expand Up @@ -517,6 +518,7 @@ export class GlideClient extends BaseClient {

/**
* Sets configuration parameters to the specified values.
* Starting from server version 7, command supports multiple parameters.
*
* @see {@link https://valkey.io/commands/config-set/|valkey.io} for details.
* @param parameters - A map consisting of configuration parameters and their respective values to set.
Expand Down
2 changes: 2 additions & 0 deletions node/src/GlideClusterClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,7 @@ export class GlideClusterClient extends BaseClient {

/**
* Reads the configuration parameters of the running server.
* Starting from server version 7, command supports multiple parameters.
*
* The command will be routed to a random node, unless `route` is provided.
*
Expand Down Expand Up @@ -981,6 +982,7 @@ export class GlideClusterClient extends BaseClient {

/**
* Sets configuration parameters to the specified values.
* Starting from server version 7, command supports multiple parameters.
*
* The command will be routed to all nodes, unless `route` is provided.
*
Expand Down
2 changes: 2 additions & 0 deletions node/src/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ export class BaseTransaction<T extends BaseTransaction<T>> {

/**
* Reads the configuration parameters of the running server.
* Starting from server version 7, command supports multiple parameters.
*
* @see {@link https://valkey.io/commands/config-get/|valkey.io} for details.
*
Expand All @@ -758,6 +759,7 @@ export class BaseTransaction<T extends BaseTransaction<T>> {

/**
* Sets configuration parameters to the specified values.
* Starting from server version 7, command supports multiple parameters.
*
* @see {@link https://valkey.io/commands/config-set/|valkey.io} for details.
*
Expand Down
22 changes: 22 additions & 0 deletions node/tests/GlideClusterClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
SlotKeyTypes,
SortOrder,
convertRecordToGlideRecord,
convertGlideRecordToRecord,
} from "..";
import { ValkeyCluster } from "../../utils/TestUtils";
import { runBaseTests } from "./SharedTests";
Expand Down Expand Up @@ -323,6 +324,27 @@ describe("GlideClusterClient", () => {
"OK",
convertRecordToGlideRecord({ timeout: "1000" }),
]);

if (!cluster.checkIfServerVersionLessThan("7.0.0")) {
const transaction = new ClusterTransaction()
.configSet({
timeout: "2000",
"cluster-node-timeout": "16000",
})
.configGet(["timeout", "cluster-node-timeout"]);
const result = await client.exec(transaction);
const convertedResult = [
result[0],
convertGlideRecordToRecord(result[1]),
];
expect(convertedResult).toEqual([
"OK",
{
timeout: "2000",
"cluster-node-timeout": "16000",
},
]);
}
},
TIMEOUT,
);
Expand Down
35 changes: 33 additions & 2 deletions node/tests/SharedTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1206,9 +1206,9 @@ export function runBaseTests(config: {
);

it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
`config get and config set with timeout parameter_%p`,
`config get and config set with multiple parameters_%p`,
async (protocol) => {
await runTest(async (client: BaseClient) => {
await runTest(async (client: BaseClient, cluster) => {
const prevTimeout = (await client.configGet([
"timeout",
])) as Record<string, GlideString>;
Expand All @@ -1225,6 +1225,37 @@ export function runBaseTests(config: {
timeout: prevTimeout["timeout"],
}),
).toEqual("OK");

if (!cluster.checkIfServerVersionLessThan("7.0.0")) {
const prevTimeout = (await client.configGet([
"timeout",
])) as Record<string, GlideString>;
const prevClusterNodeTimeout = (await client.configGet([
"cluster-node-timeout",
])) as Record<string, GlideString>;
expect(
await client.configSet({
timeout: "1000",
"cluster-node-timeout": "16000",
}),
).toEqual("OK");
const currParameterValues = (await client.configGet([
"timeout",
"cluster-node-timeout",
])) as Record<string, GlideString>;
expect(currParameterValues).toEqual({
timeout: "1000",
"cluster-node-timeout": "16000",
});
/// Revert to the previous configuration
expect(
await client.configSet({
timeout: prevTimeout["timeout"],
"cluster-node-timeout":
prevClusterNodeTimeout["cluster-node-timeout"],
}),
).toEqual("OK");
}
}, protocol);
},
config.timeout,
Expand Down
2 changes: 2 additions & 0 deletions python/python/glide/async_commands/cluster_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ async def config_get(
) -> TClusterResponse[Dict[bytes, bytes]]:
"""
Get the values of configuration parameters.
Starting from server version 7, command supports multiple parameters.
See https://valkey.io/commands/config-get/ for details.

Args:
Expand Down Expand Up @@ -236,6 +237,7 @@ async def config_set(
) -> TOK:
"""
Set configuration parameters to the specified values.
Starting from server version 7, command supports multiple parameters.
See https://valkey.io/commands/config-set/ for details.

Args:
Expand Down
2 changes: 2 additions & 0 deletions python/python/glide/async_commands/standalone_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ async def ping(self, message: Optional[TEncodable] = None) -> bytes:
async def config_get(self, parameters: List[TEncodable]) -> Dict[bytes, bytes]:
"""
Get the values of configuration parameters.
Starting from server version 7, command supports multiple parameters.
See https://valkey.io/commands/config-get/ for details.

Args:
Expand All @@ -175,6 +176,7 @@ async def config_get(self, parameters: List[TEncodable]) -> Dict[bytes, bytes]:
async def config_set(self, parameters_map: Mapping[TEncodable, TEncodable]) -> TOK:
"""
Set configuration parameters to the specified values.
Starting from server version 7, command supports multiple parameters.
See https://valkey.io/commands/config-set/ for details.

Args:
Expand Down
2 changes: 2 additions & 0 deletions python/python/glide/async_commands/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ def delete(self: TTransaction, keys: List[TEncodable]) -> TTransaction:
def config_get(self: TTransaction, parameters: List[TEncodable]) -> TTransaction:
"""
Get the values of configuration parameters.
Starting from server version 7, command supports multiple parameters.
See https://valkey.io/commands/config-get/ for details.

Args:
Expand All @@ -329,6 +330,7 @@ def config_set(
) -> TTransaction:
"""
Set configuration parameters to the specified values.
Starting from server version 7, command supports multiple parameters.
See https://valkey.io/commands/config-set/ for details.

Args:
Expand Down
40 changes: 40 additions & 0 deletions python/python/tests/test_async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,46 @@ async def test_config_get_set(self, glide_client: TGlideClient):
== OK
)

if not await check_if_server_version_lt(glide_client, "7.0.0"):
previous_timeout = await glide_client.config_get(["timeout"])
previous_cluster_node_timeout = await glide_client.config_get(
["cluster-node-timeout"]
)
assert (
await glide_client.config_set(
{"timeout": "2000", "cluster-node-timeout": "16000"}
)
== OK
)
assert await glide_client.config_get(
["timeout", "cluster-node-timeout"]
) == {
b"timeout": b"2000",
b"cluster-node-timeout": b"16000",
}
# revert changes to previous timeout
previous_timeout_decoded = convert_bytes_to_string_object(previous_timeout)
previous_cluster_node_timeout_decoded = convert_bytes_to_string_object(
previous_cluster_node_timeout
)
assert isinstance(previous_timeout_decoded, dict)
assert isinstance(previous_cluster_node_timeout_decoded, dict)
assert isinstance(previous_timeout_decoded["timeout"], str)
assert isinstance(
previous_cluster_node_timeout_decoded["cluster-node-timeout"], str
)
assert (
await glide_client.config_set(
{
"timeout": previous_timeout_decoded["timeout"],
"cluster-node-timeout": previous_cluster_node_timeout_decoded[
"cluster-node-timeout"
],
}
)
== OK
)

@pytest.mark.parametrize("cluster_mode", [True])
@pytest.mark.parametrize("protocol", [ProtocolVersion.RESP2, ProtocolVersion.RESP3])
async def test_config_get_with_wildcard_and_multi_node_route(
Expand Down
5 changes: 5 additions & 0 deletions python/python/tests/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,11 @@ async def transaction_test(
args.append(OK)
transaction.config_get(["timeout"])
args.append({b"timeout": b"1000"})
if not await check_if_server_version_lt(glide_client, "7.0.0"):
transaction.config_set({"timeout": "2000", "cluster-node-timeout": "16000"})
args.append(OK)
transaction.config_get(["timeout", "cluster-node-timeout"])
args.append({b"timeout": b"2000", b"cluster-node-timeout": b"16000"})

transaction.hset(key4, {key: value, key2: value2})
args.append(2)
Expand Down
Loading