Comments (3)
Hey @AlbertoSH, thanks for filing and sorry for the late reply on this one.
container-structure-test doesn't currently support environment variable substitution in the test spec itself, so you won't be able to use any env vars as part of your test args/output. However, what you're trying to do is still possible using the metadataTest
:
schemaVersion: 2.0.0
globalEnvVars:
- key: FOO
value: test_value
metadataTest:
env:
- key: PATH
value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
- key: FOO
value: test_value
You can specify all your env vars here and check to be sure they're set to the correct value. It's also worth noting that this will NOT let you check variables set by the OS at boot or login time, i.e. $HOME
, as these are not part of the container config.
All that said, I did actually find an issue with setting the env vars outside of the CommandTests
: opened an issue for that here.
from container-structure-test.
Yes, I know that I can test the env variables with the metadataTest but my use case was more intended to check that some software was installed and its executable was added to the PATH. So my real test is something like:
schemaVersion: "2.0.0"
globalEnvVars:
- name: "some specific software version"
envVars:
- key: "PATH"
value: "$PATH:$HOME/some/dir"
command: "someExecutableAvailableInPath"
args: ["some", "args"]
expectedOutput: ["Version X"]
In the end I got a similar result with:
schemaVersion: "2.0.0"
globalEnvVars:
- name: "some specific software version"
# PATH redefinition not needed since it's set in .bashrc
command: "bash"
args: ["-cl", "someExecutableAvailableInPath some args"]
expectedOutput: ["Version X"]
But it feels like an ugly workaround
from container-structure-test.
@AlbertoSH this should now be supported via #130. I'll get the next release out ASAP
from container-structure-test.
Related Issues (20)
- Testing the existence of a directory is very slow
- Release process: use github actions and release to bazel central registry HOT 1
- container-structure-test behaves differently on two identical machines HOT 2
- Add Expected Log validation HOT 3
- How to use container_structure_test with oci_image on MacOS
- No Release asset checksums (sha256) since Release v1.11.0
- Add platform parameter to support testing multi-platform images
- Multiple outputs (i.e. `text` and `json`) HOT 1
- New Testcontainers driver HOT 3
- Env var expansion feature in commandTests output assertions
- Add support to containerRunOptions for --cap-drop
- Security Policy violation SECURITY.md HOT 107
- Update documentation regarding Bazel and Docker TCP connections
- Binaries for v1.16.1? HOT 2
- Unable use v1.16.1 with bzlmod
- How to mount a config file? HOT 1
- Hash for linux_i386 is missing
- Add Darwin ARM64 package type HOT 7
- Add ability to document container in markdown HOT 1
- Add a metadata test to test the base image used in the image
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from container-structure-test.