Skip to content

Commit

Permalink
Merge pull request #3062 from /issues/3061-investigate-org-deletion-t…
Browse files Browse the repository at this point in the history
…imeout

Print cforg namespace in fail handler
  • Loading branch information
georgethebeatle authored Jan 15, 2024
2 parents f67b787 + ce1b69a commit d37636e
Showing 1 changed file with 32 additions and 10 deletions.
42 changes: 32 additions & 10 deletions tests/smoke/smoke_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
. "github.com/onsi/gomega/gexec"
gomegatypes "github.com/onsi/gomega/types"
"gopkg.in/yaml.v2"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/kubernetes/scheme"
Expand Down Expand Up @@ -126,6 +127,22 @@ func printCfApp(config *rest.Config) {
return
}

cfOrgNamespaceName, err := sessionOutput(helpers.Cf("org", orgName, "--guid"))
if err != nil {
fmt.Fprintf(GinkgoWriter, "failed to run 'cf org %s --guid': %v\n", orgName, err)
return
}

err = printObject(k8sClient, &corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: cfOrgNamespaceName,
},
})
if err != nil {
fmt.Fprintf(GinkgoWriter, "failed printing cforg namespace: %v\n", err)
return
}

cfAppNamespace, err := sessionOutput(helpers.Cf("space", spaceName, "--guid"))
if err != nil {
fmt.Fprintf(GinkgoWriter, "failed to run 'cf space %s --guid': %v\n", spaceName, err)
Expand All @@ -137,24 +154,29 @@ func printCfApp(config *rest.Config) {
return
}

cfApp := &korifiv1alpha1.CFApp{
err = printObject(k8sClient, &korifiv1alpha1.CFApp{
ObjectMeta: metav1.ObjectMeta{
Name: cfAppGUID,
Namespace: cfAppNamespace,
},
})
if err != nil {
fmt.Fprintf(GinkgoWriter, "failed printing cfapp: %v\n", err)
return
}
}

if err = k8sClient.Get(context.Background(), client.ObjectKeyFromObject(cfApp), cfApp); err != nil {
fmt.Fprintf(GinkgoWriter, "failed to get cfapp in namespace %q: %v\n", cfAppNamespace, err)
return
func printObject(k8sClient client.Client, obj client.Object) error {
if err := k8sClient.Get(context.Background(), client.ObjectKeyFromObject(obj), obj); err != nil {
return fmt.Errorf("failed to get object %q: %v\n", client.ObjectKeyFromObject(obj), err)
}

fmt.Fprintf(GinkgoWriter, "\n\n========== cfapp %s/%s (skipping managed fields) ==========\n", cfApp.Namespace, cfApp.Name)
cfApp.ManagedFields = []metav1.ManagedFieldsEntry{}
cfAppBytes, err := yaml.Marshal(cfApp)
fmt.Fprintf(GinkgoWriter, "\n\n========== %T %s/%s (skipping managed fields) ==========\n", obj, obj.GetNamespace(), obj.GetName())
obj.SetManagedFields([]metav1.ManagedFieldsEntry{})
objBytes, err := yaml.Marshal(obj)
if err != nil {
fmt.Fprintf(GinkgoWriter, "failed marshalling cfapp: %v\n", err)
return
return fmt.Errorf("failed marshalling object %v: %v\n", obj, err)
}
fmt.Fprintln(GinkgoWriter, string(cfAppBytes))
fmt.Fprintln(GinkgoWriter, string(objBytes))
return nil
}

0 comments on commit d37636e

Please sign in to comment.