Skip to content
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

Restore LoadTestIT #124

Merged
merged 47 commits into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
14f360b
Restore LoadTestIT
RonnyFrayRegato Oct 8, 2022
14ef4ba
Update ReadMe for CI
RonnyFrayRegato Oct 9, 2022
773f104
Update ci.sh
RonnyFrayRegato Oct 9, 2022
cf844a0
Update WebTestUtil
RonnyFrayRegato Oct 10, 2022
b39b961
Update InstallerTest
RonnyFrayRegato Oct 16, 2022
5a78106
Revert CI to three workers
RonnyFrayRegato Oct 16, 2022
dbc3ab5
Configure CI to two workers
RonnyFrayRegato Oct 16, 2022
3136f22
Create MariaDB service container
RonnyFrayRegato Oct 16, 2022
b53ac8f
Revert CI to three workers
RonnyFrayRegato Oct 16, 2022
c1fd847
Revert CI to three workers
RonnyFrayRegato Oct 16, 2022
dd2d23a
Configure CI for two workers
RonnyFrayRegato Nov 9, 2022
b7e8e86
Merge branch 'main' into restore-LoadTestIT
RonnyFrayRegato Nov 9, 2022
22c9fe5
Update workflow files
RonnyFrayRegato Nov 16, 2022
be6fd88
Update WebTestUtil
RonnyFrayRegato Nov 18, 2022
4bd31d9
Update ReadMe for CI
RonnyFrayRegato Nov 18, 2022
a582501
Update WebTestUtil
RonnyFrayRegato Nov 19, 2022
d072228
Create advanced-test job for CI
RonnyFrayRegato Nov 22, 2022
b51c1e2
Update camunda.yml
RonnyFrayRegato Nov 22, 2022
c35a683
Update LoadTestIT
RonnyFrayRegato Dec 11, 2022
16640be
Update camunda.yml
RonnyFrayRegato Dec 11, 2022
c7d154c
Update LoadTestIT
RonnyFrayRegato Dec 11, 2022
b6da1fe
Update LoadTestIT
RonnyFrayRegato Dec 11, 2022
627e505
Update LoadTestIT
RonnyFrayRegato Dec 11, 2022
55eac14
Upload screenshots always after successful build
RonnyFrayRegato Dec 11, 2022
0b0b017
Check for idle browser during testing
RonnyFrayRegato Dec 11, 2022
8f7a536
Check for idle browser during testing
RonnyFrayRegato Dec 11, 2022
5ecbaf8
Update LoadTestIT
RonnyFrayRegato Dec 11, 2022
f66bfe4
Update ReadMe for CI
RonnyFrayRegato Dec 12, 2022
87ae8f2
Refactor Test Suite
RonnyFrayRegato Dec 12, 2022
9ebad5e
Refactor Test Suite
RonnyFrayRegato Dec 12, 2022
4535b71
Update Slack message with Camunda workflow results
RonnyFrayRegato Dec 13, 2022
ce629ff
Update Slack message with detailed job results
RonnyFrayRegato Dec 13, 2022
7e27480
Update Slack message with Camunda workflow results
RonnyFrayRegato Dec 13, 2022
373d157
Update Slack message with Camunda workflow results
RonnyFrayRegato Dec 14, 2022
8c370af
Update Slack message with detailed job results
RonnyFrayRegato Dec 14, 2022
dcc4415
Show webhook payload
RonnyFrayRegato Dec 14, 2022
0a26162
Test sending Slack message based on user
RonnyFrayRegato Dec 14, 2022
7419084
Test sending Slack message based on user
RonnyFrayRegato Dec 14, 2022
983d5aa
Test sending Slack message based on user
RonnyFrayRegato Dec 14, 2022
556e0ca
Test sending Slack message based on user
RonnyFrayRegato Dec 14, 2022
535faa7
Test sending Slack message based on dev team list
RonnyFrayRegato Dec 14, 2022
2429cb8
Test sending Slack message based on dev team list
RonnyFrayRegato Dec 15, 2022
cf1e74f
Test sending Slack message based on dev team list
RonnyFrayRegato Dec 15, 2022
cebea02
Test sending Slack message based on dev team list
RonnyFrayRegato Dec 15, 2022
f97fd7b
Verify if a user belongs to the team
RonnyFrayRegato Dec 15, 2022
08f13a9
Verify if a user belongs to the team
RonnyFrayRegato Dec 15, 2022
584cfc3
Send Slack message only if workflows are triggered by the dev team
RonnyFrayRegato Dec 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 37 additions & 11 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@ Utilizing GitHub Actions, the workflows build, test, and deliver CWS by configur

## CWS CI Camunda Workflow

The CWS CI Camunda workflow is triggered upon any push to the repository, including commits, pull requests, and merges. The workflow is also scheduled to run every day at 5 AM PST / 12 PM UTC. It is composed of two jobs: `build-and-test-cws` and `publish-cws-image`. Both jobs run on separate GitHub runners with the latest version of Ubuntu.
The CWS CI Camunda workflow is triggered upon any push to the repository, including commits, pull requests, and merges. The workflow is also scheduled to run every Monday at 5 AM PST / 12 PM UTC. It is composed of three jobs: `build-and-test-cws`, `advanced-test`, and `publish-cws-image`. All jobs run on separate GitHub runners with the latest version of Ubuntu.

The `build-and-test-cws` job performs all the necessary preliminary steps required to configure and build CWS with Camunda security. Once these steps are completed, a fully-functioning instance of CWS is built. Following the build, unit and integration tests are run, with resulting artifacts being saved to the workflow run. Afterwards, data from the workflow is sent to the development team.

The `publish-cws-image` job is the CD component of the workflow, triggered upon a commit message containing the word "version," and dependant upon successful completion of the `build-and-test-cws job`.
The `advanced-test` job is fundamentally the same for the build of CWS, except 2 workers being started instead of 1. Following the build, an advanced integration test requiring additional workers is run.

The `publish-cws-image` job is the CD component of the workflow, triggered upon a commit with a tag and dependant upon successful completion of the `build-and-test-cws` and `advanced-test` jobs.

> **Note**
> The current GitHub runner configuration used for the build and test of CWS, as well as the advanced test, supports up to 1 console and 2 workers.
> More than 2 workers may result in test failures due to the stress on the runner.

### build-and-test-cws Job

- [**Services**](https://docs.github.com/en/actions/using-containerized-services/about-service-containers):
- MariaDB
- Image: mariadb:10.3
- Ports: 3306:3306
- [**checkout**](https://github.com/marketplace/actions/checkout): This action checks out the repository under `$GITHUB_WORKSPACE`, so the workflow can access it.
- Set up JDK 8:
- [**setup-java**](https://github.com/marketplace/actions/setup-java-jdk): This action downloads and sets up a requested version of Java
Expand All @@ -35,16 +45,14 @@ The `publish-cws-image` job is the CD component of the workflow, triggered upon
- **Set up Elasticsearch**:
- Creates and starts a Docker container with Elasticsearch
- Runs in the background (detached mode)
- **Set up CWS database using Docker**:
- Creates and starts a Docker container with MariaDB database instance for CWS
- Runs in the background (detached mode)
- Uses port 3306:3306, with name `cws_dev`
- **Show Docker containers**: Shows all Docker containers and their statuses
- **Build CWS**:
- Builds and runs CWS
- Begins by running the first bash script in the build process: run_ci.sh
- The bash script is passed the `SECURITY` environmental variable to run CWS in a specific security mode
- The CWS security mode for this workflow is `CAMUNDA`
- The bash script is passed the `SECURITY` environmental variable to run CWS in a specific security mode
- The CWS security mode for this workflow is `CAMUNDA`
- The bash script is passed the `WORKERS` environmental variable to start the specified number of workers
- Current configuration is set to run 1 console and 1 worker
- **Show CWS Log**:
- List files in the directory where `cws.log` is expected
- The presence of the file verifies successful deployment of the Apache Tomcat server
Expand All @@ -63,6 +71,18 @@ The `publish-cws-image` job is the CD component of the workflow, triggered upon
- Sends GitHub Actions workflow data to a Slack channel via a webhook URL
- Requires a Slack workflow using webhooks to be created

### advanced-test Job
- **Build CWS**:
- Builds and runs CWS
- Begins by running the first bash script in the build process: run_ci.sh
- The bash script is passed the `SECURITY` environmental variable to run CWS in a specific security mode
- The CWS security mode for this workflow is `CAMUNDA`
- The bash script is passed the `WORKERS` environmental variable to start the specified number of workers
- Current configuration is set to run 1 console and 2 workers
- **Run Load Integration Test**:
- Runs the Selenium-based LoadTestIT
- Requires a minimum of 2 workers to be started in order to run properly

### publish-cws-image Job
- **Check out the repo**:
- Utilizes the same `checkout` action to check out the repository again
Expand All @@ -81,21 +101,27 @@ The `publish-cws-image` job is the CD component of the workflow, triggered upon

## CWS CI LDAP Workflow

The CWS CI LDAP workflow is triggered upon any push to the repository, including commits, pull requests, and merges. The workflow is also scheduled to run every day at 5 AM PST / 12 PM UTC. It is composed of one job, `build-and-test-cws`, and runs on a GitHub runner with the latest version of Ubuntu.
The CWS CI LDAP workflow is triggered upon any push to the repository, including commits, pull requests, and merges. The workflow is also scheduled to run every Monday at 5 AM PST / 12 PM UTC. It is composed of one job, `build-and-test-cws`, and runs on a GitHub runner with the latest version of Ubuntu.

The `build-and-test-cws` job performs all the necessary preliminary steps required to configure and build CWS with LDAP security. Once these steps are completed, a fully-functioning instance of CWS is built. Following the build, LDAP-specific integration tests are run. Afterwards, data from the workflow is sent to the development team.

The following are key differences in the steps of the `build-and-test-cws` job between the `CWS CI Camunda` and `CWS CI LDAP` workflows.

> **Note**
> The current GitHub runner configuration used for the build and test of CWS supports up to 1 console and 2 workers.
> More than 2 workers may result in test failures due to the stress on the runner.

### build-and-test-cws Job
- **Set up CWS LDAP Server**:
- Creates and starts a Docker container with an LDAP server
- Runs in the background (detached mode)
- **Build CWS**:
- Builds and runs CWS
- Begins by running the first bash script in the build process: run_ci.sh
- The bash script is passed the `SECURITY` environmental variable to run CWS in a specific security mode
- The CWS security mode for this workflow is `LDAP`
- The bash script is passed the `SECURITY` environmental variable to run CWS in a specific security mode
- The CWS security mode for this workflow is `LDAP`
- The bash script is passed the `WORKERS` environmental variable to start the specified number of workers
- Current configuration is set to run 1 console and 1 worker
- **Run LDAP Integration Tests**:
- Runs LDAP-specific, Selenium-based integration tests
- Uses a different naming scheme to prevent the tests from running with the standard unit and integration tests
282 changes: 282 additions & 0 deletions .github/workflows/camunda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,282 @@
name: CWS CI Camunda

# Triggers the workflow on push
on:
push:
schedule:
# trigger a build and test of CWS weekly on Monday at 5 AM PST / 12 PM UTC
- cron: '0 12 * * 1'

env:
TEAM: ("jamesfwood" "voxparcxls" "galenhollins" "galenatjpl" "jeffreypon")

jobs:

build-and-test-cws:

runs-on: ubuntu-latest
env:
SECURITY: "CAMUNDA"
WORKERS: 1

services:
mdb103:
image: mariadb:10.3
ports:
- 3306:3306
env:
MYSQL_DATABASE: cws_dev
MYSQL_ROOT_PASSWORD: adminpw
options: >-
--name mdb103

steps:
- uses: actions/checkout@v3

- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
cache: maven

- name: Create open-source certs
run: |
cd cws-certs
chmod +x generate-certs.sh
./generate-certs.sh

- name: Download Logstash
uses: carlosperate/download-file-action@v1
with:
file-url: https://artifacts.elastic.co/downloads/logstash/logstash-oss-7.16.2-windows-x86_64.zip
file-name: logstash-7.16.2.zip
location: install/logging/

- name: Check for Logstash
run: |
cd install/logging/
ls -l

- name: Set up Elasticsearch
run: |
cd install/docker/es-only
docker-compose up -d

- name: Show Docker containers
run: |
sleep 5s
docker ps -a

- name: Build CWS
id: build
run: |
cd ci
chmod +x run_ci.sh
./run_ci.sh $SECURITY $WORKERS
shell: bash

- name: Show CWS Log
run: |
cd dist/console-only/cws/server/apache-tomcat-9.0.33/logs
ls -al

- name: Set up Google Chrome
run: |
sudo apt-get update
sudo apt-get --only-upgrade install google-chrome-stable

- name: Display Google Chrome version
run: google-chrome --version

- name: Run Unit Tests
id: unit
run: mvn -Dmaven.compiler.debug=true -Dmaven.compiler.debuglevel=lines,vars,source clean test jacoco:report-aggregate
shell: bash

- name: Run Integration Tests
id: integration
run: mvn -Dmaven.compiler.debug=true -Dmaven.compiler.debuglevel=lines,vars,source integration-test verify -DskipTests
shell: bash

- name: Upload Jacoco report
uses: actions/upload-artifact@v3
with:
name: jacoco-report
path: jacoco-reports/aggregate/index.html

- name: Upload test screenshots
if: ${{ always() && steps.build.outcome == 'success' }}
uses: actions/upload-artifact@v3
with:
name: test-screenshots
path: test-screenshots/

- name: Send custom JSON data to Slack workflow
if: ${{ always() && contains(env.TEAM, github.actor) }}
id: slack
uses: slackapi/[email protected]
with:
# This data can be any valid JSON from a previous step in the GitHub Action
payload: |
{
"status": "CWS CI Camunda build and test result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}\nBuild result: ${{ steps.build.outcome }}\nUnit test result: ${{ steps.unit.outcome }}\nIntegration test result: ${{ steps.integration.outcome }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "CWS CI Camunda build and test result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}\nBuild result: ${{ steps.build.outcome }}\nUnit test result: ${{ steps.unit.outcome }}\nIntegration test result: ${{ steps.integration.outcome }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}


advanced-test:

runs-on: ubuntu-latest
env:
SECURITY: "CAMUNDA"
WORKERS: 2

services:
mdb103:
image: mariadb:10.3
ports:
- 3306:3306
env:
MYSQL_DATABASE: cws_dev
MYSQL_ROOT_PASSWORD: adminpw
options: >-
--name mdb103

steps:
- uses: actions/checkout@v3

- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
cache: maven

- name: Create open-source certs
run: |
cd cws-certs
chmod +x generate-certs.sh
./generate-certs.sh

- name: Download Logstash
uses: carlosperate/download-file-action@v1
with:
file-url: https://artifacts.elastic.co/downloads/logstash/logstash-oss-7.16.2-windows-x86_64.zip
file-name: logstash-7.16.2.zip
location: install/logging/

- name: Check for Logstash
run: |
cd install/logging/
ls -l

- name: Set up Elasticsearch
run: |
cd install/docker/es-only
docker-compose up -d

- name: Show Docker containers
run: |
sleep 5s
docker ps -a

- name: Build CWS
id: build
run: |
cd ci
chmod +x run_ci.sh
./run_ci.sh $SECURITY $WORKERS
shell: bash

- name: Show CWS Log
run: |
cd dist/console-only/cws/server/apache-tomcat-9.0.33/logs
ls -al

- name: Set up Google Chrome
run: |
sudo apt-get update
sudo apt-get --only-upgrade install google-chrome-stable

- name: Display Google Chrome version
run: google-chrome --version

- name: Run Load Integration Test
id: load
run: mvn -Dmaven.compiler.debug=true -Dmaven.compiler.debuglevel=lines,vars, -Dit.test=LoadTestIT verify -DskipTests
shell: bash

- name: Upload test screenshots
if: ${{ always() && steps.build.outcome == 'success' }}
uses: actions/upload-artifact@v3
with:
name: test-screenshots-advanced
path: test-screenshots/

- name: Send custom JSON data to Slack workflow
if: ${{ always() && contains(env.TEAM, github.actor) }}
id: slack
uses: slackapi/[email protected]
with:
# This data can be any valid JSON from a previous step in the GitHub Action
payload: |
{
"status": "CWS CI Camunda advanced test result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}\nBuild result: ${{ steps.build.outcome }}\nLoad integration test result: ${{ steps.load.outcome }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "CWS CI Camunda advanced test result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}\nBuild result: ${{ steps.build.outcome }}\nLoad integration test result: ${{ steps.load.outcome }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}


publish-cws-image:

if: ${{ github.ref_type == 'tag' }}
needs: [build-and-test-cws, advanced-test]
runs-on: ubuntu-latest

steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
cache: maven

- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Generate CWS Docker image
run: |
cd install/docker/cws-image
./build.sh

- name: Re-Tag CWS Docker image for open source
run: docker tag nasa-ammos/common-workflow-service:${{ github.ref_name }} ${{ secrets.DOCKER_USERNAME }}/common-workflow-service:${{ github.ref_name }}

- name: Push CWS Docker image
run: docker push ${{ secrets.DOCKER_USERNAME }}/common-workflow-service:${{ github.ref_name }}
Loading