test_client.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. Copyright 2016 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 clients
  14. import (
  15. "fmt"
  16. "github.com/rook/rook/pkg/daemon/ceph/client"
  17. "github.com/rook/rook/tests/framework/installer"
  18. "github.com/rook/rook/tests/framework/utils"
  19. )
  20. // TestClient is a wrapper for test client, containing interfaces for all rook operations
  21. type TestClient struct {
  22. BlockClient *BlockOperation
  23. FSClient *FilesystemOperation
  24. NFSClient *NFSOperation
  25. ObjectClient *ObjectOperation
  26. ObjectUserClient *ObjectUserOperation
  27. PoolClient *PoolOperation
  28. BucketClient *BucketOperation
  29. UserClient *ClientOperation
  30. RBDMirrorClient *RBDMirrorOperation
  31. TopicClient *TopicOperation
  32. NotificationClient *NotificationOperation
  33. COSIClient *COSIOperation
  34. k8sh *utils.K8sHelper
  35. }
  36. // CreateTestClient creates new instance of test client for a platform
  37. func CreateTestClient(k8sHelper *utils.K8sHelper, manifests installer.CephManifests) *TestClient {
  38. return &TestClient{
  39. CreateBlockOperation(k8sHelper, manifests),
  40. CreateFilesystemOperation(k8sHelper, manifests),
  41. CreateNFSOperation(k8sHelper, manifests),
  42. CreateObjectOperation(k8sHelper, manifests),
  43. CreateObjectUserOperation(k8sHelper, manifests),
  44. CreatePoolOperation(k8sHelper, manifests),
  45. CreateBucketOperation(k8sHelper, manifests),
  46. CreateClientOperation(k8sHelper, manifests),
  47. CreateRBDMirrorOperation(k8sHelper, manifests),
  48. CreateTopicOperation(k8sHelper, manifests),
  49. CreateNotificationOperation(k8sHelper, manifests),
  50. CreateCOSIOperation(k8sHelper, manifests),
  51. k8sHelper,
  52. }
  53. }
  54. // Status returns rook status details
  55. func (c TestClient) Status(namespace string) (client.CephStatus, error) {
  56. context := c.k8sh.MakeContext()
  57. clusterInfo := client.AdminTestClusterInfo(namespace)
  58. status, err := client.Status(context, clusterInfo)
  59. if err != nil {
  60. return client.CephStatus{}, fmt.Errorf("failed to get status: %+v", err)
  61. }
  62. return status, nil
  63. }