-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
200 additions
and
27 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
File renamed without changes.
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,5 @@ | ||
# Helper Image | ||
|
||
This image is used to perform extra setup and verification tasks for the | ||
integration test. This image contains scripts that can be run to perform these | ||
actions. |
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,31 @@ | ||
#!/bin/bash | ||
|
||
function usage() { | ||
echo | ||
echo "Verify the md5sums of two files match" | ||
echo "This is used after copy_out directives to ensure the copy_in file matches the copy_out file" | ||
echo | ||
echo "Syntax: copy-out.sh FILE_IN FILE_OUT" | ||
echo | ||
echo "examples:" | ||
echo "copy-out.sh testuser/test.in testuser/test.out" | ||
echo | ||
} | ||
|
||
COPY_IN=$1 | ||
COPY_OUT=$2 | ||
|
||
if [[ -z "$COPY_IN" ]]; then | ||
usage | ||
exit 1 | ||
elif [[ -z "$COPY_OUT" ]]; then | ||
usage | ||
exit 1 | ||
fi | ||
|
||
if [[ "$(md5sum "$COPY_IN")" = "$(md5sum "$COPY_OUT")" ]]; then | ||
exit 0 | ||
else | ||
echo "md5sums do not match" | ||
exit 1 | ||
fi |
File renamed without changes.
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,124 @@ | ||
package internal | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"strings" | ||
"time" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
dwsv1alpha2 "github.com/DataWorkflowServices/dws/api/v1alpha2" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/types" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
func GetSystemConfiguraton(ctx context.Context, k8sClient client.Client) *dwsv1alpha2.SystemConfiguration { | ||
// TODO: Move this to a global variable and initialized in the test suite. | ||
// Note that putting the GET in Prepare will not work for things like | ||
// WithPersistentLustre() since those options run new MakeTests and do not | ||
// run prepare. | ||
|
||
systemConfig := &dwsv1alpha2.SystemConfiguration{} | ||
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: "default", Namespace: corev1.NamespaceDefault}, systemConfig)).To(Succeed()) | ||
|
||
// Except there to be at least 1 compute and storage node | ||
Expect(systemConfig.Spec.ComputeNodes).ToNot(HaveLen(0)) | ||
Expect(systemConfig.Spec.StorageNodes).ToNot(HaveLen(0)) | ||
|
||
return systemConfig | ||
} | ||
|
||
// Start up a pod that accesses the global lustre filesystem and creates a file | ||
// in the location specified by the copy_in directive. | ||
func SetupCopyIn(ctx context.Context, k8sClient client.Client, t *T, o TOptions) { | ||
|
||
// remove global lustre filePath/ from the filepath | ||
filePath := strings.Replace(o.globalLustre.in, o.globalLustre.mountRoot+"/", "", 1) | ||
|
||
By("Starting copy-in pod and placing file(s) on global lustre") | ||
runHelperPod(ctx, k8sClient, t, "copy-in", "/copy_in.sh", []string{ | ||
o.globalLustre.mountRoot, | ||
filePath, | ||
fmt.Sprintf("%d", t.workflow.Spec.UserID), | ||
fmt.Sprintf("%d", t.workflow.Spec.GroupID), | ||
}) | ||
} | ||
|
||
// Start up a pod that accesses the global lustre filesystem and verifies that | ||
// the files specified by the copy_in and copy_out directives match. | ||
func VerifyCopyOut(ctx context.Context, k8sClient client.Client, t *T, o TOptions) { | ||
lus := t.options.globalLustre | ||
|
||
By("Starting copy-out pod and verifying copy out") | ||
runHelperPod(ctx, k8sClient, t, "copy-out", "/copy_out.sh", []string{ | ||
fmt.Sprintf("%s/%s", lus.mountRoot, lus.in), | ||
fmt.Sprintf("%s/%s", lus.mountRoot, lus.out), | ||
}) | ||
} | ||
|
||
// Start up a pod with the given command/args and verify that it runs to completion | ||
func runHelperPod(ctx context.Context, k8sClient client.Client, t *T, name, command string, args []string) { | ||
systemConfig := GetSystemConfiguraton(ctx, k8sClient) | ||
rabbitName := systemConfig.Spec.StorageNodes[0].Name | ||
o := t.options | ||
|
||
pod := &corev1.Pod{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: t.workflow.Name + "-" + name, | ||
Namespace: t.workflow.Namespace, | ||
}, | ||
Spec: corev1.PodSpec{ | ||
RestartPolicy: corev1.RestartPolicyNever, | ||
NodeName: rabbitName, | ||
Containers: []corev1.Container{{ | ||
Name: name, | ||
Image: "ghcr.io/nearnodeflash/nnf-integration-test-helper:copy-in-copy-out", | ||
ImagePullPolicy: corev1.PullAlways, | ||
Command: []string{ | ||
command, | ||
}, | ||
Args: args, | ||
VolumeMounts: []corev1.VolumeMount{{ | ||
Name: o.globalLustre.name, | ||
MountPath: o.globalLustre.mountRoot, | ||
}}, | ||
}}, | ||
Volumes: []corev1.Volume{{ | ||
Name: o.globalLustre.name, | ||
VolumeSource: corev1.VolumeSource{ | ||
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ | ||
ClaimName: fmt.Sprintf("%s-%s-readwritemany-pvc", | ||
o.globalLustre.name, t.workflow.Namespace), | ||
}, | ||
}, | ||
}}, | ||
}, | ||
} | ||
|
||
dwsv1alpha2.InheritParentLabels(pod, t.workflow) | ||
dwsv1alpha2.AddOwnerLabels(pod, t.workflow) | ||
dwsv1alpha2.AddWorkflowLabels(pod, t.workflow) | ||
|
||
Expect(k8sClient.Create(ctx, pod)).To(Succeed()) | ||
t.helperPods = append(t.helperPods, pod) | ||
|
||
// Wait for successful completion | ||
Eventually(func(g Gomega) bool { | ||
g.Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(pod), pod)).To(Succeed()) | ||
return pod.Status.Phase == corev1.PodSucceeded | ||
}).WithTimeout(time.Minute).WithPolling(time.Second).Should(BeTrue()) | ||
} | ||
|
||
func CleanupHelperPods(ctx context.Context, k8sClient client.Client, t *T) { | ||
for _, p := range t.helperPods { | ||
By(fmt.Sprintf("Deleting helper pod %s", p.Name)) | ||
Expect(k8sClient.Delete(ctx, p)).To(Succeed()) | ||
Eventually(func() error { | ||
return k8sClient.Get(ctx, client.ObjectKeyFromObject(p), p) | ||
}).ShouldNot(Succeed(), "helper pod should delete") | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.