Skip to content

Commit

Permalink
last fixes
Browse files Browse the repository at this point in the history
Signed-off-by: avifenesh <[email protected]>
  • Loading branch information
avifenesh committed Oct 27, 2024
1 parent cf39a66 commit 898f656
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-node-wrapper/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ runs:
shell: bash
working-directory: ./node
run: |
rm -rf node_modules && npm install --frozen-lockfile
rm -rf node_modules && rm -rf package-lock.json && npm install
cd rust-client
npm install --frozen-lockfile
rm -rf node_modules && rm -rf package-lock.json && npm install
- name: Build
shell: bash
Expand Down
4 changes: 3 additions & 1 deletion node/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* eslint no-undef: off */
module.exports = {
preset: "ts-jest",
transform: { "^.+\\.ts?$": "ts-jest" },
transform: {
"^.+\\.(t|j)s$": ["ts-jest", { isolatedModules: true }],
},
testEnvironment: "node",
testRegex: "/tests/.*\\.(test|spec)?\\.(ts|tsx)$",
moduleFileExtensions: [
Expand Down
3 changes: 3 additions & 0 deletions node/tests/AsyncClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import { afterAll, afterEach, beforeAll, describe } from "@jest/globals";
import { AsyncClient } from "glide-rs";
import RedisServer from "redis-server";
import { Logger } from "..";
import { runCommonTests } from "./SharedTests";
import { flushallOnPort } from "./TestUtilities";
/* eslint-disable @typescript-eslint/no-require-imports */
Expand All @@ -16,6 +17,8 @@ describe("AsyncClient", () => {
let server: RedisServer;
let port: number;
beforeAll(async () => {
Logger.init("error");
Logger.setLoggerConfig("error");
port = await FreePort(PORT_NUMBER).then(
([free_port]: number[]) => free_port,
);
Expand Down
3 changes: 3 additions & 0 deletions node/tests/GlideClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
GlideRecord,
GlideString,
ListDirection,
Logger,
ProtocolVersion,
RequestError,
Script,
Expand Down Expand Up @@ -56,6 +57,8 @@ describe("GlideClient", () => {
let cluster: ValkeyCluster;
let client: GlideClient;
beforeAll(async () => {
Logger.init("error");
Logger.setLoggerConfig("error");
const standaloneAddresses =
parseCommandLineArgs()["standalone-endpoints"];
cluster = standaloneAddresses
Expand Down
3 changes: 2 additions & 1 deletion node/tests/GlideClientInternals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ import { convertStringArrayToBuffer } from "./TestUtilities";
const { RequestType, CommandRequest } = command_request;

beforeAll(() => {
Logger.init("info");
Logger.init("error");
Logger.setLoggerConfig("error");
});

enum ResponseType {
Expand Down
19 changes: 13 additions & 6 deletions node/tests/GlideClusterClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
GlideReturnType,
InfoOptions,
ListDirection,
Logger,
ProtocolVersion,
RequestError,
Routes,
Expand Down Expand Up @@ -64,6 +65,8 @@ describe("GlideClusterClient", () => {
let cluster: ValkeyCluster;
let client: GlideClusterClient;
beforeAll(async () => {
Logger.init("error");
Logger.setLoggerConfig("error");
const clusterAddresses = parseCommandLineArgs()["cluster-endpoints"];
// Connect to cluster or create a new one based on the parsed addresses
cluster = clusterAddresses
Expand Down Expand Up @@ -245,7 +248,7 @@ describe("GlideClusterClient", () => {
expect(await client.set(key, value)).toEqual("OK");
// Since DUMP gets binary results, we cannot use the default decoder (string) here, so we expected to get an error.
await expect(client.customCommand(["DUMP", key])).rejects.toThrow(
"invalid utf-8 sequence of 1 bytes from index 9",
"invalid utf-8 sequence of 1 bytes from index",
);

const dumpResult = await client.customCommand(["DUMP", key], {
Expand Down Expand Up @@ -450,11 +453,15 @@ describe("GlideClusterClient", () => {
);
}

for (const promise of promises) {
await expect(promise).rejects.toThrowError(
/Keys in request don't hash to the same slot/,
);
}
await Promise.allSettled(promises).then((results) => {
results.forEach((result) => {
expect(result.status).toBe("rejected");

if (result.status === "rejected") {
expect(result.reason.message).toContain("CrossSlot");
}
});
});

client.close();
},
Expand Down
3 changes: 3 additions & 0 deletions node/tests/ScanTest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
GlideClient,
GlideClusterClient,
GlideString,
Logger,
ObjectType,
ProtocolVersion,
} from "..";
Expand All @@ -30,6 +31,8 @@ describe("Scan GlideClusterClient", () => {
let cluster: ValkeyCluster;
let client: GlideClusterClient;
beforeAll(async () => {
Logger.init("error");
Logger.setLoggerConfig("error");
const clusterAddresses = parseCommandLineArgs()["cluster-endpoints"];
// Connect to cluster or create a new one based on the parsed addresses
cluster = clusterAddresses
Expand Down
24 changes: 18 additions & 6 deletions node/tests/SharedTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
InfoOptions,
InsertPosition,
ListDirection,
Logger,
ProtocolVersion,
RequestError,
ScoreFilter,
Expand Down Expand Up @@ -74,6 +75,8 @@ export function runBaseTests(config: {
close: (testSucceeded: boolean) => void;
timeout?: number;
}) {
Logger.init("error");
Logger.setLoggerConfig("error");
runCommonTests({
init: () => config.init(ProtocolVersion.RESP2),
close: config.close,
Expand Down Expand Up @@ -6434,7 +6437,7 @@ export function runBaseTests(config: {
[key3],
cluster.checkIfServerVersionLessThan("6.0.0")
? 1.0
: 0.001,
: 0.01,
),
).toBeNull();

Expand Down Expand Up @@ -9254,11 +9257,20 @@ export function runBaseTests(config: {
{ reverse: true },
),
).toEqual(
convertElementsAndScores({
edge2: 236529.17986494553,
Palermo: 166274.15156960033,
Catania: 0.0,
}),
expect.arrayContaining([
{
element: "edge2",
score: expect.closeTo(236529.17986494553, 0.0001),
},
{
element: "Palermo",
score: expect.closeTo(166274.15156960033, 0.0001),
},
{
element: "Catania",
score: expect.closeTo(0.0, 0.0001),
},
]),
);

// test search by box, unit: feet, from member, with limited count 2, with hash
Expand Down

0 comments on commit 898f656

Please sign in to comment.