-
Notifications
You must be signed in to change notification settings - Fork 211
feat(sonarqube): add sonarqube e2e test #3192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
AndrienkoAleksandr
wants to merge
17
commits into
redhat-developer:main
from
AndrienkoAleksandr:sonarqube-e2e
Closed
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
7b836b0
test(e2e): add sonarqube plugin test
AndrienkoAleksandr 87cafcd
fix(e2e): continue work on sonarqube test
AndrienkoAleksandr f4883d6
feat(e2e): try to enable installation sonarqube
AndrienkoAleksandr 37685e3
feat(e2e): evaluate sonarkube url
AndrienkoAleksandr 9b20bdc
feat(e2e): fix installation script
AndrienkoAleksandr c2221ed
feat(e2e): remove sonarkube test from skip list
AndrienkoAleksandr 4e820cf
feat(e2e): try to fix test failing
AndrienkoAleksandr e0cffcd
feat(e2e): try with timeout
AndrienkoAleksandr d7deff9
feat(e2e): add more time for processing entity
AndrienkoAleksandr 842bd3c
feat(e2e): enable sonarqube-scaffolder-module
AndrienkoAleksandr 01d2ff5
temp
AndrienkoAleksandr f4c2b7a
feat(e2e): work with sonarqube helm
AndrienkoAleksandr 9b50c37
fix(e2e): work on code review feedback
AndrienkoAleksandr 2b6f515
feat(e2e): handle code review feedback
AndrienkoAleksandr f93777d
feat(e2e): handle code review feedback
AndrienkoAleksandr 9fdd6e5
feat(e2e): add sonarqube script's installation README file
AndrienkoAleksandr 35414af
feat(e2e): work on code review feedback
AndrienkoAleksandr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,43 @@ | ||
| # SonarQube Installation Script | ||
|
|
||
| This script installs a SonarQube instance in an OpenShift cluster using the official SonarQube Helm chart. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - `kubectl` or `oc` CLI installed and configured to connect to your OpenShift cluster. | ||
| - `helm` CLI installed. | ||
|
|
||
| ## Usage | ||
|
|
||
| The `install.sh` script supports the following parameters: | ||
|
|
||
| - `--namespace`: The namespace where SonarQube will be installed. (Default: `sonarqube`) | ||
| - `--values`: Path to a custom values file for Helm chart customization. (Default: `values.yaml` in the same directory) | ||
| - `--edition`: The SonarQube edition to install. (Default: `developer`) | ||
| - `--host`: The hostname for the OpenShift route. This is a mandatory parameter. | ||
|
|
||
| ### Example | ||
|
|
||
| ```shell | ||
| ./install.sh --host sonar.<your-cluster-domain> | ||
| ``` | ||
|
|
||
| ### Example with custom namespace | ||
|
|
||
| ```shell | ||
| ./install.sh --namespace my-sonarqube --host sonar.<your-cluster-domain> | ||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| The script uses a `values.yaml` file to configure the SonarQube Helm chart. You can modify this file to customize your SonarQube installation. For example, you can configure resource limits, persistence, and other chart values. | ||
|
|
||
| ### External PostgreSQL | ||
|
|
||
| By default, the script installs a PostgreSQL database as part of the Helm release. To use an external PostgreSQL database, you can uncomment the following line in the `install.sh` script: | ||
|
|
||
| ```shell | ||
| # HELM_ARGS="${HELM_ARGS} --set postgresql.enabled=false" | ||
| ``` | ||
|
|
||
| You will also need to provide the connection details for your external database in the `values.yaml` file. |
This file contains hidden or 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,46 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Defaults | ||
| NAMESPACE="sonarqube" | ||
| VALUES_FILE="$(dirname "$0")/values.yaml" | ||
| EDITION="developer" | ||
| HOST="" | ||
|
|
||
| # Parse arguments | ||
| while [[ "$#" -gt 0 ]]; do | ||
| case $1 in | ||
| --namespace) NAMESPACE="$2"; shift ;; | ||
| --values) VALUES_FILE="$2"; shift ;; | ||
| --edition) EDITION="$2"; shift ;; | ||
| --host) HOST="$2"; shift ;; | ||
| *) echo "Unknown parameter passed: $1"; exit 1 ;; | ||
| esac | ||
| shift | ||
| done | ||
|
|
||
| # Create namespace if it doesn't exist | ||
| kubectl get namespace "$NAMESPACE" > /dev/null || kubectl create namespace "$NAMESPACE" | ||
|
|
||
| helm repo add sonarqube https://SonarSource.github.io/helm-chart-sonarqube --force-update | ||
| helm repo update | ||
|
|
||
| HELM_ARGS="--install -n ${NAMESPACE} sonarqube sonarqube/sonarqube" | ||
| HELM_ARGS="${HELM_ARGS} --set edition=${EDITION}" | ||
|
|
||
| if [ -f "${VALUES_FILE}" ]; then | ||
| HELM_ARGS="${HELM_ARGS} -f ${VALUES_FILE}" | ||
| else | ||
| echo "Warning: Values file not found at ${VALUES_FILE}" | ||
| fi | ||
|
|
||
| if [ -n "${HOST}" ]; then | ||
| HELM_ARGS="${HELM_ARGS} --set OpenShift.route.host=${HOST}" | ||
| fi | ||
|
|
||
| HELM_ARGS="${HELM_ARGS} --set postgresql.image.repository=bitnami/postgresql" | ||
| HELM_ARGS="${HELM_ARGS} --set postgresql.image.tag=15.3.0" | ||
| # To use an external PostgreSQL, uncomment the following line | ||
| # HELM_ARGS="${HELM_ARGS} --set postgresql.enabled=false" | ||
|
|
||
| # shellcheck disable=SC2086 | ||
| helm upgrade ${HELM_ARGS} |
This file contains hidden or 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,26 @@ | ||
| account: | ||
| adminPassword: NewAdminPassword1@ | ||
| currentAdminPassword: admin | ||
|
|
||
| OpenShift: | ||
| enabled: true | ||
| serviceAccount: | ||
| create: true | ||
| route: | ||
| enabled: true | ||
| host: "sonarqube.<openshift-cluster-domain>" | ||
| path: "/" | ||
| tls: | ||
| termination: edge | ||
| insecureEdgeTerminationPolicy: Redirect | ||
|
|
||
| monitoringPasscode: "define_it" | ||
|
|
||
| postgresql: | ||
| image: | ||
| repository: bitnami/postgresql | ||
| tag: 15.3.0 | ||
| securityContext: | ||
| enabled: false | ||
| containerSecurityContext: | ||
| enabled: false |
This file contains hidden or 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 hidden or 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
65 changes: 65 additions & 0 deletions
65
e2e-tests/playwright/e2e/plugins/sonarkube/sonarkube-actions.spec.ts
This file contains hidden or 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,65 @@ | ||
| import { test } from "@playwright/test"; | ||
| import { Common, setupBrowser } from "../../../utils/common"; | ||
| import { UIhelper } from "../../../utils/ui-helper"; | ||
| import { CatalogImport } from "../../../support/pages/catalog-import"; | ||
|
|
||
| test.describe("Test SonarKube Actions plugin", () => { | ||
| let common: Common; | ||
| let uiHelper: UIhelper; | ||
| let catalogImport: CatalogImport; | ||
| let project: string; | ||
| let projectKey: string; | ||
|
|
||
| const template = | ||
| "https://github.com/backstage/community-plugins/blob/main/workspaces/scaffolder-backend-module-sonarqube/plugins/scaffolder-backend-module-sonarqube/examples/templates/01-sonar-template.yaml"; | ||
|
|
||
| test.beforeEach(async ({ browser, page }, testInfo) => { | ||
| page = (await setupBrowser(browser, testInfo)).page; | ||
| common = new Common(page); | ||
| uiHelper = new UIhelper(page); | ||
| catalogImport = new CatalogImport(page); | ||
|
|
||
| await common.loginAsGuest(); | ||
| await page.goto("/create"); | ||
| }); | ||
|
|
||
| test("Creates Sonarkube project", async () => { | ||
| await uiHelper.clickButton("Import an existing Git repository"); | ||
| await catalogImport.registerExistingComponent(template, false); | ||
|
|
||
| await uiHelper.clickLink({ ariaLabel: "Self-service" }); | ||
| await common.waitForLoad(); | ||
| await uiHelper.waitForTitle("Self-service"); | ||
| await uiHelper.searchInputPlaceholder("Create a SonarQube project"); | ||
| await uiHelper.verifyText("Create a SonarQube project"); | ||
|
|
||
| project = `test-sonarqube-actions-${Date.now()}`; | ||
| projectKey = `any-key-${Date.now()}`; | ||
|
|
||
| await uiHelper.clickBtnInCard("Create a SonarQube project", "Choose"); | ||
|
|
||
| await uiHelper.waitForTitle("Create a SonarQube project", 2); | ||
|
|
||
| const baseRHDHURL: string = process.env.BASE_URL; | ||
| const host: string = new URL(baseRHDHURL).hostname; | ||
| const domain = host.split(".").slice(1).join("."); | ||
| await uiHelper.fillTextInputByLabel("Base URL", `https://sonar.${domain}`); | ||
|
|
||
| await uiHelper.selectMuiBox( | ||
| "root_authParams__oneof_select", | ||
| "Username and Password", | ||
| ); | ||
|
|
||
| await uiHelper.fillTextInputByLabel("Username *", "admin"); | ||
| await uiHelper.fillTextInputByLabel("Password", "NewAdminPassword1@", true); | ||
|
|
||
| await uiHelper.fillTextInputByLabel("Name *", project, true); | ||
| await uiHelper.fillTextInputByLabel("Key *", projectKey); | ||
| await uiHelper.fillTextInputByLabel("Branch", "main"); | ||
| await uiHelper.clickButton("Review"); | ||
| await uiHelper.clickButton("Create"); | ||
| await uiHelper.clickLinkWithNewTab(/SonarQube project URL/i); | ||
|
|
||
| await uiHelper.isLinkVisible(project); | ||
| }); | ||
| }); | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/iis it intentional ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is regular expression. Url link contains project name with random part.