Skip to content

Commit

Permalink
RHIDP-1682 [Test automation] re-enable the skipped e2e tests (#1235)
Browse files Browse the repository at this point in the history
Signed-off-by: Gustavo Lira <guga.java@gmail.com>
  • Loading branch information
gustavolira committed May 8, 2024
1 parent f996bf6 commit 66103a2
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 39 deletions.
7 changes: 7 additions & 0 deletions .ibm/pipelines/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Installation Instructions for Tests

For tests dependent on `janus-idp-backstage-plugin-ocm-backend-dynamic` and `janus-idp-backstage-plugin-ocm`, it's necessary to install **Advanced Cluster Management for Kubernetes "MultiClusterHub"**.

Please follow these steps for installation:

1. Visit [Installing Advanced Cluster Management for Kubernetes "MultiClusterHub"](https://access.redhat.com/documentation/en-us/red_hat_advanced_cluster_management_for_kubernetes/2.10/html/install/installing#installing-from-the-operatorhub) for detailed instructions on installing from the OperatorHub.
2 changes: 1 addition & 1 deletion .ibm/pipelines/auth/secrets-rhdh-secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data:
GITHUB_ORG: amFudXMtcWU=
K8S_CLUSTER_NAME: bXktY2x1c3Rlcgo=
K8S_CLUSTER_API_SERVER_URL: aHR0cHM6Ly9jMTAwLWUudXMtZWFzdC5jb250YWluZXJzLmNsb3VkLmlibS5jb206MzIyMTIK
K8S_SERVICE_ACCOUNT_TOKEN: dGVtcA==
K8S_CLUSTER_TOKEN_ENCODED: dGVtcA==
OCM_CLUSTER_URL: aHR0cHM6Ly9jMTAwLWUudXMtZWFzdC5jb250YWluZXJzLmNsb3VkLmlibS5jb206MzIyMTI=
OCM_CLUSTER_TOKEN: dGVtcA==
KEYCLOAK_BASE_URL: aHR0cHM6Ly9rZXljbG9hay1rZXljbG9hay5yaGRoLXByLW9zLWE5ODA1NjUwODMwYjIyYzNhZWUyNDNlNTFkNzk1NjVkLTAwMDAudXMtZWFzdC5jb250YWluZXJzLmFwcGRvbWFpbi5jbG91ZA==
Expand Down
1 change: 1 addition & 0 deletions .ibm/pipelines/env_variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ HELM_REPO_NAME=rhdh-chart
HELM_REPO_URL="https://redhat-developer.github.io/rhdh-chart"
K8S_CLUSTER_ROUTER_BASE="rhdh-pr-os-a9805650830b22c3aee243e51d79565d-0000.us-east.containers.appdomain.cloud"
K8S_CLUSTER_TOKEN=$(cat /tmp/secrets/K8S_CLUSTER_TOKEN)
K8S_CLUSTER_TOKEN_ENCODED=$(cat /tmp/secrets/K8S_CLUSTER_TOKEN_ENCODED)
K8S_CLUSTER_URL=https://c100-e.us-east.containers.cloud.ibm.com:32212
OPENSHIFT_CLUSTER_ID=cobct3kw0lbiltuijvmg

Expand Down
41 changes: 18 additions & 23 deletions .ibm/pipelines/openshift-ci-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -e
LOGFILE="test-log"
JUNIT_RESULTS="junit-results.xml"
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
secret_name="rhdh-k8s-plugin-secret"

cleanup() {
echo "Cleaning up before exiting"
Expand Down Expand Up @@ -82,21 +83,24 @@ configure_namespace() {
local project=$1
if oc get namespace ${project} >/dev/null 2>&1; then
echo "Namespace ${project} already exists! refreshing namespace"
oc delete namespace ${project}
oc delete namespace "${project}"
fi
oc create namespace ${project}
oc config set-context --current --namespace=${project}
oc create namespace "${project}"
oc config set-context --current --namespace="${project}"
}

apply_yaml_files() {
local dir=$1
local project=$2
echo "NAME SPACE ${project}"
#ensure that we are in the right namespace
oc config set-context --current --namespace="${project}"

# Update namespace and other configurations in YAML files
local files=("$dir/resources/service_account/service-account-rhdh.yaml"
"$dir/resources/cluster_role_binding/cluster-role-binding-k8s.yaml"
"$dir/resources/cluster_role_binding/cluster-role-binding-ocm.yaml"
"$dir/resources/cluster_role/cluster-role-k8s.yaml"
"$dir/resources/cluster_role/cluster-role-ocm.yaml"
"$dir/resources/deployment/deployment-test-app-component.yaml"
"$dir/auth/secrets-rhdh-secrets.yaml")

Expand All @@ -106,7 +110,7 @@ apply_yaml_files() {

sed -i "s/backstage.io\/kubernetes-id:.*/backstage.io\/kubernetes-id: $K8S_PLUGIN_ANNOTATION/g" "$dir/resources/deployment/deployment-test-app-component.yaml"

for key in GITHUB_APP_APP_ID GITHUB_APP_CLIENT_ID GITHUB_APP_PRIVATE_KEY GITHUB_APP_CLIENT_SECRET GITHUB_APP_WEBHOOK_URL GITHUB_APP_WEBHOOK_SECRET KEYCLOAK_CLIENT_SECRET OCM_CLUSTER_TOKEN ACR_SECRET GOOGLE_CLIENT_ID GOOGLE_CLIENT_SECRET; do
for key in GITHUB_APP_APP_ID GITHUB_APP_CLIENT_ID GITHUB_APP_PRIVATE_KEY GITHUB_APP_CLIENT_SECRET GITHUB_APP_WEBHOOK_URL GITHUB_APP_WEBHOOK_SECRET KEYCLOAK_CLIENT_SECRET ACR_SECRET GOOGLE_CLIENT_ID GOOGLE_CLIENT_SECRET K8S_CLUSTER_TOKEN_ENCODED; do
sed -i "s|$key:.*|$key: ${!key}|g" "$dir/auth/secrets-rhdh-secrets.yaml"
done

Expand All @@ -116,22 +120,17 @@ apply_yaml_files() {
oc apply -f $dir/resources/deployment/deployment-test-app-component.yaml --namespace=${project}
oc new-app https://github.com/janus-qe/test-backstage-customization-provider --namespace=${project}
oc expose svc/test-backstage-customization-provider --namespace=${project}
oc apply -f $dir/resources/cluster_role/cluster-role-k8s.yaml
oc apply -f $dir/resources/cluster_role_binding/cluster-role-binding-k8s.yaml
oc apply -f $dir/resources/cluster_role/cluster-role-ocm.yaml
oc apply -f $dir/resources/cluster_role_binding/cluster-role-binding-ocm.yaml
oc apply -f $dir/resources/cluster_role/cluster-role-k8s.yaml --namespace=${project}
oc apply -f $dir/resources/cluster_role_binding/cluster-role-binding-k8s.yaml --namespace=${project}
oc apply -f $dir/resources/cluster_role/cluster-role-ocm.yaml --namespace=${project}
oc apply -f $dir/resources/cluster_role_binding/cluster-role-binding-ocm.yaml --namespace=${project}

# obtain K8S_SERVICE_ACCOUNT_TOKEN, K8S_CLUSTER_NAME, K8S_CLUSTER_API_SERVER_URL and add them to secrets-rhdh-secrets.yaml
oc get secret rhdh-k8s-plugin-secret -o yaml >$dir/auth/service-account-rhdh-token.yaml

TOKEN=$(grep 'token:' $dir/auth/service-account-rhdh-token.yaml | awk '{print $2}')

sed -i "s/K8S_SERVICE_ACCOUNT_TOKEN:.*/K8S_SERVICE_ACCOUNT_TOKEN: $TOKEN/g" $dir/auth/secrets-rhdh-secrets.yaml
sed -i "s/K8S_CLUSTER_API_SERVER_URL:.*/K8S_CLUSTER_API_SERVER_URL: $ENCODED_API_SERVER_URL/g" $dir/auth/secrets-rhdh-secrets.yaml
sed -i "s/K8S_CLUSTER_NAME:.*/K8S_CLUSTER_NAME: $ENCODED_CLUSTER_NAME/g" $dir/auth/secrets-rhdh-secrets.yaml

# Cleanup temp file
rm $dir/auth/service-account-rhdh-token.yaml
token=$(oc get secret $secret_name -n "$project" -o=jsonpath='{.data.token}')
sed -i "s/OCM_CLUSTER_TOKEN: .*/OCM_CLUSTER_TOKEN: $token/" "$dir"/auth/secrets-rhdh-secrets.yaml


if [[ "${project}" == "showcase-rbac" || "${project}" == "showcase-rbac-nightly" ]]; then
oc apply -f $dir/resources/config_map/configmap-app-config-rhdh-rbac.yaml --namespace=${project}
Expand Down Expand Up @@ -184,7 +183,7 @@ curl -fsSLk -o /tmp/droute-linux-amd64 "https://nexus.hosts.prod.upshift.rdu2.re
&& chmod +x /tmp/droute-linux-amd64
EOF
)"

oc exec -n ${droute_project} "$droute_pod_name" -- /bin/bash -c "$(cat <<EOF
/tmp/droute-linux-amd64 send --metadata /tmp/droute/${METEDATA_OUTPUT} \
--url "$DATA_ROUTER_URL" \
Expand Down Expand Up @@ -225,7 +224,6 @@ run_tests() {
ansi2html <"/tmp/${LOGFILE}" >"/tmp/${LOGFILE}.html"
cp -a "/tmp/${LOGFILE}.html" ${ARTIFACT_DIR}/${project}
cp -a /tmp/backstage-showcase/e2e-tests/playwright-report/* ${ARTIFACT_DIR}/${project}


droute_send $release_name $project

Expand Down Expand Up @@ -314,7 +312,7 @@ check_and_test() {
main() {
echo "Log file: ${LOGFILE}"
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source ./.ibm/pipelines/env_variables.sh
source "${DIR}/env_variables.sh"
# Update the namespace for nightly job.
if [ "$JOB_TYPE" != "presubmit" ]; then
NAME_SPACE="showcase-ci-nightly"
Expand All @@ -323,9 +321,6 @@ main() {

echo "OPENSHIFT_CLUSTER_ID : $OPENSHIFT_CLUSTER_ID"

install_ibmcloud
ibmcloud version
ibmcloud config --check-version=false
install_oc
oc version --client
oc login --token=${K8S_CLUSTER_TOKEN} --server=${K8S_CLUSTER_URL}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ rules:
- get
- watch
- list
- create
- apiGroups:
- internal.open-cluster-management.io
resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ roleRef:
kind: ClusterRole
name: rhdh-k8s-plugin-ocm
subjects:
- kind: ServiceAccount
name: rhdh-k8s-plugin
namespace: showcase
- kind: ServiceAccount
name: rhdh-k8s-plugin
namespace: showcase
- kind: ServiceAccount
name: rhdh-k8s-plugin
namespace: showcase-rbac
- kind: ServiceAccount
name: rhdh-k8s-plugin
namespace: showcase-rbac
- kind: ServiceAccount
name: rhdh-k8s-plugin
namespace: showcase-ci-nightly

6 changes: 1 addition & 5 deletions .ibm/pipelines/value_files/values_showcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ global:
- clusters:
- authProvider: serviceAccount
name: 'my-cluster'
serviceAccountToken: ${K8S_SERVICE_ACCOUNT_TOKEN}
serviceAccountToken: ${K8S_CLUSTER_TOKEN_ENCODED}
url: ${K8S_CLUSTER_API_SERVER_URL}
type: config
customResources:
Expand All @@ -70,10 +70,6 @@ global:
- apiVersion: 'v1'
group: 'route.openshift.io'
plural: 'routes'
# Add to view topology code decorators
- group: 'org.eclipse.che'
apiVersion: 'v2'
plural: 'checlusters'
serviceLocatorMethod:
type: multiTenant
# Enable OCM plugins.
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/playwright/e2e/plugins/acr.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { UIhelper } from '../../utils/UIhelper';
import { Common, setupBrowser } from '../../utils/Common';

let page;
test.describe.skip('Test ACR plugin', () => {
test.describe('Test ACR plugin', () => {
let uiHelper: UIhelper;
let common: Common;
const dateRegex =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { UIhelper } from '../../../utils/UIhelper';
import { Common } from '../../../utils/Common';
import { test, expect } from '@playwright/test';

test.describe.skip('Test Keycloak plugin', () => {
test.describe('Test Keycloak plugin', () => {
let uiHelper: UIhelper;
let keycloak: Keycloak;
let common: Common;
Expand Down
10 changes: 6 additions & 4 deletions e2e-tests/playwright/e2e/plugins/ocm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import { UIhelper } from '../../utils/UIhelper';
import { Clusters } from '../../support/pages/Clusters';

//Pre-req: Enable janus-idp-backstage-plugin-ocm-backend-dynamic and janus-idp-backstage-plugin-ocm Plugins
//Pre-req: Install Advanced Cluster Management for Kubernetes "MultiClusterHub"
// https://access.redhat.com/documentation/en-us/red_hat_advanced_cluster_management_for_kubernetes/2.10/html/install/installing#installing-from-the-operatorhub

const clusterDetails = {
clusterName: 'testCluster',
status: 'Ready',
platform: 'IBM',
cpuCores: '16',
memorySize: '63 Gi',
cpuCores: '24',
memorySize: '94 Gi',
ocVersion: /^\d+\.\d+\.\d+$/,
};
let page: Page;
Expand All @@ -28,7 +30,7 @@ test.describe.serial('Test OCM plugin', () => {

await common.loginAsGithubUser();
});
test.skip('Navigate to Clusters and Verify OCM Clusters', async () => {
test('Navigate to Clusters and Verify OCM Clusters', async () => {
await uiHelper.openSidebar('Clusters');
await uiHelper.verifyRowInTableByUniqueText(clusterDetails.clusterName, [
clusterDetails.status,
Expand All @@ -50,7 +52,7 @@ test.describe.serial('Test OCM plugin', () => {
);
});

test.skip('Navigate to Catalog > resources and verify cluster', async () => {
test('Navigate to Catalog > resources and verify cluster', async () => {
await uiHelper.openSidebar('Catalog');
await common.waitForLoad();
await uiHelper.selectMuiBox('Kind', 'Resource');
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/playwright/e2e/plugins/tekton/tekton.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Tekton } from '../../../utils/tekton/tekton';
// Pre-req: A kubernetes cluster containing pipeline and pipelinerun resources labeled with backstage.io/kubernetes-id: developer-hub
// Pre-req: A catalog entity with the matching backstage.io/kubernetes-id: developer-hub annotation as well as the janus-idp.io/tekton : <BACKSTAGE_ENTITY_NAME> annotation

test.describe.skip('Test Tekton plugin', () => {
test.describe('Test Tekton plugin', () => {
let common: Common;
let uiHelper: UIhelper;
let tekton: Tekton;
Expand Down

0 comments on commit 66103a2

Please sign in to comment.