Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/tests/utils.go b/tests/utils.go
- index a45b8eb2a..82f77cefb 100644
- --- a/tests/utils.go
- +++ b/tests/utils.go
- @@ -28,6 +28,7 @@ import (
- "fmt"
- "io"
- "io/ioutil"
- + "net/http"
- "os"
- "os/exec"
- "path/filepath"
- @@ -359,6 +360,7 @@ func BeforeTestSuitSetup() {
- createNamespaces()
- createServiceAccounts()
- if DeployTestingInfrastructureFlag {
- + WipeTestingInfrastructure()
- DeployTestingInfrastructure()
- }
- @@ -505,8 +507,9 @@ func ReadManifestYamlFile(pathToManifest string) []unstructured.Unstructured {
- return objects
- }
- -func isGroupVersionKindScoped(kind schema.GroupVersionKind) bool {
- - if kind.Group == "rbac.authorization.k8s.io" {
- +func isNamespaceScoped(kind schema.GroupVersionKind) bool {
- + switch kind.Kind {
- + case "ClusterRole", "ClusterRoleBinding":
- return false
- }
- return true
- @@ -518,7 +521,7 @@ func composeResourceURI(object unstructured.Unstructured) string {
- uri += "s"
- }
- uri += "/" + object.GetAPIVersion()
- - if object.GetNamespace() != "" && isGroupVersionKindScoped(object.GroupVersionKind()) {
- + if object.GetNamespace() != "" && isNamespaceScoped(object.GroupVersionKind()) {
- uri += "/namespaces/" + object.GetNamespace()
- }
- uri += "/" + strings.ToLower(object.GetKind())
- @@ -549,15 +552,16 @@ func DeleteRawManifest(object unstructured.Unstructured) error {
- PanicOnError(err)
- uri := composeResourceURI(object)
- - jsonbody, err := object.MarshalJSON()
- + uri = uri + "/" + object.GetName()
- PanicOnError(err)
- - b, err := virtCli.CoreV1().RESTClient().Delete().RequestURI(uri).Body(jsonbody).DoRaw()
- - if err != nil {
- + result := virtCli.CoreV1().RESTClient().Delete().RequestURI(uri).Do()
- + var code int
- + result.StatusCode(&code)
- + if result.Error() != nil && code != http.StatusNotFound {
- fmt.Printf(fmt.Sprintf("ERROR: Can not delete %s\n", object))
- panic(err)
- }
- - status := unstructured.Unstructured{}
- - return json.Unmarshal(b, &status)
- + return nil
- }
- func DeployTestingInfrastructure() {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement