Skip to content

Commit

Permalink
MGMT-19258: Identify and copy shared code
Browse files Browse the repository at this point in the history
MGMT-19258: Copied context sensitive funcs into a context

MGMT-19258: Ensure that all context sensitive code is in test context
  • Loading branch information
paul-maidment committed Jan 1, 2025
1 parent 6c35570 commit 01a8a88
Show file tree
Hide file tree
Showing 21 changed files with 3,301 additions and 1,819 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,10 @@ deploy-dev-infra: create-hub-cluster
########

test:
$(MAKE) _run_subsystem_test AUTH_TYPE=rhsso ENABLE_ORG_TENANCY=true ENABLE_ORG_BASED_FEATURE_GATES=true
$(MAKE) _run_subsystem_test AUTH_TYPE=rhsso ENABLE_ORG_TENANCY=true ENABLE_ORG_BASED_FEATURE_GATES=true TEST="$(or $(TEST),'github.com/openshift/assisted-service/subsystem')"

test-kube-api:
$(MAKE) _run_subsystem_test AUTH_TYPE=local FOCUS="$(or ${FOCUS},kube-api)"
$(MAKE) _run_subsystem_test AUTH_TYPE=local TEST="$(or $(TEST),'github.com/openshift/assisted-service/subsystem/kubeapi')"

# Alias for test
subsystem-test: test
Expand Down Expand Up @@ -490,7 +490,7 @@ _run_subsystem_test:
TEST_TOKEN_UNALLOWED="$(shell cat $(BUILD_FOLDER)/auth-tokenUnallowedString)" \
TEST_TOKEN_EDITOR="$(shell cat $(BUILD_FOLDER)/auth-tokenClusterEditor)" \
RELEASE_SOURCES='$(or ${RELEASE_SOURCES},${DEFAULT_RELEASE_SOURCES})' \
$(MAKE) _test TEST_SCENARIO=subsystem TIMEOUT=120m TEST="$(or $(TEST),./subsystem/...)"
$(MAKE) _test TEST_SCENARIO=subsystem TIMEOUT=120m

enable-kube-api-for-subsystem: $(BUILD_FOLDER)
$(MAKE) deploy-service-requirements AUTH_TYPE=local ENABLE_KUBE_API=true ALLOW_CONVERGED_FLOW=true ISO_IMAGE_TYPE=minimal-iso
Expand Down
66 changes: 66 additions & 0 deletions api/config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
name: validating-webhook-configuration
webhooks:
- admissionReviewVersions:
- v1
clientConfig:
service:
name: webhook-service
namespace: system
path: /validate-agent-install-openshift-io-v1beta1-agent
failurePolicy: Fail
name: vagent.kb.io
rules:
- apiGroups:
- agent-install.openshift.io
apiVersions:
- v1beta1
operations:
- CREATE
- UPDATE
resources:
- agents
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
service:
name: webhook-service
namespace: system
path: /validate-agent-install-openshift-io-v1beta1-agentclassification
failurePolicy: Fail
name: vagentclassification.kb.io
rules:
- apiGroups:
- agent-install.openshift.io
apiVersions:
- v1beta1
operations:
- CREATE
- UPDATE
resources:
- agentclassifications
sideEffects: None
- admissionReviewVersions:
- v1
clientConfig:
service:
name: webhook-service
namespace: system
path: /validate-agent-install-openshift-io-v1beta1-infraenv
failurePolicy: Fail
name: vinfraenv.kb.io
rules:
- apiGroups:
- agent-install.openshift.io
apiVersions:
- v1beta1
operations:
- CREATE
- UPDATE
resources:
- infraenvs
sideEffects: None
13 changes: 7 additions & 6 deletions subsystem/ams_subscriptions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/openshift/assisted-service/pkg/auth"
"github.com/openshift/assisted-service/pkg/ocm"
"k8s.io/apimachinery/pkg/util/wait"
"github.com/openshift/assisted-service/subsystem/shared"
)

var _ = Describe("test AMS subscriptions", func() {
Expand Down Expand Up @@ -46,7 +47,7 @@ var _ = Describe("test AMS subscriptions", func() {
clusterID, err := registerCluster(ctx, userBMClient, "test-cluster", pullSecret)
Expect(err).ToNot(HaveOccurred())
log.Infof("Register cluster %s", clusterID)
cc := getCommonCluster(ctx, clusterID)
cc := shared.TestContext.GetCommonCluster(ctx, clusterID)
Expect(cc.AmsSubscriptionID).To(Equal(FakeSubscriptionID))
})

Expand Down Expand Up @@ -263,7 +264,7 @@ var _ = Describe("test AMS subscriptions", func() {
waitForConsoleUrlUpdateInAMS := func(clusterID strfmt.UUID) {

waitFunc := func(ctx context.Context) (bool, error) {
c := getCommonCluster(ctx, clusterID)
c := shared.TestContext.GetCommonCluster(ctx, clusterID)
return c.IsAmsSubscriptionConsoleUrlSet, nil
}
err := wait.PollUntilContextTimeout(ctx, pollDefaultInterval, pollDefaultTimeout, false, waitFunc)
Expand All @@ -288,9 +289,9 @@ var _ = Describe("test AMS subscriptions", func() {
})

By("update subscription with console url", func() {
c := getCluster(clusterID)
c := shared.TestContext.GetCluster(clusterID)
for _, host := range c.Hosts {
updateProgress(*host.ID, host.InfraEnvID, models.HostStageDone)
shared.TestContext.UpdateProgress(*host.ID, host.InfraEnvID, models.HostStageDone)
}
waitForClusterState(ctx, clusterID, models.ClusterStatusFinalizing, defaultWaitForClusterStateTimeout, clusterFinalizingStateInfo)
completeInstallation(agentBMClient, clusterID)
Expand Down Expand Up @@ -327,8 +328,8 @@ var _ = Describe("test AMS subscriptions", func() {
Expect(err).NotTo(HaveOccurred())
c := reply.GetPayload()
Expect(*c.Status).Should(Equal(models.ClusterStatusPreparingForInstallation))
generateEssentialPrepareForInstallationSteps(ctx, c.Hosts...)
waitForLastInstallationCompletionStatus(clusterID, models.LastInstallationPreparationStatusFailed)
shared.TestContext.GenerateEssentialPrepareForInstallationSteps(ctx, c.Hosts...)
shared.TestContext.WaitForLastInstallationCompletionStatus(clusterID, models.LastInstallationPreparationStatusFailed)
})
})
})
Expand Down
Loading

0 comments on commit 01a8a88

Please sign in to comment.