mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-08-15 11:46:06 +00:00
Add unit tests, change copyright years and revert unrelated changes.
Signed-off-by: Hoang, Phuong <phuong.n.hoang@dell.com>
This commit is contained in:
@@ -1 +0,0 @@
|
||||
Support multiple skip option for E2E test
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2017 the Velero contributors.
|
||||
Copyright 2017, 2022 the Velero contributors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 the Velero contributors.
|
||||
Copyright 2018, 2022 the Velero contributors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -115,6 +115,25 @@ func TestPodActionExecute(t *testing.T) {
|
||||
{GroupResource: kuberesource.PersistentVolumeClaims, Namespace: "foo", Name: "claim2"},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "test priority class",
|
||||
pod: velerotest.UnstructuredOrDie(`
|
||||
{
|
||||
"apiVersion": "v1",
|
||||
"kind": "Pod",
|
||||
"metadata": {
|
||||
"namespace": "foo",
|
||||
"name": "bar"
|
||||
},
|
||||
"spec": {
|
||||
"priorityClassName": "testPriorityClass"
|
||||
}
|
||||
}
|
||||
`),
|
||||
expected: []velero.ResourceIdentifier{
|
||||
{GroupResource: kuberesource.PriorityClasses, Name: "testPriorityClass"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 the Velero contributors.
|
||||
Copyright 2018, 2022 the Velero contributors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2017 the Velero contributors.
|
||||
Copyright 2017, 2022 the Velero contributors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2017, 2019 the Velero contributors.
|
||||
Copyright 2017, 2019, 2022 the Velero contributors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -17,6 +17,8 @@ limitations under the License.
|
||||
package restore
|
||||
|
||||
import (
|
||||
"github.com/vmware-tanzu/velero/pkg/kuberesource"
|
||||
//"github.com/vmware-tanzu/velero/pkg/kuberesource"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -34,10 +36,11 @@ func TestPodActionExecute(t *testing.T) {
|
||||
var priority int32 = 1
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
obj corev1api.Pod
|
||||
expectedErr bool
|
||||
expectedRes corev1api.Pod
|
||||
name string
|
||||
obj corev1api.Pod
|
||||
expectedErr bool
|
||||
expectedRes corev1api.Pod
|
||||
additionalItems []velero.ResourceIdentifier
|
||||
}{
|
||||
{
|
||||
name: "nodeName (only) should be deleted from spec",
|
||||
@@ -189,6 +192,35 @@ func TestPodActionExecute(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "test priority class",
|
||||
obj: corev1api.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pod-1"},
|
||||
Spec: corev1api.PodSpec{
|
||||
ServiceAccountName: "foo",
|
||||
PriorityClassName: "testPriorityClass",
|
||||
Volumes: []corev1api.Volume{
|
||||
{Name: "foo"},
|
||||
{Name: "foo-token-foo"},
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedRes: corev1api.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pod-1"},
|
||||
Spec: corev1api.PodSpec{
|
||||
ServiceAccountName: "foo",
|
||||
PriorityClassName: "testPriorityClass",
|
||||
Volumes: []corev1api.Volume{
|
||||
{Name: "foo"},
|
||||
},
|
||||
},
|
||||
},
|
||||
additionalItems: []velero.ResourceIdentifier{
|
||||
{GroupResource: kuberesource.PriorityClasses,
|
||||
Name: "testPriorityClass",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
@@ -214,6 +246,7 @@ func TestPodActionExecute(t *testing.T) {
|
||||
require.NoError(t, runtime.DefaultUnstructuredConverter.FromUnstructured(res.UpdatedItem.UnstructuredContent(), &pod))
|
||||
|
||||
assert.Equal(t, test.expectedRes, pod)
|
||||
assert.Equal(t, test.additionalItems, res.AdditionalItems)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ If you encounter issues, review the [troubleshooting docs][30], [file an issue][
|
||||
|
||||
## Contributing
|
||||
|
||||
If you are ready to jump in and test, add code, or help with documentation, follow the instructions on our [Start contributing](https://velero.io/docs/v1.8/start-contributing/) documentation for guidance on how to setup Velero for development.
|
||||
If you are ready to jump in and test, add code, or help with documentation, follow the instructions on our [Start contributing](https://velero.io/docs/v1.8.0/start-contributing/) documentation for guidance on how to setup Velero for development.
|
||||
|
||||
## Changelog
|
||||
|
||||
|
||||
+1
-2
@@ -47,7 +47,6 @@ KUSTOMIZE := $(TOOLS_BIN_DIR)/kustomize
|
||||
OUTPUT_DIR := _output/$(GOOS)/$(GOARCH)/bin
|
||||
GINKGO_FOCUS ?=
|
||||
GINKGO_SKIP ?=
|
||||
SKIP_STR := $(foreach var, $(subst ., ,$(GINKGO_SKIP)),-skip "$(var)")
|
||||
VELERO_CLI ?=$$(pwd)/../../_output/bin/$(GOOS)/$(GOARCH)/velero
|
||||
VELERO_IMAGE ?= velero/velero:main
|
||||
VELERO_VERSION ?= $(VERSION)
|
||||
@@ -87,7 +86,7 @@ run: ginkgo
|
||||
(echo "Bucket to store the backups from E2E tests is required, please re-run with BSL_BUCKET=<BucketName>"; exit 1 )
|
||||
@[ "${CLOUD_PROVIDER}" ] && echo "Using cloud provider ${CLOUD_PROVIDER}" || \
|
||||
(echo "Cloud provider for target cloud/plug-in provider is required, please rerun with CLOUD_PROVIDER=<aws,azure,kind,vsphere>"; exit 1)
|
||||
@$(GINKGO) -v -focus="$(GINKGO_FOCUS)" $(SKIP_STR) . -- -velerocli=$(VELERO_CLI) \
|
||||
@$(GINKGO) -v -focus="$(GINKGO_FOCUS)" -skip="$(GINKGO_SKIP)" . -- -velerocli=$(VELERO_CLI) \
|
||||
-velero-image=$(VELERO_IMAGE) \
|
||||
-plugins=$(PLUGINS) \
|
||||
-velero-version=$(VELERO_VERSION) \
|
||||
|
||||
Reference in New Issue
Block a user