installer.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 installer
  14. import (
  15. "fmt"
  16. "testing"
  17. "github.com/coreos/pkg/capnslog"
  18. "github.com/rook/rook/tests/framework/utils"
  19. "github.com/stretchr/testify/assert"
  20. "k8s.io/apimachinery/pkg/api/errors"
  21. )
  22. const (
  23. // LocalBuildTag tag for the latest manifests
  24. LocalBuildTag = "local-build"
  25. // test suite names
  26. CassandraTestSuite = "cassandra"
  27. CephTestSuite = "ceph"
  28. NFSTestSuite = "nfs"
  29. )
  30. var (
  31. logger = capnslog.NewPackageLogger("github.com/rook/rook", "installer")
  32. createArgs = []string{"create", "-f"}
  33. createFromStdinArgs = append(createArgs, "-")
  34. deleteArgs = []string{"delete", "-f"}
  35. deleteFromStdinArgs = append(deleteArgs, "-")
  36. )
  37. func SystemNamespace(namespace string) string {
  38. if utils.IsPlatformOpenShift() {
  39. logger.Infof("For openshift execution used system namespace: %s", namespace)
  40. return namespace
  41. }
  42. return fmt.Sprintf("%s-system", namespace)
  43. }
  44. func checkError(t *testing.T, err error, message string) {
  45. // During cleanup the resource might not be found because the test might have failed before the test was done and never created the resource
  46. if err == nil || errors.IsNotFound(err) {
  47. return
  48. }
  49. assert.NoError(t, err, "%s. %+v", message, err)
  50. }