Skip to content

Commit 39a1984

Browse files
Fixing unit tests
1 parent 1630010 commit 39a1984

File tree

1 file changed

+10
-181
lines changed

1 file changed

+10
-181
lines changed

controllers/restic_test.go

Lines changed: 10 additions & 181 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ func TestVeleroReconciler_buildResticDaemonset(t *testing.T) {
387387
},
388388
},
389389
{
390-
name: "Valid velero and daemonset for aws as bsl with non-default secret name",
390+
name: "Valid velero with annotation and daemonset for aws as bsl with default secret name",
391391
args: args{
392392
&oadpv1alpha1.Velero{
393393
Spec: oadpv1alpha1.VeleroSpec{
@@ -409,178 +409,7 @@ func TestVeleroReconciler_buildResticDaemonset(t *testing.T) {
409409
},
410410
Credential: &corev1.SecretKeySelector{
411411
LocalObjectReference: corev1.LocalObjectReference{
412-
Name: "aws-creds",
413-
},
414-
},
415-
},
416-
},
417-
},
418-
}, &appsv1.DaemonSet{
419-
ObjectMeta: getResticObjectMeta(r),
420-
},
421-
},
422-
wantErr: false,
423-
want: &appsv1.DaemonSet{
424-
ObjectMeta: getResticObjectMeta(r),
425-
TypeMeta: metav1.TypeMeta{
426-
Kind: "DaemonSet",
427-
APIVersion: appsv1.SchemeGroupVersion.String(),
428-
},
429-
Spec: appsv1.DaemonSetSpec{
430-
UpdateStrategy: appsv1.DaemonSetUpdateStrategy{
431-
Type: appsv1.RollingUpdateDaemonSetStrategyType,
432-
},
433-
Selector: resticLabelSelector,
434-
Template: corev1.PodTemplateSpec{
435-
ObjectMeta: metav1.ObjectMeta{
436-
Labels: map[string]string{
437-
"component": common.Velero,
438-
"name": common.Restic,
439-
},
440-
},
441-
Spec: corev1.PodSpec{
442-
NodeSelector: velero.Spec.ResticNodeSelector,
443-
ServiceAccountName: common.Velero,
444-
SecurityContext: &corev1.PodSecurityContext{
445-
RunAsUser: pointer.Int64(0),
446-
SupplementalGroups: velero.Spec.ResticSupplementalGroups,
447-
},
448-
Volumes: []corev1.Volume{
449-
// Cloud Provider volumes are dynamically added in the for loop below
450-
{
451-
Name: HostPods,
452-
VolumeSource: corev1.VolumeSource{
453-
HostPath: &corev1.HostPathVolumeSource{
454-
Path: resticPvHostPath,
455-
},
456-
},
457-
},
458-
{
459-
Name: "scratch",
460-
VolumeSource: corev1.VolumeSource{
461-
EmptyDir: &corev1.EmptyDirVolumeSource{},
462-
},
463-
},
464-
{
465-
Name: "certs",
466-
VolumeSource: corev1.VolumeSource{
467-
EmptyDir: &corev1.EmptyDirVolumeSource{},
468-
},
469-
},
470-
{
471-
Name: "aws-creds",
472-
VolumeSource: corev1.VolumeSource{
473-
Secret: &corev1.SecretVolumeSource{
474-
SecretName: "aws-creds",
475-
},
476-
},
477-
},
478-
},
479-
Tolerations: velero.Spec.ResticTolerations,
480-
Containers: []corev1.Container{
481-
{
482-
Name: common.Restic,
483-
SecurityContext: &corev1.SecurityContext{
484-
Privileged: pointer.Bool(true),
485-
},
486-
Image: getVeleroImage(&velero),
487-
ImagePullPolicy: corev1.PullAlways,
488-
Resources: r.getVeleroResourceReqs(&velero), //setting default.
489-
Command: []string{
490-
"/velero",
491-
},
492-
Args: []string{
493-
"restic",
494-
"server",
495-
},
496-
VolumeMounts: []corev1.VolumeMount{
497-
{
498-
Name: "host-pods",
499-
MountPath: "/host_pods",
500-
MountPropagation: &mountPropagationToHostContainer,
501-
},
502-
{
503-
Name: "scratch",
504-
MountPath: "/scratch",
505-
},
506-
{
507-
Name: "certs",
508-
MountPath: "/etc/ssl/certs",
509-
},
510-
{
511-
Name: "aws-creds",
512-
MountPath: "/credentials",
513-
},
514-
},
515-
Env: []corev1.EnvVar{
516-
{
517-
Name: "NODE_NAME",
518-
ValueFrom: &corev1.EnvVarSource{
519-
FieldRef: &corev1.ObjectFieldSelector{
520-
FieldPath: "spec.nodeName",
521-
},
522-
},
523-
},
524-
{
525-
Name: "VELERO_NAMESPACE",
526-
ValueFrom: &corev1.EnvVarSource{
527-
FieldRef: &corev1.ObjectFieldSelector{
528-
FieldPath: "metadata.namespace",
529-
},
530-
},
531-
},
532-
{
533-
Name: "VELERO_SCRATCH_DIR",
534-
Value: "/scratch",
535-
},
536-
{
537-
Name: "HTTP_PROXY",
538-
Value: os.Getenv("HTTP_PROXY"),
539-
},
540-
{
541-
Name: "HTTPS_PROXY",
542-
Value: os.Getenv("HTTPS_PROXY"),
543-
},
544-
{
545-
Name: "NO_PROXY",
546-
Value: os.Getenv("NO_PROXY"),
547-
},
548-
{
549-
Name: common.AWSSharedCredentialsFileEnvKey,
550-
Value: "/credentials/cloud",
551-
},
552-
},
553-
},
554-
},
555-
},
556-
},
557-
},
558-
},
559-
},
560-
{
561-
name: "Valid velero with annotation and daemonset for aws as bsl with non-default secret name",
562-
args: args{
563-
&oadpv1alpha1.Velero{
564-
Spec: oadpv1alpha1.VeleroSpec{
565-
DefaultVeleroPlugins: []oadpv1alpha1.DefaultPlugin{
566-
oadpv1alpha1.DefaultPluginAWS,
567-
},
568-
BackupStorageLocations: []velerov1.BackupStorageLocationSpec{
569-
{
570-
Provider: AWSProvider,
571-
StorageType: velerov1.StorageType{
572-
ObjectStorage: &velerov1.ObjectStorageLocation{
573-
Bucket: "aws-bucket",
574-
},
575-
},
576-
Config: map[string]string{
577-
Region: "aws-region",
578-
S3URL: "https://sr-url-aws-domain.com",
579-
InsecureSkipTLSVerify: "false",
580-
},
581-
Credential: &corev1.SecretKeySelector{
582-
LocalObjectReference: corev1.LocalObjectReference{
583-
Name: "aws-creds",
412+
Name: "cloud-credentials",
584413
},
585414
},
586415
},
@@ -645,10 +474,10 @@ func TestVeleroReconciler_buildResticDaemonset(t *testing.T) {
645474
},
646475
},
647476
{
648-
Name: "aws-creds",
477+
Name: "cloud-credentials",
649478
VolumeSource: corev1.VolumeSource{
650479
Secret: &corev1.SecretVolumeSource{
651-
SecretName: "aws-creds",
480+
SecretName: "cloud-credentials",
652481
},
653482
},
654483
},
@@ -685,7 +514,7 @@ func TestVeleroReconciler_buildResticDaemonset(t *testing.T) {
685514
MountPath: "/etc/ssl/certs",
686515
},
687516
{
688-
Name: "aws-creds",
517+
Name: "cloud-credentials",
689518
MountPath: "/credentials",
690519
},
691520
},
@@ -735,7 +564,7 @@ func TestVeleroReconciler_buildResticDaemonset(t *testing.T) {
735564
},
736565
},
737566
{
738-
name: "Valid velero with DNS Policy/Config with annotation and daemonset for aws as bsl with non-default secret name",
567+
name: "Valid velero with DNS Policy/Config with annotation and daemonset for aws as bsl with default secret name",
739568
args: args{
740569
&oadpv1alpha1.Velero{
741570
Spec: oadpv1alpha1.VeleroSpec{
@@ -757,7 +586,7 @@ func TestVeleroReconciler_buildResticDaemonset(t *testing.T) {
757586
},
758587
Credential: &corev1.SecretKeySelector{
759588
LocalObjectReference: corev1.LocalObjectReference{
760-
Name: "aws-creds",
589+
Name: "cloud-credentials",
761590
},
762591
},
763592
},
@@ -854,10 +683,10 @@ func TestVeleroReconciler_buildResticDaemonset(t *testing.T) {
854683
},
855684
},
856685
{
857-
Name: "aws-creds",
686+
Name: "cloud-credentials",
858687
VolumeSource: corev1.VolumeSource{
859688
Secret: &corev1.SecretVolumeSource{
860-
SecretName: "aws-creds",
689+
SecretName: "cloud-credentials",
861690
},
862691
},
863692
},
@@ -894,7 +723,7 @@ func TestVeleroReconciler_buildResticDaemonset(t *testing.T) {
894723
MountPath: "/etc/ssl/certs",
895724
},
896725
{
897-
Name: "aws-creds",
726+
Name: "cloud-credentials",
898727
MountPath: "/credentials",
899728
},
900729
},

0 commit comments

Comments
 (0)