-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test case for unit test and delete the duplicated docker file.
- Loading branch information
Showing
7 changed files
with
86 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package nvidia | ||
|
||
import ( | ||
"context" | ||
_ "embed" | ||
"fmt" | ||
"testing" | ||
"time" | ||
|
||
fwext "github.com/aws/aws-k8s-tester/e2e2/internal/framework_extensions" | ||
"sigs.k8s.io/e2e-framework/klient/wait" | ||
"sigs.k8s.io/e2e-framework/pkg/envconf" | ||
"sigs.k8s.io/e2e-framework/pkg/features" | ||
|
||
batchv1 "k8s.io/api/batch/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
var ( | ||
//go:embed manifests/job-unit-test-single-node.yaml | ||
jobUnitTestSingleNodeManifest []byte | ||
renderedJobUnitTestSingleNodeManifest []byte | ||
) | ||
|
||
type unitTestManifestTplVars struct { | ||
NvidiaTestImage string | ||
} | ||
|
||
func TestSingleNodeUnitTest(t *testing.T) { | ||
unitTest := features.New("unit-test"). | ||
WithLabel("suite", "nvidia"). | ||
WithLabel("hardware", "gpu"). | ||
Setup(func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context { | ||
if *nvidiaTestImage == "" { | ||
t.Fatal(fmt.Errorf("nvidiaTestImage must be set to run unit test, use https://github.com/aws/aws-k8s-tester/blob/main/e2e2/test/images/nvidia/Dockerfile to build the image and -nvidiaTestImage to set the image url")) | ||
} | ||
var err error | ||
renderedJobUnitTestSingleNodeManifest, err = fwext.RenderManifests(jobUnitTestSingleNodeManifest, unitTestManifestTplVars{ | ||
NvidiaTestImage: *nvidiaTestImage, | ||
}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
err = fwext.ApplyManifests(cfg.Client().RESTConfig(), renderedJobUnitTestSingleNodeManifest) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
return ctx | ||
}). | ||
Assess("Unit test Job succeeds", func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context { | ||
job := &batchv1.Job{ | ||
ObjectMeta: metav1.ObjectMeta{Name: "unit-test-job", Namespace: "default"}, | ||
} | ||
err := wait.For(fwext.NewConditionExtension(cfg.Client().Resources()).JobSucceeded(job), | ||
wait.WithTimeout(time.Minute*20)) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
return ctx | ||
}). | ||
Teardown(func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context { | ||
err := fwext.DeleteManifests(cfg.Client().RESTConfig(), renderedJobUnitTestSingleNodeManifest) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
return ctx | ||
}). | ||
Feature() | ||
|
||
testenv.Test(t, unitTest) | ||
} |
This file was deleted.
Oops, something went wrong.