Skip to content

Commit

Permalink
Update CONFIG GET and CONFIG SET documentation and tests (#2919)
Browse files Browse the repository at this point in the history
* Update documentation for CONFIG GET and CONFIG SET commands for Java client

Signed-off-by: Jonathan Louie <[email protected]>

* Update documentation for BaseTransaction CONFIG GET and CONFIG SET

Signed-off-by: Jonathan Louie <[email protected]>

* Add transaction test for CONFIG SET and CONFIG GET with multiple parameters

Signed-off-by: Jonathan Louie <[email protected]>

* Update Python client CONFIG SET and CONFIG GET docs and tests

Signed-off-by: Jonathan Louie <[email protected]>

* Update Python transaction CONFIG GET and CONFIG SET docs

Signed-off-by: Jonathan Louie <[email protected]>

* Update Node client docs and tests for CONFIG SET and CONFIG GET

Signed-off-by: Jonathan Louie <[email protected]>

* Update CHANGELOG

Signed-off-by: Jonathan Louie <[email protected]>

* Fix linter issue

Signed-off-by: Jonathan Louie <[email protected]>

* Fix Prettier issues

Signed-off-by: Jonathan Louie <[email protected]>

* Apply Spotless

Signed-off-by: Jonathan Louie <[email protected]>

* Add missing cluster argument for Node SharedTests

Signed-off-by: Jonathan Louie <[email protected]>

* Try changing cluster-node-timeout instead of logfile to avoid immutable config error

Signed-off-by: Jonathan Louie <[email protected]>

* Fix test failures for Node client

Signed-off-by: Jonathan Louie <[email protected]>

* Fix linting errors

Signed-off-by: Jonathan Louie <[email protected]>

* Sort expected result for CONFIG GET and CONFIG SET transaction test

Signed-off-by: Jonathan Louie <[email protected]>

* Assign sorted array to new variable

Signed-off-by: Jonathan Louie <[email protected]>

* Apply Black linter

Signed-off-by: Jonathan Louie <[email protected]>

* Update Python tests to avoid immutable config error

Signed-off-by: Jonathan Louie <[email protected]>

* Apply Black linter

Signed-off-by: Jonathan Louie <[email protected]>

* Fix typo

Signed-off-by: Jonathan Louie <[email protected]>

* Fix typo in Python tests

Signed-off-by: Jonathan Louie <[email protected]>

* Run Black linter

Signed-off-by: Jonathan Louie <[email protected]>

* Fix failing Node test

Signed-off-by: Jonathan Louie <[email protected]>

* Remove swap file

Signed-off-by: Jonathan Louie <[email protected]>

* Combine CONFIG GET and CONFIG SET tests in SharedTests.ts

Signed-off-by: Jonathan Louie <[email protected]>

* Fix build error

Signed-off-by: Jonathan Louie <[email protected]>

---------

Signed-off-by: Jonathan Louie <[email protected]>
Signed-off-by: jonathanl-bq <[email protected]>
  • Loading branch information
jonathanl-bq authored Jan 10, 2025
1 parent 4334c54 commit 52b51dc
Show file tree
Hide file tree
Showing 15 changed files with 161 additions and 19 deletions.
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

0 comments on commit 52b51dc

Please sign in to comment.