ceph_base_nfs_test.go 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. Copyright 2022 The Rook Authors. All rights reserved.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package integration
  14. import (
  15. "github.com/rook/rook/tests/framework/clients"
  16. "github.com/rook/rook/tests/framework/installer"
  17. "github.com/rook/rook/tests/framework/utils"
  18. "github.com/stretchr/testify/assert"
  19. "github.com/stretchr/testify/require"
  20. "github.com/stretchr/testify/suite"
  21. )
  22. // Smoke Test for File System Storage for CephNFS - Test check the following operations on Filesystem Storage in order
  23. // Create,Mount,Write,Read,Unmount and Delete.
  24. func runNFSFileE2ETest(helper *clients.TestClient, k8sh *utils.K8sHelper, s *suite.Suite, settings *installer.TestCephSettings, filesystemName string) {
  25. defer fileTestDataCleanUp(helper, k8sh, s, filePodName, settings.Namespace, filesystemName)
  26. logger.Infof("Running on Rook Cluster %s", settings.Namespace)
  27. logger.Infof("File Storage End To End Integration Test for CephNFS- create, mount, write to, read from, and unmount")
  28. activeCount := 1
  29. createFilesystem(helper, k8sh, s, settings, filesystemName, activeCount)
  30. nfsClusterName := "my-nfs"
  31. err := helper.NFSClient.Create(settings.Namespace, nfsClusterName, 1)
  32. require.Nil(s.T(), err)
  33. if settings.TestNFSCSI {
  34. storageClassName := "nfs-storageclass"
  35. err = helper.NFSClient.CreateStorageClass(filesystemName, nfsClusterName, settings.OperatorNamespace, settings.Namespace, storageClassName)
  36. assert.NoError(s.T(), err)
  37. createFilesystemConsumerPod(helper, k8sh, s, settings, filesystemName, storageClassName)
  38. // Test reading and writing to the first pod
  39. err = writeAndReadToFilesystem(helper, k8sh, s, settings.Namespace, filePodName, "test_file")
  40. assert.NoError(s.T(), err)
  41. cleanupFilesystemConsumer(helper, k8sh, s, settings.Namespace, filePodName)
  42. assert.NoError(s.T(), err)
  43. fileSystemCSISnapshotTest(helper, k8sh, s, storageClassName, settings.Namespace, true)
  44. fileSystemCSICloneTest(helper, k8sh, s, storageClassName, settings.Namespace)
  45. }
  46. err = helper.NFSClient.Delete(settings.Namespace, nfsClusterName)
  47. assert.Nil(s.T(), err)
  48. cleanupFilesystem(helper, k8sh, s, settings.Namespace, filesystemName)
  49. }