Skip to content

Commit

Permalink
Merge pull request #542 from zebrunner/develop
Browse files Browse the repository at this point in the history
2.3 rc
  • Loading branch information
vdelendik authored Apr 28, 2023
2 parents 2e78be5 + 9a24c46 commit fe0bd88
Show file tree
Hide file tree
Showing 19 changed files with 155 additions and 58 deletions.
4 changes: 2 additions & 2 deletions docs/config-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
* Open "Account and Profile" menu in top right corner and generate token
* Login to [Jenkins](http://hostname/jenkins), open "Management_Jobs" folder
* Run "RegisterOrganization" job providing your organization name as folderName and Reporting url/token
![Alt text](https://github.com/zebrunner/zebrunner/blob/develop/docs/img/Organization.png?raw=true "Organization")
![Alt text](https://github.com/zebrunner/community-edition/blob/master/docs/img/Organization.png?raw=true "Organization")
> New organization folder is created with "RegisterRepository" job inside and registered reporting integration
### Register Repository
* Open your organization folder
* Run "RegisterRepository" job providing git args (use [carina-demo](https://github.com/zebrunner/carina-demo.git) as sample repo to scan)
![Alt text](https://github.com/qaprosoft/qps-infra/blob/develop/docs/img/Repository.png?raw=true "Repository")
![Alt text](https://github.com/zebrunner/community-edition/blob/master/docs/img/Repository.png?raw=true "Repository")
> SYSTEM jobs (build, onPullRequest, onPush) and all testing jobs are generated, login to [SonarQube](http://hostname/sonarqube) to see static code analysis of your test repository sources
* Setup [Source Code Manager](https://zebrunner.github.io/community-edition/integration/scm/) and [SonarQube](https://zebrunner.github.io/community-edition/integration/sonarqube/) integrations to automate jobs generation and static code analysis for every pull request/merge operations.

Expand Down
Binary file removed docs/img/SonarBaseUrlConfig.png
Binary file not shown.
Binary file modified docs/img/SonarGitHubConfig.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/SonarProjectDevOps.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/img/SonarPullRequestConfig.png
Binary file not shown.
Binary file removed docs/img/gitlab-mr-deco1.png
Binary file not shown.
Binary file removed docs/img/gitlab-mr-deco2.png
Binary file not shown.
6 changes: 3 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ Zebrunner (Community Edition)
Zebrunner (Community Edition) is a [Continuous configuration automation](https://en.wikipedia.org/wiki/Infrastructure_as_code#Continuous_configuration_automation) framework for continuous testing (running various kinds of tests on the code to gain successive levels of confidence in the quality of the code), and (optionally) continuous deployment. It is built in accordance with [Infrastructure as Code](https://en.wikipedia.org/wiki/Infrastructure_as_code) processes.
> It is integrated by default with [carina-core](http://www.carina-core.io) open source TestNG framework and uses Jenkins as a CI Tool.
* Zebrunner is built on top of popular docker solutions, it includes Postgres database, [Zebrunner Reporting](https://zebrunner.com/), Jenkins with agent node(s), Selenium Hub(s), [MCloud](https://zebrunner.com/mcloud), [SonarQube](https://github.com/zebrunner/sonarqube), etc.
> In addition, it is easily integrated with 3rd party devices/browsers cloud providers like: [Zebrunner Selenium Grid](https://zebrunner.com/), [Browserstack](https://www.browserstack.com/), [SauceLabs](https://saucelabs.com/), etc.
* Zebrunner is built on top of popular docker solutions, it includes Postgres database, [Zebrunner Testing Platform](https://zebrunner.com/testing-platform) (Community Edition), Jenkins with agent node(s), Selenium Hub(s), [Zebrunner Device Farm](https://zebrunner.com/products/mobile-testing-farm/), [SonarQube](https://github.com/zebrunner/sonarqube), etc.
> In additions it is easily integrated with 3rd party devices/browsers cloud providers like: [Zebrunner Selenium Grid](https://zebrunner.com/selenium-grid), [Browserstack](https://www.browserstack.com/), [SauceLabs](https://saucelabs.com/) etc
* All components are deployed under NGiNX WebServer which can be configured in a fully secured environment

* Zebrunner and its subcomponents all together can be used as an effective Test Automation infrastructure for test automation development, execution, management, etc.

## Purpose
Welcome to the Zebrunner Tutorial. This manual is designed to help you install, configure and maintain your system, and to optimize and extend or re-configure it to meet the changing needs of your business.
Welcome to the Zebrunner Community Edition Tutorial. This manual is designed to help you install, configure and maintain your system, and to optimize and extend or re-configure it to meet the changing needs of your business.
> In short, the aim of this manual is to explain the tasks involved in administering Zebrunner (Community Edition)
## Audience
Expand Down
69 changes: 30 additions & 39 deletions docs/integration/sonarqube.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,19 @@
The sonarqube static analysis is invoked for each webhook event triggered on your target repository(pushes and/or pull/merge requests).

If the event is a pull/merge request the reports from the sonarqube analysis will be decorated into the pull request itself for the correspondant scm system. On the contrary, only the analysis will run for push events.
> Note: default credentials for embedded sonarqube are: admin/admin. Please, change them after 1st login
* Login to SonarQube
* Go to **My Account > Security**
* Generate new token using **Global Analysis Token** type and **No expiration**
* Login to the Jenkins, go to **Manage Jenkins > System Configuration > Global Properties**
* Search for **SONAR_TOKEN** and put generated value
> To integrate private sonarqube server update also **SONAR_URL** global env variable.
> Note: default credentials for embedded sonarqube are: admin/admin, we recommend to change them after setting up zebrunner
> Note: Sonarqube pull request decoration is supported for **Github** and **Gitlab**
> Note: if the sonarqube server is not available the analysis will be skipped
## Integrate private sonarqube server

If you have a private sonarqube instance and you have decided to use it, please follow the steps bellow:

* Login to Jenkins, go to **Manage Jenkins > System Configuration > Global Properties**
* Search for **SONAR_URL** and change the value with your private SonarQube instance url
> Note: Compatible SonarQube version is 7.9.3 - 8.0
## GitHub configuration

To enable **pull reqeuest decoration** on your github repository you need to create a **GitHub App**, his purpose is to publish the sonarqube reports generated on the webhook event being processed as **checks** into the pull request itself on github.
To enable **pull request decoration** on your github repository you need to create a **GitHub App**, its purpose is to publish the sonarqube reports generated on the webhook event being processed as **checks** into the pull request itself on github.
> Steps were generated based on original Sonarqube [article](https://docs.sonarqube.org/9.8/devops-platform-integration/github-integration/)
### Create a [GitHub App](https://developer.github.com/apps/about-apps/)

Expand All @@ -38,6 +32,11 @@ To enable **pull reqeuest decoration** on your github repository you need to cre
| Metadata | Read-Only |
| Pull Requests | Read & Write |
| Commit statuses | Read-only |
| Contents | Read-only |
| Email addresses | Read-only |
| Members | Read-only |
| Projects | Read-only |

> Note: if your are using **Github Enterprise** the permission "Metadata" is renamed to "Repository Metadata"
* Under "Where can this GitHub App be installed?" select **Any account.**
Expand All @@ -58,44 +57,36 @@ Install your GitHub App from the app's settings page.
* Click install
> Note: You can select specific repositories, so the github application will have access **only for those specified**
### Configure sonarqube with your app
### Configure SonarQube with your app

* Login into your sonarqube instance
* Go to **Administration > Configuration > GitHub** add your GitHub App **Client ID, Client Secret**
![Alt text](https://github.com/qaprosoft/qps-infra/blob/develop/docs/img/SonarGitHubConfig.png?raw=true "SonarGitHubConfig")

* In **Administration > Configuration > Pull Request** add your GitHub **App ID, App Name, App Private Key**
![Alt text](https://github.com/qaprosoft/qps-infra/blob/develop/docs/img/SonarPullRequestConfig.png?raw=true "SonarPullRequestConfig")

* Login into your SonarQube instance
* Go to **Administration > DevOps Platform Integrations > GitHub** create configuration using your GitHub App **ID, Client ID, Client Secret and Private Key**
![Alt text](https://github.com/zebrunner/community-edition/blob/master/docs/img/SonarGitHubConfig.png?raw=true "SonarGitHubConfig")
> Note: make sure to copy all content from the .pem file generated in the **Create GitHub App** section
### Configure DevOps Integration for your project

* Login into your SonarQube instance
* Go to your project **General Settings > DevOps Platform Integrations**
* Choose **Configuration name**, specify **Repository name** and **Enable analysis summary under the GitHub Conversation tab**
![Alt text](https://github.com/zebrunner/community-edition/blob/master/docs/img/SonarProjectDevOps.png?raw=true "SonarProjectDevOps")

### Pull Request decoration example

When you create a pull and the sonar analysis reported issues, your pull request will be decorated with those issues and links to the sonarqube instance with your project.

![Alt text](https://github.com/zebrunner/zebrunner/blob/master/docs/img/github-pr-deco1.png?raw=true "github-pr-deco1")
![Alt text](https://github.com/zebrunner/zebrunner/blob/master/docs/img/github-pr-deco2.png?raw=true "github-pr-deco2")
![Alt text](https://github.com/zebrunner/community-edition/blob/master/docs/img/github-pr-deco1.png?raw=true "github-pr-deco1")
![Alt text](https://github.com/zebrunner/community-edition/blob/master/docs/img/github-pr-deco2.png?raw=true "github-pr-deco2")

## Gitlab configuration

To enable **merge requests decoration** on your gitlab repository we are going to use the token generated in **Gitlab access token** step. The sonarqube report is published as pipeline status and comments into the merge request itself.

* Login into your sonarqube instance
* Go to **Administration > Configuration > Pull Requests > Integration with Gitlab** and in the token input paste your gitlab acces token.
## Gitlab, Bitbucket and Azure configuration

### Merge request decoration exmaple

When you create a merge request and the sonar analysis reports issues, your merge request will be decorated with those issues and links to the sonarqube instance with your project.

![Alt text](https://github.com/zebrunner/zebrunner/blob/master/docs/img/gitlab-mr-deco1.png?raw=true "gitlab-mr-deco1")
![Alt text](https://github.com/zebrunner/zebrunner/blob/master/docs/img/gitlab-mr-deco2.png?raw=true "gitlab-mr-deco2")

Visit original Sonarqube integration [guide](https://docs.sonarqube.org/latest/devops-platform-integration/github-integration/)

## Configure sonarqube base URL

This will serve static context(such as images, links, etc.) for pull/merge requests decoration. Follow the below steps to configure your server base URL:

* Add your SonarQube server under **Administration > Configuration > General Settings > Server base URL**
![Alt text](https://github.com/qaprosoft/qps-infra/blob/develop/docs/img/SonarBaseUrlConfig.png?raw=true "SonarBaseUrlConfig")
> Tip: If you are missing images in your decorated pull/merge request it is probably due to configuration issues or the sonarqube server being unavailable at that moment.

Expand Down
Binary file removed docs/organization5.png
Binary file not shown.
10 changes: 5 additions & 5 deletions docs/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

All test jobs are created and maintained automatically according to [IaC](https://en.wikipedia.org/wiki/Infrastructure_as_code) processes.
For every TestNG [suite](https://www.toolsqa.com/testng/testng-test-suite/) dedicated job is created.
> For example visit [carina suites](https://github.com/qaprosoft/carina-demo/tree/master/src/test/resources/testng_suites)
> For example visit [carina suites](https://github.com/zebrunner/carina-demo/tree/main/src/test/resources/testng_suites)
## Test Jobs (API/Web/Mobile)

To generate special type of jobs, coverage matrix etc we have to use special annotations otherwise "api" job is generated using suite ["name"](https://github.com/qaprosoft/carina-demo/blob/14f7f7a7c426b1c6d86768abddf4c6467b32b016/src/test/resources/testng_suites/api.xml#L2).
Use [special annotations](https://zebrunner.github.io/community-edition/user-guide/#special-annotations) to define jobs name, ownership, schedule coverage matrix etc, for example [API-Demo-Test](https://github.com/zebrunner/carina-demo/blob/b64e76d5168ed5439c146d715e194294b2199b12/src/test/resources/testng_suites/api.xml#L5)
Test Jobs can be executed on-demand, scheduled, included into different testing layers (Smoke, Regression, etc.).

### Create a Job
Expand All @@ -25,7 +25,7 @@ Test Jobs can be executed on-demand, scheduled, included into different testing
<parameter name="suiteOwner" value="qpsdemo"/>
<parameter name="jenkinsJobName" value="Job1"/>
<parameter name="jenkinsJobType" value="api"/>
<parameter name="jenkinsEmail" value="test@qaprosoft.com"/>
<parameter name="jenkinsEmail" value="user@zebrunner.com"/>
<parameter name="jenkinsEnvironments" value="DEMO"/> 
```
* Commit and merge.
Expand All @@ -48,7 +48,7 @@ Steps:
* Login to Jenkins
* Go to organization/repository and open a Job
* Click Build with Parameters and run Build
* When Job is completed analyze published reports/logs (ZafiraReport/Full TestNG HTML Report/TestNG Summary HTML Report)
* When Job is completed analyze published reports/logs (Zebrunner Report and TestNG reports)

### Schedule a Job
* Open TestNG suite xml file
Expand Down Expand Up @@ -100,7 +100,7 @@ Steps:
> Note: There is a "CRON" view for such kind of jobs
* Click Build with Parameters and run Build
* Cron Job should trigger children jobs according to desired configuration matrix
* When Cron and children jobs are finished analyze children jobs' reports/logs (Carina reports/Zafira reports/TestNG reports)
* When Cron and children jobs are finished analyze children jobs' reports/logs (Zebrunner Report and TestNG reports)

### Schedule a Cron
* Open any child TestNG suite xml file
Expand Down
2 changes: 1 addition & 1 deletion jenkins
2 changes: 1 addition & 1 deletion mcloud
2 changes: 1 addition & 1 deletion nginx/conf.d/default.conf.original
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ server {
}
}

location ~ /(stf|auth/mock|auth/ldap|auth/contact|auth/api|static/app|static/logo|app/api|api/v1|s/upload|s/image|s/blob|s/apk) {
location ~ /(stf|auth/mock|auth/ldap|auth/zebrunner|auth/contact|auth/api|static/app|static/logo|app/api|api/v1|s/upload|s/image|s/blob|s/apk) {
set $upstream_stf http://stf-proxy:80;
proxy_pass $upstream_stf;
proxy_http_version 1.1;
Expand Down
97 changes: 97 additions & 0 deletions patch/2.3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/bin/bash

# shellcheck disable=SC1091
source patch/utility.sh

TARGET_VERSION=2.3

source backup/settings.env
SOURCE_VERSION=${ZBR_VERSION}
#echo SOURCE_VERSION: $SOURCE_VERSION

if ! [[ "${TARGET_VERSION}" > "${SOURCE_VERSION}" ]]; then
#target Zebrunner version less or equal existing
echo "No need to perform upgrade to ${TARGET_VERSION}"
exit 2
fi

echo "Upgrading Zebrunner from ${SOURCE_VERSION} to ${TARGET_VERSION}"

# apply nginx changes
cp nginx/conf.d/default.conf nginx/conf.d/default.conf.bak_2.2
cp nginx/conf.d/default.conf.original nginx/conf.d/default.conf

replace ./nginx/conf.d/default.conf "server_name localhost" "server_name '$ZBR_HOSTNAME'"
# declare ssl protocol for NGiNX default config
if [[ "$ZBR_PROTOCOL" == "https" ]]; then
replace ./nginx/conf.d/default.conf "listen 80" "listen 80 ssl"

# uncomment default ssl settings
replace ./nginx/conf.d/default.conf "# ssl_" " ssl_"

# configure valid sub-modules rules
replace ./nginx/conf.d/default.conf "http://jenkins-master:8080;" "https://jenkins-master:8443;"
replace ./nginx/conf.d/default.conf "upstream_sonar http://127.0.0.1:80;" "upstream_sonar https://127.0.0.1:80;"
replace ./nginx/conf.d/default.conf "upstream_mcloud http://127.0.0.1:80;" "upstream_mcloud https://127.0.0.1:80;"
replace ./nginx/conf.d/default.conf "upstream_stf http://stf-proxy:80;" "upstream_stf https://stf-proxy:80;"
fi

if [[ $ZBR_REPORTING_ENABLED -eq 1 ]]; then
replace ./nginx/conf.d/default.conf "default-proxy-server" "zebrunner-proxy:80"
replace ./nginx/conf.d/default.conf "default-proxy-host" "zebrunner-proxy"
elif [[ $ZBR_MCLOUD_ENABLED -eq 1 ]]; then
replace ./nginx/conf.d/default.conf "default-proxy-server" "stf-proxy:80"
replace ./nginx/conf.d/default.conf "default-proxy-host" "stf-proxy"
elif [[ $ZBR_JENKINS_ENABLED -eq 1 ]]; then
replace ./nginx/conf.d/default.conf 'set $upstream_default default-proxy-server;' ""
replace ./nginx/conf.d/default.conf "proxy_set_header Host default-proxy-host;" ""
replace ./nginx/conf.d/default.conf 'proxy_pass http://$upstream_default;' "rewrite / /jenkins;"
elif [[ $ZBR_SONARQUBE_ENABLED -eq 1 ]]; then
replace ./nginx/conf.d/default.conf 'set $upstream_default default-proxy-server;' ""
replace ./nginx/conf.d/default.conf "proxy_set_header Host default-proxy-host;" ""
replace ./nginx/conf.d/default.conf 'proxy_pass http://$upstream_default;' "rewrite / /sonarqube;"
else
replace ./nginx/conf.d/default.conf 'proxy_pass http://$upstream_default;' "root /usr/share/nginx/html;"
fi

#apply mcloud changes
if [[ ! -f mcloud/.disabled ]] ; then
cp mcloud/.env mcloud/.env_2.2
cp mcloud/variables.env mcloud/variables.env_2.2

mcloud/zebrunner.sh setup
fi

#apply jenkins changes
if [[ ! -f jenkins/.disabled ]] ; then
cp jenkins/variables.env jenkins/variables.env_2.2
#549 remove ./jobs/Management_Jobs/jobs/* to recreate using new main branch
docker run --rm --volumes-from jenkins-master "ubuntu" bash -c "rm -rf /var/jenkins_home/jobs/Management_Jobs/jobs/DeleteOrganization \
/var/jenkins_home/jobs/Management_Jobs/jobs/RegisterHubCredentials \
/var/jenkins_home/jobs/Management_Jobs/jobs/RegisterMavenSettings \
/var/jenkins_home/jobs/Management_Jobs/jobs/RegisterOrganization \
/var/jenkins_home/jobs/Management_Jobs/jobs/RegisterReportingCredentials \
/var/jenkins_home/jobs/Management_Jobs/jobs/RegisterUserCredentials"
jenkins/zebrunner.sh setup
fi

# apply sonarqube changes
if [[ ! -f sonarqube/.disabled ]] ; then
docker rm -f sonarqube
docker volume rm sonarqube_data-volume sonarqube_extensions-volume sonarqube_logs-volume
sonarqube/zebrunner.sh setup
fi

# apply selenoid changes
if [[ ! -f selenoid/.disabled ]] ; then
cp selenoid/.env selenoid/.env_2.2
selenoid/zebrunner.sh setup
fi

echo "Upgrade to ${TARGET_VERSION} finished successfully"

#remember successfully applied version in settings.env file
export ZBR_VERSION=${TARGET_VERSION}

#save information about upgraded zebrunner version
export_settings
2 changes: 1 addition & 1 deletion selenoid
Submodule selenoid updated 1 files
+1 −1 .env.original
2 changes: 1 addition & 1 deletion sonarqube
15 changes: 12 additions & 3 deletions zebrunner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
fi

export ZBR_INSTALLER=1
export ZBR_VERSION=2.1
export ZBR_VERSION=2.3
set_global_settings

cp .env.original .env
Expand Down Expand Up @@ -214,7 +214,7 @@

shutdown() {
if [ ! -f backup/settings.env ]; then
echo_warning "You have to setup services in advance using: ./zebrunner.sh setup"
echo_warning "Unable to erase as nothing is configured!"
echo_telegram
exit -1
fi
Expand All @@ -225,6 +225,8 @@
exit
fi

export SHUTDOWN_CONFIRMED=1

print_banner

jenkins/zebrunner.sh shutdown
Expand Down Expand Up @@ -507,9 +509,16 @@
exit -1
fi

patch/2.3.sh
p2_3=$?
if [[ ${p2_3} -eq 1 ]]; then
echo "ERROR! 2.3 patchset was not applied correctly!"
exit -1
fi


# IMPORTANT! Increment latest verification to new version, i.e. p1_3, p1_4 etc to verify latest upgrade status
if [[ ${p2_1} -eq 2 ]]; then
if [[ ${p2_3} -eq 2 ]]; then
echo "No need to restart service as nothing was upgraded."
exit -1
fi
Expand Down

0 comments on commit fe0bd88

Please sign in to comment.