Pre-build ldap image for integration test#92
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #92 +/- ##
=======================================
Coverage 83.69% 83.69%
=======================================
Files 13 13
Lines 1325 1325
=======================================
Hits 1109 1109
Misses 216 216
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
The plan made some incorrect assumptions about how the tests are going to run. Apparently when more than one component is built in a PR, each one gets a separate test pipeline, plus there is one "group" test pipeline. In each case the ITS is supposed to get a snapshot with all components. For pipelines running on a single component, the other components are supposed to be populated from latest stable build. In this case, that is not working as there is no stable build for the ldap-server component. We get:
The fallback in the ldap-server extraction is not helpful. If there was something to fall back to, it would have been included in the Snapshot in the first place. If the snapshot doesn't contain ldap-server, the test should just be skipped. This is only an issue for the initial PR. Once there is an ldap-server built from main branch, the snapshot should always have some url available. This is already visible on the ldap-server ITS run: cts is coming from last build on main. |
Build a dedicated container image for the in-memory LDAP server used by the integration test instead of performing a live 'pip install ldaptor twisted' on every test run. New files: - integration-tests/images/ldap-server/server.py: the in-memory LDAP server script, listening on port 1389 as an arbitrary UID (OpenShift restricted-v2 SCC compatible). - integration-tests/images/ldap-server/Containerfile: builds a fedora-minimal:44-based image that installs ldaptor and twisted via pip3. - .tekton/ldap-server-pull-request.yaml: Konflux build PipelineRun for pull requests; triggers only when files under integration-tests/images/ldap-server/ change (pathChanged() CEL filter). Sets image-expires-after to 5d. - .tekton/ldap-server-push.yaml: Konflux build PipelineRun for pushes to main. Same path filter. Modified: - .tekton/integration-test-eaas.yaml: parse-snapshot now emits a ldap-server-present result; when ldap-server is absent from the Snapshot (no stable build yet, and not triggered for this PR), every downstream task is skipped via a 'when' condition and the finally task emits 'skipped' instead of failing. Generated-By: OpenCode (google-vertex-anthropic/claude-sonnet-4-6@default)
|
@guillermodotn , this implements your suggestion of moving the ldap test server into a pre-built image. It slightly complicates the compatibility story though. If something about the test data changes, there will be multiple pipelines with the latest test code, but multiple combinations of images (new ldap-server+old cts; old ldap-server+new cts; both new images). Either we would need to care to make all of these work, or accept having failing tests. The check to skip the pipeline if ldap-server is missing is needed only for the initial PR. Once (if) this is merged, there would always be some ldap-server image available. |
|
|
||
| RUN microdnf install -y python3 python3-pip && \ | ||
| microdnf clean all && \ | ||
| pip3 install --no-cache-dir ldaptor twisted |
There was a problem hiding this comment.
maybe we should pin the versions in here or add a requirements.txt under integration-tests/images/ldap-server
There was a problem hiding this comment.
Yeah, this is a good point. The build could be switched to hermetic mode too when the file is added. But I'd prefer to do that in a separate follow up PR to not bloat this even more.
I guess we can extract the LDIF data to its own file and mount it at runtime via a ConfigMap, so the image only contains the server dependencies and never goes stale. What do you think? |
That's a great idea. It's going to need a bit of refactoring though. The deploy-ldap task currently doesn't have access to the files from the git repo. Those files are only needed for the run-tests task, which does a git clone in the test runner ephemeral container. I guess the solution would be to have a separate task to clone the git repo into a workspace. Then all deploy tasks would have access to it and could read config files. The clone in run-tests could be replaced with With such change, the deploy tasks could read manifests from files, and no longer embed them. The current yaml in bash in yaml is not the most readable thing... I think that refactor should be a separate PR. We can block this one until that's done and then rebase, or merge this and then refactor. I'm happy to do either. |
Summary
Pre-builds the LDAP server used by the integration test as a dedicated container image instead of performing a live
pip install ldaptor twistedon every test run.Changes
New files
integration-tests/images/ldap-server/server.py– the existing in-memory LDAP server script (extracted verbatim from the inline ConfigMap in the integration-test pipeline). Listens on port 1389 as an arbitrary UID, compatible with OpenShift'srestricted-v2SCC.integration-tests/images/ldap-server/Containerfile– builds afedora-minimal:40-based image that installsldaptorandtwistedviapip3and setsCMD ["python3", "/app/server.py"]..tekton/ldap-server-pull-request.yaml– Konflux build PipelineRun for pull requests. Triggers only when files underintegration-tests/images/ldap-server/change (pathChanged()CEL filter). Uses service accountbuild-pipeline-ldap-serverand setsimage-expires-after: 5d..tekton/ldap-server-push.yaml– Konflux build PipelineRun for pushes tomain. Same path filter. Applies themaintag via theapply-tagstask.Modified file
.tekton/integration-test-eaas.yaml:parse-snapshot: adds aldap-server-image-urlresult that extracts theldap-servercomponent'scontainerImagefrom the Snapshot JSON.deploy-openldap: replaces the inline ConfigMap creation,pip install, volume mount, and volumes with a single Deployment that references the pre-built image passed as theldap-server-imageparameter.