@@ -110,24 +110,49 @@ setup_crossplane() {
110110 echo_info " using crossplane version ${chart_version} "
111111 echo
112112
113+ # Disable the default ManagedResourceActivationPolicy that activates all resources,
114+ # so we can test safe-start with selective activation policies.
113115 " ${HELM} " install crossplane --namespace crossplane-system --create-namespace \
114116 crossplane-channel/crossplane \
115- --version " ${chart_version} " --wait
117+ --version " ${chart_version} " --wait --set ' provider.defaultActivations={} '
116118}
117119
118120setup_provider () {
121+ echo_sub_step " applying ManagedResourceActivationPolicy to disable cluster-wide MSSQL"
122+ " ${KUBECTL} " apply -f " ${projectdir} /examples/activation-policy-no-cluster-mssql.yaml"
123+
119124 echo_step " deploying provider via local.xpkg.deploy"
120125 make -C " ${projectdir} " local.xpkg.deploy.provider.${PACKAGE_NAME} KIND_CLUSTER_NAME=" ${K8S_CLUSTER} "
121126
122127 echo_step " waiting for provider to be installed"
123128 " ${KUBECTL} " wait " provider.pkg.crossplane.io/${PACKAGE_NAME} " --for=condition=healthy --timeout=60s
129+
130+ echo_step " verifying cluster-wide MSSQL CRDs are NOT installed"
131+ if " ${KUBECTL} " get crd databases.mssql.sql.crossplane.io 2> /dev/null; then
132+ echo_error " cluster-wide MSSQL Database CRD should not be installed"
133+ fi
134+ if " ${KUBECTL} " get crd grants.mssql.sql.crossplane.io 2> /dev/null; then
135+ echo_error " cluster-wide MSSQL Grant CRD should not be installed"
136+ fi
137+ if " ${KUBECTL} " get crd users.mssql.sql.crossplane.io 2> /dev/null; then
138+ echo_error " cluster-wide MSSQL User CRD should not be installed"
139+ fi
140+ echo_step_completed
141+
142+ echo_step " verifying namespaced MSSQL CRDs ARE installed"
143+ " ${KUBECTL} " get crd databases.mssql.sql.m.crossplane.io || echo_error " namespaced MSSQL Database CRD should be installed"
144+ " ${KUBECTL} " get crd grants.mssql.sql.m.crossplane.io || echo_error " namespaced MSSQL Grant CRD should be installed"
145+ " ${KUBECTL} " get crd users.mssql.sql.m.crossplane.io || echo_error " namespaced MSSQL User CRD should be installed"
146+ echo_step_completed
124147}
125148
126149cleanup_provider () {
127150 echo_step " uninstalling provider"
128151
129152 " ${KUBECTL} " delete provider.pkg.crossplane.io " ${PACKAGE_NAME} "
130153 " ${KUBECTL} " delete deploymentruntimeconfig.pkg.crossplane.io runtimeconfig-${PACKAGE_NAME}
154+ " ${KUBECTL} " delete managedresourceactivationpolicy.apiextensions.crossplane.io disable-cluster-mssql --ignore-not-found=true
155+ " ${KUBECTL} " delete managedresourceactivationpolicy.apiextensions.crossplane.io enable-cluster-mssql --ignore-not-found=true
131156
132157 echo_step " waiting for provider pods to be deleted"
133158 timeout=60
@@ -458,6 +483,33 @@ TLS=false API_TYPE="cluster" run_test integration_tests_postgres
458483TLS=false API_TYPE=" namespaced" run_test integration_tests_postgres
459484
460485# no TLS=false variant - MSSQL uses built-in encryption
486+ # Enable cluster-wide MSSQL CRDs before running cluster MSSQL tests.
487+ # The initial activation policy excludes them to test safe-start.
488+ echo_step " creating activation policy to enable cluster-wide MSSQL"
489+ " ${KUBECTL} " apply -f - << EOF
490+ apiVersion: apiextensions.crossplane.io/v1alpha1
491+ kind: ManagedResourceActivationPolicy
492+ metadata:
493+ name: enable-cluster-mssql
494+ spec:
495+ activate:
496+ - "*.mssql.sql.crossplane.io"
497+ EOF
498+
499+ echo_step " waiting for cluster-wide MSSQL CRDs to be installed"
500+ timeout=60
501+ current=0
502+ step=3
503+ while ! " ${KUBECTL} " get crd databases.mssql.sql.crossplane.io 2> /dev/null; do
504+ echo " waiting another $step seconds for MSSQL CRDs..."
505+ current=$(( current + step))
506+ if [[ $current -ge $timeout ]]; then
507+ echo_error " timeout of ${timeout} s waiting for MSSQL CRDs"
508+ fi
509+ sleep $step
510+ done
511+ echo_step_completed
512+
461513TLS=true API_TYPE=" cluster" run_test integration_tests_mssql
462514TLS=true API_TYPE=" namespaced" run_test integration_tests_mssql
463515
0 commit comments