mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 20:42:26 +00:00
add unit test for PVC conditions describer
This commit is contained in:
parent
49dcdbe2c5
commit
c29728f220
@ -1020,6 +1020,7 @@ func TestPersistentVolumeClaimDescriber(t *testing.T) {
|
|||||||
block := api.PersistentVolumeBlock
|
block := api.PersistentVolumeBlock
|
||||||
file := api.PersistentVolumeFilesystem
|
file := api.PersistentVolumeFilesystem
|
||||||
goldClassName := "gold"
|
goldClassName := "gold"
|
||||||
|
now := time.Now()
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
pvc *api.PersistentVolumeClaim
|
pvc *api.PersistentVolumeClaim
|
||||||
@ -1070,6 +1071,103 @@ func TestPersistentVolumeClaimDescriber(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expectedElements: []string{"VolumeMode", "Block"},
|
expectedElements: []string{"VolumeMode", "Block"},
|
||||||
},
|
},
|
||||||
|
// Tests for Status.Condition.
|
||||||
|
{
|
||||||
|
name: "condition-type",
|
||||||
|
pvc: &api.PersistentVolumeClaim{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{Namespace: "foo", Name: "bar"},
|
||||||
|
Spec: api.PersistentVolumeClaimSpec{
|
||||||
|
VolumeName: "volume4",
|
||||||
|
StorageClassName: &goldClassName,
|
||||||
|
},
|
||||||
|
Status: api.PersistentVolumeClaimStatus{
|
||||||
|
Conditions: []api.PersistentVolumeClaimCondition{
|
||||||
|
{Type: api.PersistentVolumeClaimResizing},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectedElements: []string{"Conditions", "Type", "Resizing"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "condition-status",
|
||||||
|
pvc: &api.PersistentVolumeClaim{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{Namespace: "foo", Name: "bar"},
|
||||||
|
Spec: api.PersistentVolumeClaimSpec{
|
||||||
|
VolumeName: "volume5",
|
||||||
|
StorageClassName: &goldClassName,
|
||||||
|
},
|
||||||
|
Status: api.PersistentVolumeClaimStatus{
|
||||||
|
Conditions: []api.PersistentVolumeClaimCondition{
|
||||||
|
{Status: api.ConditionTrue},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectedElements: []string{"Conditions", "Status", "True"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "condition-last-probe-time",
|
||||||
|
pvc: &api.PersistentVolumeClaim{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{Namespace: "foo", Name: "bar"},
|
||||||
|
Spec: api.PersistentVolumeClaimSpec{
|
||||||
|
VolumeName: "volume6",
|
||||||
|
StorageClassName: &goldClassName,
|
||||||
|
},
|
||||||
|
Status: api.PersistentVolumeClaimStatus{
|
||||||
|
Conditions: []api.PersistentVolumeClaimCondition{
|
||||||
|
{LastProbeTime: metav1.Time{Time: now}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectedElements: []string{"Conditions", "LastProbeTime", now.Format(time.RFC1123Z)},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "condition-last-transition-time",
|
||||||
|
pvc: &api.PersistentVolumeClaim{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{Namespace: "foo", Name: "bar"},
|
||||||
|
Spec: api.PersistentVolumeClaimSpec{
|
||||||
|
VolumeName: "volume7",
|
||||||
|
StorageClassName: &goldClassName,
|
||||||
|
},
|
||||||
|
Status: api.PersistentVolumeClaimStatus{
|
||||||
|
Conditions: []api.PersistentVolumeClaimCondition{
|
||||||
|
{LastTransitionTime: metav1.Time{Time: now}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectedElements: []string{"Conditions", "LastTransitionTime", now.Format(time.RFC1123Z)},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "condition-reason",
|
||||||
|
pvc: &api.PersistentVolumeClaim{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{Namespace: "foo", Name: "bar"},
|
||||||
|
Spec: api.PersistentVolumeClaimSpec{
|
||||||
|
VolumeName: "volume8",
|
||||||
|
StorageClassName: &goldClassName,
|
||||||
|
},
|
||||||
|
Status: api.PersistentVolumeClaimStatus{
|
||||||
|
Conditions: []api.PersistentVolumeClaimCondition{
|
||||||
|
{Reason: "OfflineResize"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectedElements: []string{"Conditions", "Reason", "OfflineResize"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "condition-message",
|
||||||
|
pvc: &api.PersistentVolumeClaim{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{Namespace: "foo", Name: "bar"},
|
||||||
|
Spec: api.PersistentVolumeClaimSpec{
|
||||||
|
VolumeName: "volume9",
|
||||||
|
StorageClassName: &goldClassName,
|
||||||
|
},
|
||||||
|
Status: api.PersistentVolumeClaimStatus{
|
||||||
|
Conditions: []api.PersistentVolumeClaimCondition{
|
||||||
|
{Message: "User request resize"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectedElements: []string{"Conditions", "Message", "User request resize"},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range testCases {
|
for _, test := range testCases {
|
||||||
|
Loading…
Reference in New Issue
Block a user