Skip to content

Conversation

@gianarb
Copy link
Contributor

@gianarb gianarb commented Jan 2, 2026

Fixes #15138

Motivation

This commit explores how to drop testify from another (first was example
suite) e2e suite. In this case the cronjob one with particular focus on
how to abstract the code used for both migrations in a reusable fashion

Modifications

I created a new structure to pre-configure and dispatch the Given fixture.
I refactored both Example and Cron suite to use it

Verification

CI/CD is green

Documentation

N/A

@gianarb gianarb marked this pull request as draft January 2, 2026 13:26
@gianarb gianarb force-pushed the chore/suite-without-testify branch from 0bad8d2 to 7fc7127 Compare January 2, 2026 14:39
@gianarb gianarb marked this pull request as ready for review January 2, 2026 15:41
@gianarb
Copy link
Contributor Author

gianarb commented Jan 2, 2026

I do not like the name Runner, it is too generic. it is at this point a placeholder because I did not know how this struct would look like at the end. I still don't know where I am so far with this but happy to get feedback

if err != nil {
s.T().Fatal(err)
}
CheckError(s.T(), err)
Copy link
Member

Choose a reason for hiding this comment

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

Why both this and the previous changes of s.CheckError->CheckError.

This still should be an s.T().Helper()

var err error
s.RestConfig, err = kubeconfig.DefaultRestConfig()
s.CheckError(err)
CheckError(s.T(), err)
Copy link
Member

Choose a reason for hiding this comment

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

Can't we stick with s.CheckError(err) here and all the way down?

if err != nil {
t.Fatal(err)
}
//kubeClient, err := kubernetes.NewForConfig(restConfig)
Copy link
Member

Choose a reason for hiding this comment

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

Remove dead code rather than comment it out please

assert.Greater(t, cronWf.Status.LastScheduledTime.Time, time.Now().Add(-1*time.Minute))
})
}
func TestBasicTimezone(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Blank new line between functions please

CronWorkflow(`apiVersion: argoproj.io/v1alpha1
func TestBasic(t *testing.T) {
runner := fixtures.NewRunner(t)
defer runner.DeleteResources(t)
Copy link
Member

Choose a reason for hiding this comment

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

Requiring this everywhere is a bit messy and prone to mistakes (missing the call to DeleteResources). Also, it makes it impossible to t.Parallel() these as they all nuke all resources after they complete.

Can we run this in some wrapper like the former suite?

Copy link
Contributor Author

@gianarb gianarb Jan 7, 2026

Choose a reason for hiding this comment

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

The current cronjob suite does not support parallelization. defer does not look like the problem here. Parallelization will not work because the problem is in how tbe DeleteResources function works. It is a copy of the old one, and it does not support parallelization because there is no segmentation by test name. We should do something like labeling all the resources created in a test with their test name and the DeleteResources should delete only the one with such label. Right now the DeleteResources deletes across tests if I understand it correctly, and it works only because parallelization is disabled.

This is based on what we had before where the cleanup happened after each cron subtest. If we want to move it at the end of the all suite we can use the func TestMain(m *testing.M) structure but ready the comment related to why we do cleanup after each subtest I think we should keep it like it is so it means that in order to parallelize w eneed to do some work to improve the DeleteResources function

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, the current version doesn't support parallelisation, but it did used to have this enabled (but not working, due to testify). The linter testifylint complained about them having it enabled but disfunctional, so the code was removed.

Ok, let's go with this for now and we can parallelise in a separate PR if we ever get around to it.

I'd still like us not to have to remember the defer though, so wrapping it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if you like the approach, but I added options to the Runner and the cleanup runs if enabled as t.Cleanup function. It sounds idiomatic and I like the API. Let me know

This commit explores how to drop testify from another (first was example
suite) e2e suite. In this case the cronjob one with particular focus on
how to abstract the code used for both migrations in a reusable fashion

Signed-off-by: Gianluca Arbezzano <ciao@gianarb.it>
@gianarb gianarb force-pushed the chore/suite-without-testify branch 2 times, most recently from c9d6c50 to 4befc19 Compare January 7, 2026 15:00
@gianarb gianarb requested a review from Joibel January 7, 2026 15:11
Signed-off-by: Gianluca Arbezzano <ciao@gianarb.it>
@gianarb gianarb force-pushed the chore/suite-without-testify branch from 4befc19 to 82fde00 Compare January 7, 2026 15:59
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.

Build abstraction for the code copied from E2ESuite during examples_test migration out from Testify

2 participants