mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
ci: add function to validate checksum
calculateSha512sum() returns the md5sum of a file inside a pod. Signed-off-by: Yug <yuggupta27@gmail.com>
This commit is contained in:
parent
d1d88cb4d6
commit
63b5a7ac96
16
e2e/pod.go
16
e2e/pod.go
@ -210,3 +210,19 @@ func deletePodWithLabel(label, ns string, skipNotFound bool) error {
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// calculateSHA512sum returns the sha512sum of a file inside a pod.
|
||||
func calculateSHA512sum(f *framework.Framework, app *v1.Pod, filePath string, opt *metav1.ListOptions) (string, error) {
|
||||
cmd := fmt.Sprintf("sha512sum %s", filePath)
|
||||
sha512sumOut, stdErr, err := execCommandInPod(f, cmd, app.Namespace, opt)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if stdErr != "" {
|
||||
return "", fmt.Errorf("error: sha512sum could not be calculated %v", stdErr)
|
||||
}
|
||||
// extract checksum from sha512sum output.
|
||||
checkSum := strings.Split(sha512sumOut, "")[0]
|
||||
e2elog.Logf("Calculated checksum %s", checkSum)
|
||||
return checkSum, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user