You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected Behaviour
When setting resource limits for a Docker container using the Testcontainers library, specifying a memory quota of 0.5 should limit the container's memory to 0.5 GB (or 512 MB), and specifying a CPU quota of 1 should allocate 1 unit of the CPU without causing any errors in JSON parsing or unmarshalling.
Actual Behaviour
Specifying a memory quota of 0.2 and a CPU quota of 0.3 via the .withResourcesQuota({ memory: 0.5, cpu: 1 }) method results in an unexpected 400 HTTP code error related to invalid JSON parsing. The error message indicates an inability to unmarshal the number 214748364.8 into the expected Go struct for Docker's HostConfig.Memory, which is of type int64. This discrepancy indicates a potential issue with how the Testcontainers library or Docker API interprets and formats the memory quota values for the Docker engine.
Error Message
Error: (HTTP code 400) unexpected - invalid JSON: json: cannot unmarshal number 214748364.8 into Go struct field HostConfig.HostConfig.Memory of type int64
at C:\projects\node.js\***.FunctionalTests\node_modules\.pnpm\[email protected]\node_modules\docker-modem\lib\modem.js:343:17
at getCause (C:\projects\node.js\***.FunctionalTests\node_modules\.pnpm\[email protected]\node_modules\docker-modem\lib\modem.js:373:7)
at Modem.buildPayload (C:\projects\node.js\***.FunctionalTests\node_modules\.pnpm\[email protected]\node_modules\docker-modem\lib\modem.js:342:5)
at IncomingMessage.<anonymous> (C:\projects\node.js\***.FunctionalTests\node_modules\.pnpm\[email protected]\node_modules\docker-modem\lib\modem.js:310:16)
at IncomingMessage.emit (node:events:530:35)
at endReadableNT (node:internal/streams/readable:1696:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21)
Steps to Reproduce
Set up a Node.js environment with the Testcontainers library installed.
Configure a Docker container using the Testcontainers library with the following resource quota:
javascript
const container = await new GenericContainer("mongo:latest")
.withExposedPorts(27017)
.withWaitStrategy(Wait.forLogMessage(/Waiting for connections/))
.withEnvironment({
MONGO_INITDB_ROOT_USERNAME: "user",
MONGO_INITDB_ROOT_PASSWORD: "password"
})
.withResourcesQuota({
memory: 0.2,
cpu: 0.3
})
.start();
Run the container setup script.
Observe the error related to invalid JSON and the incorrect handling of the memory quota.
The documentation for Testcontainers suggests that memory should be specified in gigabytes and CPU quota in units of CPUs, which was followed in the setup that led to this issue.
The error indicates a mismatch between the expected data type for the Docker engine's memory configuration and the data provided by the Testcontainers library, suggesting a potential bug in the library's handling of resource quotas or a documentation mismatch on proper usage.
The text was updated successfully, but these errors were encountered:
Expected Behaviour
When setting resource limits for a Docker container using the Testcontainers library, specifying a memory quota of 0.5 should limit the container's memory to 0.5 GB (or 512 MB), and specifying a CPU quota of 1 should allocate 1 unit of the CPU without causing any errors in JSON parsing or unmarshalling.
Actual Behaviour
Specifying a memory quota of 0.2 and a CPU quota of 0.3 via the .withResourcesQuota({ memory: 0.5, cpu: 1 }) method results in an unexpected 400 HTTP code error related to invalid JSON parsing. The error message indicates an inability to unmarshal the number 214748364.8 into the expected Go struct for Docker's HostConfig.Memory, which is of type int64. This discrepancy indicates a potential issue with how the Testcontainers library or Docker API interprets and formats the memory quota values for the Docker engine.
Error Message
Steps to Reproduce
Environment Information
Additional Context
The text was updated successfully, but these errors were encountered: