Skip to content

Commit 3c1576d

Browse files
committed
Add e2e for fsGroupChangePolicy for RWOP volume types
1 parent 1e7b440 commit 3c1576d

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

test/e2e/storage/testsuites/fsgroupchangepolicy.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ func (s *fsGroupChangePolicyTestSuite) DefineTests(driver storageframework.TestD
113113
l = local{}
114114
l.driver = driver
115115
l.config = driver.PrepareTest(ctx, f)
116-
testVolumeSizeRange := s.GetTestSuiteInfo().SupportedSizeRange
117-
l.resource = storageframework.CreateVolumeResource(ctx, l.driver, l.config, pattern, testVolumeSizeRange)
118116
}
119117

120118
cleanup := func(ctx context.Context) {
@@ -129,6 +127,8 @@ func (s *fsGroupChangePolicyTestSuite) DefineTests(driver storageframework.TestD
129127
framework.ExpectNoError(errors.NewAggregate(errs), "while cleanup resource")
130128
}
131129

130+
rwopAccessMode := v1.ReadWriteOncePod
131+
132132
tests := []struct {
133133
name string // Test case name
134134
podfsGroupChangePolicy string // 'Always' or 'OnRootMismatch'
@@ -143,6 +143,7 @@ func (s *fsGroupChangePolicyTestSuite) DefineTests(driver storageframework.TestD
143143
// * OnRootMismatch policy is not supported.
144144
// * It may not be possible to chgrp after mounting a volume.
145145
supportsVolumeMountGroup bool
146+
volumeAccessMode *v1.PersistentVolumeAccessMode
146147
}{
147148
// Test cases for 'Always' policy
148149
{
@@ -154,6 +155,16 @@ func (s *fsGroupChangePolicyTestSuite) DefineTests(driver storageframework.TestD
154155
finalExpectedSubDirFileOwnership: 2000,
155156
supportsVolumeMountGroup: true,
156157
},
158+
{
159+
name: "rwop pod created with an initial fsgroup, new pod fsgroup applied to volume contents",
160+
podfsGroupChangePolicy: "Always",
161+
initialPodFsGroup: 1000,
162+
secondPodFsGroup: 2000,
163+
finalExpectedRootDirFileOwnership: 2000,
164+
finalExpectedSubDirFileOwnership: 2000,
165+
supportsVolumeMountGroup: true,
166+
volumeAccessMode: &rwopAccessMode,
167+
},
157168
{
158169
name: "pod created with an initial fsgroup, volume contents ownership changed via chgrp in first pod, new pod with same fsgroup applied to the volume contents",
159170
podfsGroupChangePolicy: "Always",
@@ -218,6 +229,13 @@ func (s *fsGroupChangePolicyTestSuite) DefineTests(driver storageframework.TestD
218229
}
219230

220231
init(ctx)
232+
testVolumeSizeRange := s.GetTestSuiteInfo().SupportedSizeRange
233+
if test.volumeAccessMode != nil {
234+
accessModes := []v1.PersistentVolumeAccessMode{*test.volumeAccessMode}
235+
l.resource = storageframework.CreateVolumeResourceWithAccessModes(ctx, l.driver, l.config, pattern, testVolumeSizeRange, accessModes, nil)
236+
} else {
237+
l.resource = storageframework.CreateVolumeResource(ctx, l.driver, l.config, pattern, testVolumeSizeRange)
238+
}
221239
ginkgo.DeferCleanup(cleanup)
222240
podConfig := e2epod.Config{
223241
NS: f.Namespace.Name,

0 commit comments

Comments
 (0)