Skip to content

Conversation

@tomleb
Copy link
Contributor

@tomleb tomleb commented Nov 24, 2025

Issue rancher/rancher#48080

This PR adds an integration test harness for Steve that allows us to tests the Steve API with everything running (schema controllers, formatters, virtual func transformation, etc) the same way it runs within Rancher or within the Steve binary.

We can then avoid doing the setup code for steve like we're doing in pkg/sqlcache/integration_test.go. In fact, we're likely to get rid of that test and move the tests over to this new harness (out of scope for this PR).

The only dependency for running integration tests is a Kubernetes cluster (eg: k3d). If a KUBECONFIG is not provided then the test entrypoint will try to create one using k3d.

How to use

See tests/README.md, but the gist is: make integration-tests.

Features

  • Easy way to debug the system under test by setting INTEGRATION_TEST_DEBUG=true. You can then curl the running steve API, inspect the Kubernetes cluster and explore the SQLite database.
  • Data-driven tests ala Go tables but instead of Go code, it's yaml code. The current 3 types of tests (sorting, filtering, columns) are configured via *.manifests.yaml files (which you can directly apply via kubectl when troubleshooting) and *.test.yaml files which defines the tests (eg: filter params, expected output).

The goal of this PR is NOT to bring a LOT of tests. Instead, I'm adding a few examples and then future PRs can add more tests. This will make it easier to get the test harness reviewed.

Note: It's still possible to write tests not using YAML if those tests don't really match that.

How to review

Best to review commit by commit. The first commit introduces the test harness: no tests, just utilities for building the tests in the next few commits.

@tomleb tomleb force-pushed the integration-tests branch 5 times, most recently from 52dc07e to 47c0a91 Compare November 25, 2025 13:55
@tomleb tomleb marked this pull request as ready for review November 25, 2025 14:29
@tomleb tomleb requested a review from a team as a code owner November 25, 2025 14:29
Copy link
Contributor

@gehrkefc gehrkefc left a comment

Choose a reason for hiding this comment

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

1 comment, but this is too good for me to request any changes. Great work!

paramCodec = runtime.NewParameterCodec(paramScheme)
// Please keep the gvkKey entries in alphabetical order, on a field-by-field basis
typeSpecificIndexedFields = map[string][][]string{
TypeSpecificIndexedFields = map[string][][]string{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm thinking of moving this to an option in the CachefactoryOption struct so we can modify things per-gvk (fields, type hints, etc). But that would be in another PR. For now, the only other way I figured was making this public for the sake of modifying it in the tests. Not great, but does the job. Open to other suggestions though

# - schemaID: columns.cattle.io.namespacedsomecolumns
# expected:
# - [foo, $timestamp, $timestamp]
---
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's also possible to have manifests directly in the .test.yaml file. IS this a good idea or should we force an external manifest file?

@tomleb
Copy link
Contributor Author

tomleb commented Nov 26, 2025

Some recent changes (cc: @gehrkefc )

Was missing some HTTP response code check in two of those tests, move the tests to tests/integration as suggested by @ericpromislow and fixed waitForSchema so it works properly for resources without a group like pods, configmaps and events.

Copy link
Contributor

@ericpromislow ericpromislow left a comment

Choose a reason for hiding this comment

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

Lots going on here but it works, and looks fine.

@tomleb tomleb merged commit 5f83ccd into rancher:main Nov 26, 2025
2 checks passed
@tomleb tomleb deleted the integration-tests branch November 26, 2025 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants