Merge pull request #81486 from wongma7/aws-testdriver

Re-implement AWS test driver interfaces
This commit is contained in:
Kubernetes Prow Robot 2019-08-28 18:26:23 -07:00 committed by GitHub
commit 4ba225a541
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1512,17 +1512,18 @@ func (v *azureVolume) DeleteVolume() {
// AWS // AWS
type awsDriver struct { type awsDriver struct {
volumeName string
driverInfo testsuites.DriverInfo driverInfo testsuites.DriverInfo
} }
type awsVolume struct {
volumeName string
}
var _ testsuites.TestDriver = &awsDriver{} var _ testsuites.TestDriver = &awsDriver{}
// TODO: Fix authorization error in attach operation and uncomment below var _ testsuites.PreprovisionedVolumeTestDriver = &awsDriver{}
//var _ testsuites.PreprovisionedVolumeTestDriver = &awsDriver{} var _ testsuites.InlineVolumeTestDriver = &awsDriver{}
//var _ testsuites.InlineVolumeTestDriver = &awsDriver{} var _ testsuites.PreprovisionedPVTestDriver = &awsDriver{}
//var _ testsuites.PreprovisionedPVTestDriver = &awsDriver{}
var _ testsuites.DynamicPVTestDriver = &awsDriver{} var _ testsuites.DynamicPVTestDriver = &awsDriver{}
// InitAwsDriver returns awsDriver that implements TestDriver interface // InitAwsDriver returns awsDriver that implements TestDriver interface
@ -1534,7 +1535,10 @@ func InitAwsDriver() testsuites.TestDriver {
MaxFileSize: testpatterns.FileSizeMedium, MaxFileSize: testpatterns.FileSizeMedium,
SupportedFsType: sets.NewString( SupportedFsType: sets.NewString(
"", // Default fsType "", // Default fsType
"ext2",
"ext3", "ext3",
"ext4",
"xfs",
"ntfs", "ntfs",
), ),
SupportedMountOption: sets.NewString("debug", "nouid32"), SupportedMountOption: sets.NewString("debug", "nouid32"),
@ -1562,12 +1566,12 @@ func (a *awsDriver) SkipUnsupportedTest(pattern testpatterns.TestPattern) {
framework.SkipUnlessProviderIs("aws") framework.SkipUnlessProviderIs("aws")
} }
// TODO: Fix authorization error in attach operation and uncomment below
/*
func (a *awsDriver) GetVolumeSource(readOnly bool, fsType string, volume testsuites.TestVolume) *v1.VolumeSource { func (a *awsDriver) GetVolumeSource(readOnly bool, fsType string, volume testsuites.TestVolume) *v1.VolumeSource {
av, ok := volume.(*awsVolume)
gomega.Expect(ok).To(gomega.BeTrue(), "Failed to cast test volume to AWS test volume")
volSource := v1.VolumeSource{ volSource := v1.VolumeSource{
AWSElasticBlockStore: &v1.AWSElasticBlockStoreVolumeSource{ AWSElasticBlockStore: &v1.AWSElasticBlockStoreVolumeSource{
VolumeID: a.volumeName, VolumeID: av.volumeName,
ReadOnly: readOnly, ReadOnly: readOnly,
}, },
} }
@ -1578,18 +1582,19 @@ func (a *awsDriver) GetVolumeSource(readOnly bool, fsType string, volume testsui
} }
func (a *awsDriver) GetPersistentVolumeSource(readOnly bool, fsType string, volume testsuites.TestVolume) (*v1.PersistentVolumeSource, *v1.VolumeNodeAffinity) { func (a *awsDriver) GetPersistentVolumeSource(readOnly bool, fsType string, volume testsuites.TestVolume) (*v1.PersistentVolumeSource, *v1.VolumeNodeAffinity) {
av, ok := volume.(*awsVolume)
gomega.Expect(ok).To(gomega.BeTrue(), "Failed to cast test volume to AWS test volume")
pvSource := v1.PersistentVolumeSource{ pvSource := v1.PersistentVolumeSource{
AWSElasticBlockStore: &v1.AWSElasticBlockStoreVolumeSource{ AWSElasticBlockStore: &v1.AWSElasticBlockStoreVolumeSource{
VolumeID: a.volumeName, VolumeID: av.volumeName,
ReadOnly: readOnly, ReadOnly: readOnly,
}, },
} }
if fsType != "" { if fsType != "" {
pvSource.AWSElasticBlockStore.FSType = fsType pvSource.AWSElasticBlockStore.FSType = fsType
} }
return &pvSource return &pvSource, nil
} }
*/
func (a *awsDriver) GetDynamicProvisionStorageClass(config *testsuites.PerTestConfig, fsType string) *storagev1.StorageClass { func (a *awsDriver) GetDynamicProvisionStorageClass(config *testsuites.PerTestConfig, fsType string) *storagev1.StorageClass {
provisioner := "kubernetes.io/aws-ebs" provisioner := "kubernetes.io/aws-ebs"
@ -1599,8 +1604,9 @@ func (a *awsDriver) GetDynamicProvisionStorageClass(config *testsuites.PerTestCo
} }
ns := config.Framework.Namespace.Name ns := config.Framework.Namespace.Name
suffix := fmt.Sprintf("%s-sc", a.driverInfo.Name) suffix := fmt.Sprintf("%s-sc", a.driverInfo.Name)
delayedBinding := storagev1.VolumeBindingWaitForFirstConsumer
return testsuites.GetStorageClass(provisioner, parameters, nil, ns, suffix) return testsuites.GetStorageClass(provisioner, parameters, &delayedBinding, ns, suffix)
} }
func (a *awsDriver) GetClaimSize() string { func (a *awsDriver) GetClaimSize() string {
@ -1621,19 +1627,25 @@ func (a *awsDriver) PrepareTest(f *framework.Framework) (*testsuites.PerTestConf
return config, func() {} return config, func() {}
} }
// TODO: Fix authorization error in attach operation and uncomment below
/*
func (a *awsDriver) CreateVolume(config *testsuites.PerTestConfig, volType testpatterns.TestVolType) testsuites.TestVolume { func (a *awsDriver) CreateVolume(config *testsuites.PerTestConfig, volType testpatterns.TestVolType) testsuites.TestVolume {
if volType == testpatterns.InlineVolume {
// PD will be created in framework.TestContext.CloudConfig.Zone zone,
// so pods should be also scheduled there.
config.ClientNodeSelector = map[string]string{
v1.LabelZoneFailureDomain: framework.TestContext.CloudConfig.Zone,
}
}
ginkgo.By("creating a test aws volume") ginkgo.By("creating a test aws volume")
var err error vname, err := framework.CreatePDWithRetry()
a.volumeName, err = framework.CreatePDWithRetry() framework.ExpectNoError(err)
framework.ExpectNoError(err)) return &awsVolume{
volumeName: vname,
}
} }
DeleteVolume() { func (v *awsVolume) DeleteVolume() {
framework.DeletePDWithRetry(a.volumeName) framework.DeletePDWithRetry(v.volumeName)
} }
*/
// local // local
type localDriver struct { type localDriver struct {