forked from opendatahub-io/opendatahub-operator
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cherry-pick]: from ODH to RHOAI with refactor and bug fixes (#232)
* chore: move testing fixtures to fixtures directory (#906) This change aims to enhance the readability of our test suite. It brings `/crds` and `/templates` into `/fixtures` and moves more helper functions out into dedicated files. * feat(build): adds gci to go fmt target (#925) This update incorporates the `gci` tool into the `make fmt` command, aiming to improve the formatting of Go files and ensure that imports adhere to our established conventions. Unfortunately, due to how `.golangci.yml` is defined, we are not able to just use `--disable-all --enable=gci` flags. This yields an error as we use `enable-all` and `disable` in the config file for linter. To address this, the `golangci-lint` configuration is dynamically adjusted using the `yq` tool, which is now included in our toolchain. This process creates a temporary configuration file specifically for `golangci-lint` execution, ensuring `gci`'s integration without altering the primary linting setup. Furthermore, the generated temporary file is added to the `CLEANFILES` list, ensuring its removal when calling `make clean`, maintaining a clean build environment. To prevent this temporary file from being tracked by Git, a `*.mktmp.*` pattern has been added to our `.gitignore`, safeguarding against accidental inclusion of temporary files in the repository.: ### Tidies - removes duplicate `blank` import section in `gci` config, otherwise it can add `_` imports twice * chore: splits feature tests to separate files (#924) As the number of test cases (grouped as `Describe`) started to grow, we can split a single file into several groups per functionality. Follow-up for #906. * fix(dashboard): do not set owner on CR (#923) Signed-off-by: Wen Zhou <wenzhou@redhat.com> * (fix): Description patch during make bundle (#926) * feat(DW): prepare CF,ray,kueue for GA (#929) Signed-off-by: Wen Zhou <wenzhou@redhat.com> * fix(dashboard): wrong path for consolelink in downstream (#933) Signed-off-by: Wen Zhou <wenzhou@redhat.com> * docs: remove modelregistry and update default application NS Signed-off-by: Zhou, Wen <wenzhou@redhat.com> --------- Signed-off-by: Wen Zhou <wenzhou@redhat.com> Signed-off-by: Zhou, Wen <wenzhou@redhat.com> Co-authored-by: Cameron Garrison <cgarriso@redhat.com> Co-authored-by: Bartosz Majsak <bartosz.majsak@gmail.com> Co-authored-by: Ajay Jaganathan <36824134+AjayJagan@users.noreply.github.com>
- Loading branch information
1 parent
c4b93d5
commit dd2b28f
Showing
28 changed files
with
2,756 additions
and
744 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package features_test | ||
|
||
import ( | ||
"context" | ||
|
||
"k8s.io/apimachinery/pkg/api/errors" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
|
||
dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" | ||
featurev1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/features/v1" | ||
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/feature" | ||
"github.com/opendatahub-io/opendatahub-operator/v2/tests/envtestutil" | ||
"github.com/opendatahub-io/opendatahub-operator/v2/tests/integration/features/fixtures" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
. "github.com/onsi/gomega/gstruct" | ||
) | ||
|
||
var _ = Describe("feature cleanup", func() { | ||
|
||
Context("using FeatureTracker and ownership as cleanup strategy", Ordered, func() { | ||
|
||
const ( | ||
featureName = "create-secret" | ||
secretName = "test-secret" | ||
) | ||
|
||
var ( | ||
dsci *dsciv1.DSCInitialization | ||
namespace string | ||
featuresHandler *feature.FeaturesHandler | ||
) | ||
|
||
BeforeAll(func() { | ||
namespace = envtestutil.AppendRandomNameTo("test-secret-ownership") | ||
dsci = fixtures.NewDSCInitialization(namespace) | ||
featuresHandler = feature.ClusterFeaturesHandler(dsci, func(handler *feature.FeaturesHandler) error { | ||
secretCreationErr := feature.CreateFeature(featureName). | ||
For(handler). | ||
UsingConfig(envTest.Config). | ||
PreConditions( | ||
feature.CreateNamespaceIfNotExists(namespace), | ||
). | ||
WithResources(fixtures.CreateSecret(secretName, namespace)). | ||
Load() | ||
|
||
Expect(secretCreationErr).ToNot(HaveOccurred()) | ||
|
||
return nil | ||
}) | ||
|
||
}) | ||
|
||
It("should successfully create resource and associated feature tracker", func() { | ||
// when | ||
Expect(featuresHandler.Apply()).Should(Succeed()) | ||
|
||
// then | ||
Eventually(createdSecretHasOwnerReferenceToOwningFeature(namespace, secretName)). | ||
WithTimeout(fixtures.Timeout). | ||
WithPolling(fixtures.Interval). | ||
Should(Succeed()) | ||
}) | ||
|
||
It("should remove feature tracker on clean-up", func() { | ||
// when | ||
Expect(featuresHandler.Delete()).To(Succeed()) | ||
|
||
// then | ||
Eventually(createdSecretHasOwnerReferenceToOwningFeature(namespace, secretName)). | ||
WithTimeout(fixtures.Timeout). | ||
WithPolling(fixtures.Interval). | ||
Should(WithTransform(errors.IsNotFound, BeTrue())) | ||
}) | ||
|
||
}) | ||
|
||
}) | ||
|
||
func createdSecretHasOwnerReferenceToOwningFeature(namespace, secretName string) func() error { | ||
return func() error { | ||
secret, err := envTestClientset.CoreV1(). | ||
Secrets(namespace). | ||
Get(context.TODO(), secretName, metav1.GetOptions{}) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
Expect(secret.OwnerReferences).Should( | ||
ContainElement( | ||
MatchFields(IgnoreExtras, Fields{"Kind": Equal("FeatureTracker")}), | ||
), | ||
) | ||
|
||
trackerName := "" | ||
for _, ownerRef := range secret.OwnerReferences { | ||
if ownerRef.Kind == "FeatureTracker" { | ||
trackerName = ownerRef.Name | ||
break | ||
} | ||
} | ||
|
||
tracker := &featurev1.FeatureTracker{} | ||
return envTestClient.Get(context.Background(), client.ObjectKey{ | ||
Name: trackerName, | ||
}, tracker) | ||
} | ||
} |
Oops, something went wrong.