Skip to content

Commit

Permalink
Fix redis 6.2.14 installation
Browse files Browse the repository at this point in the history
  • Loading branch information
shohamazon authored Jan 1, 2024
1 parent 51f5756 commit 88329f3
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/install-redis-modules/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ runs:
with:
repository: "RedisJSON/RedisJSON"
path: "./redisjson"
ref: ${{ startsWith(inputs.redis-version, '6') && '2.6' || '' }}
ref: ${{ startsWith(inputs.redis-version, '6') && 'v2.6.0' || '' }}
submodules: recursive

- name: Build RedisJSON
Expand Down
17 changes: 11 additions & 6 deletions .github/workflows/install-redis/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ runs:
using: "composite"

steps:
- run: mkdir ~/redis-binaries
- run: mkdir -p ~/redis-binaries/${{ inputs.redis-version }}
shell: bash

- uses: actions/checkout@v4
Expand All @@ -24,9 +24,9 @@ runs:
id: cache-redis
with:
path: |
~/redis-binaries/redis-cli
~/redis-binaries/redis-server
key: ${{ runner.os }}-install-redis
~/redis-binaries/${{ inputs.redis-version }}/redis-cli
~/redis-binaries/${{ inputs.redis-version }}/redis-server
key: ${{ runner.os }}-${{ inputs.redis-version }}-install-redis

- name: Install redis
shell: bash
Expand All @@ -35,8 +35,13 @@ runs:
sudo apt-get update
wget https://github.com/redis/redis/archive/${{ inputs.redis-version }}.tar.gz;
tar -xzvf ${{ inputs.redis-version }}.tar.gz;
pushd redis-${{ inputs.redis-version }} && BUILD_TLS=yes make && sudo mv src/redis-server src/redis-cli ~/redis-binaries && popd;
pushd redis-${{ inputs.redis-version }} && BUILD_TLS=yes make && sudo mv src/redis-server src/redis-cli ~/redis-binaries/${{ inputs.redis-version }} && popd;
- name: Remove the source package
shell: bash
if: steps.cache-redis.outputs.cache-hit != 'true'
run: sudo rm -r redis-${{ inputs.redis-version }}

- name: Copy executable to place
shell: bash
run: sudo cp ~/redis-binaries/redis-server ~/redis-binaries/redis-cli /usr/bin/
run: sudo cp ~/redis-binaries/${{ inputs.redis-version }}/redis-server ~/redis-binaries/${{ inputs.redis-version }}/redis-cli /usr/bin/
11 changes: 7 additions & 4 deletions node/tests/RedisClusterClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
RedisClusterClient,
} from "../";
import { runBaseTests } from "./SharedTests";
import { flushallOnPort, transactionTest } from "./TestUtilities";
import { flushallOnPort, getFirstResult, transactionTest } from "./TestUtilities";

type Context = {
client: RedisClusterClient;
Expand Down Expand Up @@ -152,8 +152,12 @@ describe("RedisClusterClient", () => {
const client = await RedisClusterClient.createClient(
getOptions(cluster.ports())
);
const result = (await client.info([
const info_server = getFirstResult(await client.info([
InfoOptions.Server,
]));
expect(info_server).toEqual(expect.stringContaining("# Server"));

const result = (await client.info([
InfoOptions.Replication,
])) as Record<string, string>;
const clusterNodes = await client.customCommand([
Expand All @@ -164,7 +168,6 @@ describe("RedisClusterClient", () => {
(clusterNodes as string)?.split("master").length - 1
).toEqual(Object.keys(result).length);
Object.values(result).every((item) => {
expect(item).toEqual(expect.stringContaining("# Server"));
expect(item).toEqual(expect.stringContaining("# Replication"));
expect(item).toEqual(
expect.not.stringContaining("# Errorstats")
Expand Down Expand Up @@ -217,7 +220,7 @@ describe("RedisClusterClient", () => {
);
const transaction = new ClusterTransaction();
const expectedRes = transactionTest(transaction);
const result = await client.exec(transaction);
const result = await client.exec(transaction)
expect(result).toEqual(expectedRes);
client.close();
},
Expand Down
80 changes: 56 additions & 24 deletions node/tests/SharedTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1013,18 +1013,37 @@ export function runBaseTests<Context>(config: {
expect(await client.ttl(key)).toBeLessThanOrEqual(10);
/// set command clears the timeout.
expect(await client.set(key, "bar")).toEqual("OK");
expect(
await client.pexpire(key, 10000, ExpireOptions.HasNoExpiry)
).toEqual(true);
const version = await getVersion();
if (version[0] < 7 ) {
expect(
await client.pexpire(key, 10000)
).toEqual(true);
}
else {
expect(
await client.pexpire(key, 10000, ExpireOptions.HasNoExpiry)
).toEqual(true);
}

expect(await client.ttl(key)).toBeLessThanOrEqual(10);
/// TTL will be updated to the new value = 15
expect(
await client.expire(
key,
15,
ExpireOptions.HasExistingExpiry
)
).toEqual(true);
if (version[0] < 7 ) {
expect(
await client.expire(
key,
15
)
).toEqual(true);
}
else {
expect(
await client.expire(
key,
15,
ExpireOptions.HasExistingExpiry
)
).toEqual(true);
}
expect(await client.ttl(key)).toBeLessThanOrEqual(15);
});
},
Expand All @@ -1044,24 +1063,37 @@ export function runBaseTests<Context>(config: {
)
).toEqual(true);
expect(await client.ttl(key)).toBeLessThanOrEqual(10);
expect(
await client.expireAt(
key,
Math.floor(Date.now() / 1000) + 50,
ExpireOptions.NewExpiryGreaterThanCurrent
)
).toEqual(true);
const version = await getVersion();
if (version[0] < 7 ) {
expect(
await client.expireAt(
key,
Math.floor(Date.now() / 1000) + 50
)
).toEqual(true);
}
else{
expect(
await client.expireAt(
key,
Math.floor(Date.now() / 1000) + 50,
ExpireOptions.NewExpiryGreaterThanCurrent
)
).toEqual(true);
}
expect(await client.ttl(key)).toBeLessThanOrEqual(50);

/// set command clears the timeout.
expect(await client.set(key, "bar")).toEqual("OK");
expect(
await client.pexpireAt(
key,
Date.now() + 50000,
ExpireOptions.HasExistingExpiry
)
).toEqual(false);
if (version[0] >= 7) {
expect(
await client.pexpireAt(
key,
Date.now() + 50000,
ExpireOptions.HasExistingExpiry
)
).toEqual(false);
}
});
},
config.timeout
Expand Down
5 changes: 2 additions & 3 deletions node/tests/TestUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ export function transactionTest(
const value = uuidv4();
baseTransaction.set(key1, "bar");
baseTransaction.set(key2, "baz", {
conditionalSet: "onlyIfDoesNotExist",
returnOldValue: true,
});
returnOldValue:true
});
baseTransaction.customCommand(["MGET", key1, key2]);
baseTransaction.mset({ [key3]: value });
baseTransaction.mget([key1, key2]);
Expand Down
51 changes: 32 additions & 19 deletions python/python/tests/test_async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,14 @@ async def test_request_error_raises_exception(self, redis_client: TRedisClient):

@pytest.mark.parametrize("cluster_mode", [True, False])
async def test_info_server_replication(self, redis_client: TRedisClient):
sections = [InfoSection.SERVER, InfoSection.REPLICATION]
info = get_first_result(await redis_client.info(sections))
info = get_first_result(await redis_client.info([InfoSection.SERVER]))
assert "# Server" in info
assert "# Replication" in info
assert "# Errorstats" not in info
cluster_mode = parse_info_response(info)["redis_mode"]
expected_cluster_mode = isinstance(redis_client, RedisClusterClient)
assert cluster_mode == "cluster" if expected_cluster_mode else "standalone"
info = get_first_result(await redis_client.info([InfoSection.REPLICATION]))
assert "# Replication" in info
assert "# Errorstats" not in info

@pytest.mark.parametrize("cluster_mode", [True, False])
async def test_info_default(self, redis_client: TRedisClient):
Expand Down Expand Up @@ -853,12 +853,22 @@ async def test_expire_pexpire_ttl_with_positive_timeout(

# set command clears the timeout.
assert await redis_client.set(key, "bar") == OK
assert await redis_client.pexpire(key, 10000, ExpireOptions.HasNoExpiry) == True
if await check_if_server_version_lt(redis_client, "7.0.0"):
assert await redis_client.pexpire(key, 10000) == True
else:
assert (
await redis_client.pexpire(key, 10000, ExpireOptions.HasNoExpiry)
== True
)
assert await redis_client.ttl(key) in range(11)

assert (
await redis_client.expire(key, 15, ExpireOptions.HasExistingExpiry) == True
)
if await check_if_server_version_lt(redis_client, "7.0.0"):
assert await redis_client.expire(key, 15) == True
else:
assert (
await redis_client.expire(key, 15, ExpireOptions.HasExistingExpiry)
== True
)
assert await redis_client.ttl(key) in range(16)

@pytest.mark.parametrize("cluster_mode", [True, False])
Expand All @@ -871,24 +881,27 @@ async def test_expireat_pexpireat_ttl_with_positive_timeout(

assert await redis_client.expireat(key, current_time + 10) == 1
assert await redis_client.ttl(key) in range(11)

assert (
await redis_client.expireat(
key, current_time + 50, ExpireOptions.NewExpiryGreaterThanCurrent
if await check_if_server_version_lt(redis_client, "7.0.0"):
assert await redis_client.expireat(key, current_time + 50) == 1
else:
assert (
await redis_client.expireat(
key, current_time + 50, ExpireOptions.NewExpiryGreaterThanCurrent
)
== 1
)
== 1
)
assert await redis_client.ttl(key) in range(51)

# set command clears the timeout.
assert await redis_client.set(key, "bar") == OK
current_time_ms = int(time.time() * 1000)
assert (
await redis_client.pexpireat(
key, current_time_ms + 50000, ExpireOptions.HasExistingExpiry
if not check_if_server_version_lt(redis_client, "7.0.0"):
assert (
await redis_client.pexpireat(
key, current_time_ms + 50000, ExpireOptions.HasExistingExpiry
)
== False
)
== False
)

@pytest.mark.parametrize("cluster_mode", [True, False])
async def test_expire_pexpire_expireat_pexpireat_past_or_negative_timeout(
Expand Down
1 change: 0 additions & 1 deletion utils/cluster_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ def start_redis_server(
raise ValueError(
"Please provide the path(s) to the module(s) you want to load."
)
cmd_args.extend(["--enable-module-command", "yes"])
for module_path in load_module:
cmd_args.extend(["--loadmodule", module_path])
cmd_args += tls_args
Expand Down

0 comments on commit 88329f3

Please sign in to comment.