@testcontainers/valkey 10.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +30 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +7 -0
- package/build/index.js.map +1 -0
- package/build/valkey-container.d.ts +22 -0
- package/build/valkey-container.js +104 -0
- package/build/valkey-container.js.map +1 -0
- package/package.json +38 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 - 2023 Cristian Greco
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Testcontainers
|
|
2
|
+
|
|
3
|
+
[](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=116414510&machine=standardLinux32gb&devcontainer_path=.devcontainer%2Fdevcontainer.json&location=EastUs)
|
|
4
|
+
|
|
5
|
+
[](https://github.com/testcontainers/testcontainers-node/actions/workflows/test.yml)
|
|
6
|
+
[](https://www.npmjs.com/package/testcontainers)
|
|
7
|
+
[](https://www.npmjs.com/package/testcontainers)
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
## [📖 Documentation](https://node.testcontainers.org/)
|
|
12
|
+
|
|
13
|
+
## License
|
|
14
|
+
|
|
15
|
+
See [LICENSE](https://github.com/testcontainers/testcontainers-node/blob/main/LICENSE).
|
|
16
|
+
|
|
17
|
+
## Copyright
|
|
18
|
+
|
|
19
|
+
Copyright (c) 2018 - 2023 Cristian Greco and other authors.
|
|
20
|
+
|
|
21
|
+
## Contributing
|
|
22
|
+
|
|
23
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for how to contribute to this repo.
|
|
24
|
+
|
|
25
|
+
See [contributors](https://github.com/testcontainers/testcontainers-node/graphs/contributors/) for all contributors.
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
----
|
|
29
|
+
|
|
30
|
+
Join our [Slack workspace](https://slack.testcontainers.org/) | [Testcontainers OSS](https://java.testcontainers.org/) | [Testcontainers Cloud](https://www.testcontainers.cloud/)
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ValkeyContainer, StartedValkeyContainer } from "./valkey-container";
|
package/build/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StartedValkeyContainer = exports.ValkeyContainer = void 0;
|
|
4
|
+
var valkey_container_1 = require("./valkey-container");
|
|
5
|
+
Object.defineProperty(exports, "ValkeyContainer", { enumerable: true, get: function () { return valkey_container_1.ValkeyContainer; } });
|
|
6
|
+
Object.defineProperty(exports, "StartedValkeyContainer", { enumerable: true, get: function () { return valkey_container_1.StartedValkeyContainer; } });
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6E;AAApE,mHAAA,eAAe,OAAA;AAAE,0HAAA,sBAAsB,OAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AbstractStartedContainer, GenericContainer, StartedTestContainer } from "testcontainers";
|
|
2
|
+
export declare class ValkeyContainer extends GenericContainer {
|
|
3
|
+
private readonly importFilePath;
|
|
4
|
+
private password?;
|
|
5
|
+
private persistenceVolume?;
|
|
6
|
+
private initialImportScriptFile?;
|
|
7
|
+
constructor(image?: string);
|
|
8
|
+
withPassword(password: string): this;
|
|
9
|
+
withPersistence(sourcePath: string): this;
|
|
10
|
+
withInitialData(importScriptFile: string): this;
|
|
11
|
+
protected containerStarted(container: StartedTestContainer): Promise<void>;
|
|
12
|
+
start(): Promise<StartedValkeyContainer>;
|
|
13
|
+
private importInitialData;
|
|
14
|
+
}
|
|
15
|
+
export declare class StartedValkeyContainer extends AbstractStartedContainer {
|
|
16
|
+
private readonly password?;
|
|
17
|
+
constructor(startedTestContainer: StartedTestContainer, password?: string | undefined);
|
|
18
|
+
getPort(): number;
|
|
19
|
+
getPassword(): string;
|
|
20
|
+
getConnectionUrl(): string;
|
|
21
|
+
executeCliCmd(cmd: string, additionalFlags?: string[]): Promise<string>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.StartedValkeyContainer = exports.ValkeyContainer = void 0;
|
|
7
|
+
const testcontainers_1 = require("testcontainers");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const VALKEY_PORT = 6379;
|
|
10
|
+
class ValkeyContainer extends testcontainers_1.GenericContainer {
|
|
11
|
+
importFilePath = "/tmp/import.valkey";
|
|
12
|
+
password = "";
|
|
13
|
+
persistenceVolume = "";
|
|
14
|
+
initialImportScriptFile = "";
|
|
15
|
+
constructor(image = "valkey/valkey:8.0") {
|
|
16
|
+
super(image);
|
|
17
|
+
this.withExposedPorts(VALKEY_PORT)
|
|
18
|
+
.withStartupTimeout(120000)
|
|
19
|
+
.withWaitStrategy(testcontainers_1.Wait.forLogMessage("Ready to accept connections"));
|
|
20
|
+
}
|
|
21
|
+
withPassword(password) {
|
|
22
|
+
this.password = password;
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
withPersistence(sourcePath) {
|
|
26
|
+
this.persistenceVolume = sourcePath;
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
withInitialData(importScriptFile) {
|
|
30
|
+
this.initialImportScriptFile = importScriptFile;
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
async containerStarted(container) {
|
|
34
|
+
if (this.initialImportScriptFile) {
|
|
35
|
+
await this.importInitialData(container);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async start() {
|
|
39
|
+
this.withCommand([
|
|
40
|
+
"valkey-server",
|
|
41
|
+
...(this.password ? [`--requirepass "${this.password}"`] : []),
|
|
42
|
+
...(this.persistenceVolume ? ["--save 1 1 ", "--appendonly yes"] : []),
|
|
43
|
+
]);
|
|
44
|
+
if (this.persistenceVolume) {
|
|
45
|
+
this.withBindMounts([{ mode: "rw", source: this.persistenceVolume, target: "/data" }]);
|
|
46
|
+
}
|
|
47
|
+
if (this.initialImportScriptFile) {
|
|
48
|
+
this.withCopyFilesToContainer([
|
|
49
|
+
{
|
|
50
|
+
mode: 666,
|
|
51
|
+
source: this.initialImportScriptFile,
|
|
52
|
+
target: this.importFilePath,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
mode: 777,
|
|
56
|
+
source: path_1.default.join(__dirname, "import.sh"),
|
|
57
|
+
target: "/tmp/import.sh",
|
|
58
|
+
},
|
|
59
|
+
]);
|
|
60
|
+
}
|
|
61
|
+
return new StartedValkeyContainer(await super.start(), this.password);
|
|
62
|
+
}
|
|
63
|
+
async importInitialData(container) {
|
|
64
|
+
const re = await container.exec(`/tmp/import.sh ${this.password || ""}`);
|
|
65
|
+
if (re.exitCode !== 0 || re.output.includes("ERR")) {
|
|
66
|
+
throw Error(`Could not import initial data from ${this.initialImportScriptFile}: ${re.output}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.ValkeyContainer = ValkeyContainer;
|
|
71
|
+
class StartedValkeyContainer extends testcontainers_1.AbstractStartedContainer {
|
|
72
|
+
password;
|
|
73
|
+
constructor(startedTestContainer, password) {
|
|
74
|
+
super(startedTestContainer);
|
|
75
|
+
this.password = password;
|
|
76
|
+
}
|
|
77
|
+
getPort() {
|
|
78
|
+
return this.getMappedPort(VALKEY_PORT);
|
|
79
|
+
}
|
|
80
|
+
getPassword() {
|
|
81
|
+
return this.password ? this.password.toString() : "";
|
|
82
|
+
}
|
|
83
|
+
getConnectionUrl() {
|
|
84
|
+
const url = new URL("", "redis://");
|
|
85
|
+
url.hostname = this.getHost();
|
|
86
|
+
url.port = this.getPort().toString();
|
|
87
|
+
url.password = this.getPassword();
|
|
88
|
+
return url.toString();
|
|
89
|
+
}
|
|
90
|
+
async executeCliCmd(cmd, additionalFlags = []) {
|
|
91
|
+
const result = await this.startedTestContainer.exec([
|
|
92
|
+
"redis-cli",
|
|
93
|
+
...(this.password != "" ? [`-a ${this.password}`] : []),
|
|
94
|
+
`${cmd}`,
|
|
95
|
+
...additionalFlags,
|
|
96
|
+
]);
|
|
97
|
+
if (result.exitCode !== 0) {
|
|
98
|
+
throw new Error(`executeQuery failed with exit code ${result.exitCode} for query: ${cmd}. ${result.output}`);
|
|
99
|
+
}
|
|
100
|
+
return result.output;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.StartedValkeyContainer = StartedValkeyContainer;
|
|
104
|
+
//# sourceMappingURL=valkey-container.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"valkey-container.js","sourceRoot":"","sources":["../src/valkey-container.ts"],"names":[],"mappings":";;;;;;AAAA,mDAAwG;AACxG,gDAAwB;AAExB,MAAM,WAAW,GAAG,IAAI,CAAC;AAEzB,MAAa,eAAgB,SAAQ,iCAAgB;IAClC,cAAc,GAAG,oBAAoB,CAAC;IAC/C,QAAQ,GAAI,EAAE,CAAC;IACf,iBAAiB,GAAI,EAAE,CAAC;IACxB,uBAAuB,GAAI,EAAE,CAAC;IAEtC,YAAY,KAAK,GAAG,mBAAmB;QACrC,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC;aAC/B,kBAAkB,CAAC,MAAO,CAAC;aAC3B,gBAAgB,CAAC,qBAAI,CAAC,aAAa,CAAC,6BAA6B,CAAC,CAAC,CAAC;IACzE,CAAC;IAEM,YAAY,CAAC,QAAgB;QAClC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,eAAe,CAAC,UAAkB;QACvC,IAAI,CAAC,iBAAiB,GAAG,UAAU,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,eAAe,CAAC,gBAAwB;QAC7C,IAAI,CAAC,uBAAuB,GAAG,gBAAgB,CAAC;QAChD,OAAO,IAAI,CAAC;IACd,CAAC;IAEkB,KAAK,CAAC,gBAAgB,CAAC,SAA+B;QACvE,IAAI,IAAI,CAAC,uBAAuB,EAAE;YAChC,MAAM,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;SACzC;IACH,CAAC;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AAC,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,sCAAsC,MAAM,CAAC,QAAQ,eAAe,GAAG,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;SAC9G;QACD,OAAO,MAAM,CAAC,MAAM,CAAC;IACvB,CAAC;CACF;AAjCD,wDAiCC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@testcontainers/valkey",
|
|
3
|
+
"version": "10.18.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"valkey",
|
|
7
|
+
"testing",
|
|
8
|
+
"docker",
|
|
9
|
+
"testcontainers"
|
|
10
|
+
],
|
|
11
|
+
"description": "Valkey module for Testcontainers",
|
|
12
|
+
"homepage": "https://github.com/testcontainers/testcontainers-node#readme",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/testcontainers/testcontainers-node"
|
|
16
|
+
},
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/testcontainers/testcontainers-node/issues"
|
|
19
|
+
},
|
|
20
|
+
"main": "build/index.js",
|
|
21
|
+
"files": [
|
|
22
|
+
"build"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"prepack": "shx cp ../../../README.md . && shx cp ../../../LICENSE .",
|
|
29
|
+
"build": "tsc --project tsconfig.build.json"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/redis": "^4.0.11",
|
|
33
|
+
"redis": "^4.6.15"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"testcontainers": "^10.18.0"
|
|
37
|
+
}
|
|
38
|
+
}
|