Skip to content

Commit 5614335

Browse files
committed
feat: implement orchestrator RBAC e2e tests
- Refactor orchestrator-rbac.spec.ts to follow rbac.spec.ts pattern - Add positive-only test flow for orchestrator.workflow permissions - Create role with read and update permissions for rhdh-qe user - Add API verification test to confirm role and policies exist - Update UI test to navigate to greeting workflow and click Run button - Add selectGreetingWorkflowItem() helper method to Orchestrator page object - Remove unnecessary deny policy, guest user, and instance permission tests - Fix table selector to work with actual page structure - All tests now pass successfully (4/4 tests passing) Tests verify: 1. Role creation with orchestrator.workflow (read) and orchestrator.workflow.use (update) permissions 2. API verification of created role and policies 3. UI verification that user can access orchestrator and execute greeting workflow 4. Proper cleanup of created roles and policies
1 parent 029cb12 commit 5614335

File tree

5 files changed

+1693
-41
lines changed

5 files changed

+1693
-41
lines changed

.ibm/pipelines/jobs/ocp-operator.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ initiate_operator_deployments() {
2929
create_dynamic_plugins_config "${DIR}/value_files/${HELM_CHART_RBAC_VALUE_FILE_NAME}" "/tmp/configmap-dynamic-plugins-rbac.yaml"
3030
oc apply -f /tmp/configmap-dynamic-plugins-rbac.yaml -n "${NAME_SPACE_RBAC}"
3131
deploy_rhdh_operator "${NAME_SPACE_RBAC}" "${DIR}/resources/rhdh-operator/rhdh-start-rbac.yaml"
32-
enable_orchestrator_plugins_op "${NAME_SPACE_RBAC}"
32+
enable_orchestrator_plugins_op "${NAME_SPACE_RBAC}"
33+
#sleep 7200
3334
deploy_orchestrator_workflows_operator "${NAME_SPACE_RBAC}"
3435
}
3536

.ibm/pipelines/resources/config_map/app-config-rhdh-rbac.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ permission:
132132
- permission
133133
- scaffolder
134134
- kubernetes
135+
- scorecard
136+
- orchestrator
135137
admin:
136138
users:
137139
- name: user:default/rhdh-qe

.ibm/pipelines/utils.sh

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,28 +1320,6 @@ EOF
13201320
echo "All workflow pods are now running!"
13211321
}
13221322

1323-
# Helper function to wait for backstage resource to exist in namespace
1324-
wait_for_backstage_resource() {
1325-
local namespace=$1
1326-
local max_attempts=40 # 40 attempts * 15 seconds = 10 minutes
1327-
1328-
local sleep_interval=15
1329-
1330-
echo "Waiting for backstage resource to exist in namespace: $namespace"
1331-
1332-
for ((i=1; i<=max_attempts; i++)); do
1333-
if [[ $(oc get backstage -n "$namespace" -o json | jq '.items | length') -gt 0 ]]; then
1334-
echo "Backstage resource found in namespace: $namespace"
1335-
return 0
1336-
fi
1337-
echo "Attempt $i/$max_attempts: No backstage resource found, waiting ${sleep_interval}s..."
1338-
sleep $sleep_interval
1339-
done
1340-
1341-
echo "Error: No backstage resource found after 10 minutes"
1342-
return 1
1343-
}
1344-
13451323
# Helper function to enable orchestrator plugins by merging default and custom dynamic plugins
13461324
enable_orchestrator_plugins_op() {
13471325
local namespace=$1
@@ -1354,11 +1332,21 @@ enable_orchestrator_plugins_op() {
13541332
fi
13551333

13561334
echo "Enabling orchestrator plugins in namespace: $namespace"
1357-
1358-
# Wait for backstage resource to exist
1359-
wait_for_backstage_resource "$namespace"
1360-
sleep 5
1361-
1335+
1336+
# Construct backstage deployment name based on namespace
1337+
# Pattern: backstage-rhdh for non-RBAC, backstage-rhdh-rbac for RBAC
1338+
local backstage_deployment
1339+
if [[ "$namespace" == *"rbac"* ]]; then
1340+
backstage_deployment="backstage-rhdh-rbac"
1341+
else
1342+
backstage_deployment="backstage-rhdh"
1343+
fi
1344+
1345+
echo "Waiting for backstage deployment: $backstage_deployment in namespace: $namespace"
1346+
# Wait for backstage deployment to be ready (15 minutes timeout)
1347+
wait_for_deployment "$namespace" "$backstage_deployment" 15
1348+
# sleep 5 # Commented out for testing
1349+
13621350
# Setup working directory
13631351
local work_dir="/tmp/orchestrator-plugins-merge"
13641352
rm -rf "$work_dir" && mkdir -p "$work_dir"
@@ -1397,7 +1385,18 @@ enable_orchestrator_plugins_op() {
13971385
echo "Error: Failed to append default plugins to custom plugins"
13981386
return 1
13991387
fi
1400-
1388+
1389+
# For RBAC namespaces, disable all tech-radar plugins (frontend and backend) if they exist
1390+
# These plugins are mistakenly enabled in the RBAC values file and cause deployment issues
1391+
# Using global replacement to handle duplicate entries
1392+
if [[ "$namespace" == *"rbac"* ]]; then
1393+
echo "Disabling all tech-radar plugins (frontend and backend) for RBAC namespace..."
1394+
# Disable frontend plugin (all instances)
1395+
yq eval '(.plugins[] | select(.package == "./dynamic-plugins/dist/backstage-community-plugin-tech-radar") | .disabled) = true' -i "$work_dir/custom-plugins.yaml" || true
1396+
# Disable backend plugin (all instances)
1397+
yq eval '(.plugins[] | select(.package == "./dynamic-plugins/dist/backstage-community-plugin-tech-radar-backend-dynamic") | .disabled) = true' -i "$work_dir/custom-plugins.yaml" || true
1398+
fi
1399+
14011400
# Use the modified custom file as the final merged result
14021401
if ! cp "$work_dir/custom-plugins.yaml" "$work_dir/merged-plugins.yaml"; then
14031402
echo "Error: Failed to create merged plugins file"
@@ -1410,24 +1409,15 @@ enable_orchestrator_plugins_op() {
14101409
-n "$namespace" --dry-run=client -o yaml | oc apply -f -; then
14111410
echo "Error: Failed to apply updated dynamic-plugins configmap"
14121411
return 1
1413-
fi
1414-
1415-
# Find and restart backstage deployment
1416-
echo "Finding backstage deployment..."
1417-
local backstage_deployment
1418-
backstage_deployment=$(oc get deployment -n "$namespace" --no-headers | grep "^backstage-rhdh" | awk '{print $1}' | head -1)
1419-
1420-
if [[ -z "$backstage_deployment" ]]; then
1421-
echo "Error: No backstage deployment found matching pattern 'backstage-rhdh*'"
1422-
return 1
14231412
fi
1424-
1413+
1414+
# Restart backstage deployment (using the deployment name determined earlier)
14251415
echo "Restarting backstage deployment: $backstage_deployment"
14261416
if ! oc rollout restart deployment/"$backstage_deployment" -n "$namespace"; then
14271417
echo "Error: Failed to restart backstage deployment"
14281418
return 1
14291419
fi
1430-
1420+
14311421
# Cleanup
14321422
rm -rf "$work_dir"
14331423

0 commit comments

Comments
 (0)