Skip to content

Conversation

@jpculp
Copy link

@jpculp jpculp commented Oct 17, 2025

Issue #, if available:

Description of changes:

Adds a simple workload test case that runs a command or script within a test container.

Sample output from Python-based "Hello world" type of container:

2025/10/17 01:02:01 Starting workload test suite...
=== RUN   TestWorkload
=== RUN   TestWorkload/single-node
    workload_test.go:54: Applying single node manifest
    workload_test.go:59: Manifest applied successfully
=== RUN   TestWorkload/single-node/Single_node_test_Job_succeeds
    workload_test.go:66: Waiting for single node job to complete
=== NAME  TestWorkload/single-node
    workload_test.go:83: Test log for hello-python:
    workload_test.go:84: hello, python

--- PASS: TestWorkload (15.60s)
    --- PASS: TestWorkload/single-node (15.60s)
        --- PASS: TestWorkload/single-node/Single_node_test_Job_succeeds (15.01s)
PASS

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Signed-off-by: Patrick J.P. Culp <jpculp@amazon.com>
Comment on lines +36 to +44
if *workloadTestCommand == "" {
t.Fatal(fmt.Errorf("workloadTestCommand must be set to run workload test"))
}
if *workloadTestImage == "" {
t.Fatal(fmt.Errorf("workloadTestImage must be set to run workload test"))
}
if *workloadTestName == "" {
t.Fatal(fmt.Errorf("workloadTestName must be set to run workload test"))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: just shortening

Suggested change
if *workloadTestCommand == "" {
t.Fatal(fmt.Errorf("workloadTestCommand must be set to run workload test"))
}
if *workloadTestImage == "" {
t.Fatal(fmt.Errorf("workloadTestImage must be set to run workload test"))
}
if *workloadTestName == "" {
t.Fatal(fmt.Errorf("workloadTestName must be set to run workload test"))
}
if *workloadTestCommand == "" {
t.Fatal("workloadTestCommand must be set to run workload test")
}
if *workloadTestImage == "" {
t.Fatal("workloadTestImage must be set to run workload test")
}
if *workloadTestName == "" {
t.Fatal("workloadTestName must be set to run workload test")
}

}).
Assess("Single node test Job succeeds", func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
job := &batchv1.Job{
ObjectMeta: metav1.ObjectMeta{Name: *workloadTestName, Namespace: "default"},
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: is there a default namespace enum in corev1 we can use just for posterity?

if err != nil {
t.Error(err)
} else {
t.Log(fmt.Sprintf("Test log for %s:", *workloadTestName))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
t.Log(fmt.Sprintf("Test log for %s:", *workloadTestName))
t.Logf("Test log for %s:", *workloadTestName)

Copy link
Contributor

Choose a reason for hiding this comment

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

this template is actually so minimal i feel like its worth just using the go type for?

Copy link
Contributor

Choose a reason for hiding this comment

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

just want to nit the naming, "workload" is pretty broad, could we pick a clear name with a theme like "jobTemplate"? I'm really open to suggestions but i want to make sure this is sane/immediately readable

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.

2 participants