Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RHOAIENG-17695: chore(ci): create a test for calling oc version in the test, which can be run with ci testing #829

Merged

Conversation

jiridanek
Copy link
Member

https://issues.redhat.com/browse/RHOAIENG-17695

Description

Pytest! Yay!

How Has This Been Tested?

poetry run pytest tests/containers \
  --image ghcr.io/jiridanek/notebooks/workbench-images:runtime-minimal-ubi9-python-3.9-main_fe3641a01ac9e1e8f694f1a8bce3b34cacf9ae57 \
  --image quay.io/modh/odh-minimal-notebook-container@sha256:eec50e5518176d5a31da739596a7ddae032d73851f9107846a587442ebd10a82 \
  --image=ghcr.io/jiridanek/notebooks/workbench-images:base-ubi9-python-3.11-jd_try_oc_command_cleanup_b1b8d1f10a329317d85f0ea54580e170b002cae8

This should fail one test, because one of the images is the one that was seen failing on FIPS systems.

Merge criteria:

  • The commits are squashed in a cohesive manner and have meaningful messages.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

…the test, which can be run with ci testing
Copy link
Member Author

@jiridanek jiridanek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Design issues

  • suite should support local run
  • github run
  • and on openshift run

Suite should handle reporting of failing tests

  • junit, or markdown table, something that's clear at a glanc

Makefile tests should be rewritten into this

  • the source of truth should be the manifest files
  • need to figure out which manifest applies for which image

env:
DOCKER_HOST: "unix:///var/run/podman/podman.sock"
TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE: "/var/run/podman/podman.sock"
RYUK_CONTAINER_IMAGE: "testcontainers/ryuk:0.8.1"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jstourac suggested disabling ryuk for gha runs

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"""Tests that are applicable for all images we have in this repository."""

def test_oc_command_runs(self, image: str):
container = testcontainers.core.container.DockerContainer(image=image, user=123456, group_add=[0])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jstourac suggested abstracting this object away, so the same test can run against local docker as well as remote kubernetes, depending on some cli switch or some other configuration mechanism

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

@jiridanek jiridanek Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logging.debug(output.decode())
assert ecode == 0

def test_oc_command_runs_fake_fips(self, image: str, subtests: pytest_subtests.SubTests):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jstourac suggested skipping this test when running suite on openshift, openshift will test real configurations, not these fake ones

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

metafunc.parametrize(image.__name__, metafunc.config.getoption("--image"))


# https://docs.pytest.org/en/stable/how-to/fixtures.html#parametrizing-fixtures
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jstourac was discouraged by this long doc page and left the office for today shortly after opening it

import pytest_subtests


class TestBaseImage:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jstourac wondered how to structure the tests when more are to be added, like when the version tests are rewritten from makefile to here

@andyatmiami
Copy link
Contributor

/lgtm

Reviewed code and was able to run locally to observe intended behavior.

@jstourac 's insights all certainly good/valid - but current form of this PR seems like a great starting point to enhance in the future.

@jiridanek
Copy link
Member Author

/override ci/prow/images
/approve

Copy link
Contributor

openshift-ci bot commented Jan 21, 2025

@jiridanek: Overrode contexts on behalf of jiridanek: ci/prow/images

In response to this:

/override ci/prow/images
/approve

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link
Contributor

openshift-ci bot commented Jan 21, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jiridanek

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants