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

Create LDAP CI test #116

Merged
merged 28 commits into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4c5741e
Create ldap.yml
RonnyFrayRegato Aug 29, 2022
3b565b5
Test security env variable.
RonnyFrayRegato Aug 29, 2022
98fc5ce
Test security env variable.
RonnyFrayRegato Aug 29, 2022
0cc3074
Test security env variable.
RonnyFrayRegato Aug 29, 2022
a6d9eb7
Configure open source LDAP for CI.
RonnyFrayRegato Aug 30, 2022
a6c61c6
Configure open source LDAP for CI.
RonnyFrayRegato Aug 30, 2022
72c924b
Adjust wait time for web elements
RonnyFrayRegato Sep 1, 2022
403c43a
Merge branch 'main' into CWS-687-LDAP-CI-test
RonnyFrayRegato Sep 1, 2022
90262ca
Create WebTestLdap
RonnyFrayRegato Sep 1, 2022
0557963
Create WebTestLdap
RonnyFrayRegato Sep 1, 2022
7eb77b9
Create WebTestLdap
RonnyFrayRegato Sep 1, 2022
56b4e0b
Create WebTestLdap
RonnyFrayRegato Sep 1, 2022
9fea6c9
Publish CWS Docker image
RonnyFrayRegato Sep 2, 2022
2dd0442
Publish CWS Docker image
RonnyFrayRegato Sep 2, 2022
869c9df
Test version v.2.3.0
RonnyFrayRegato Sep 4, 2022
5ec98e3
Test version v.2.3.0
RonnyFrayRegato Sep 4, 2022
06d3507
Test version v.2.3.0
RonnyFrayRegato Sep 5, 2022
8118e0e
Test version v.2.3.0
RonnyFrayRegato Sep 5, 2022
65b8d85
Test version v.2.3.0
RonnyFrayRegato Sep 5, 2022
7b549e9
Test version v.2.3.0
RonnyFrayRegato Sep 6, 2022
43e84d2
Update WebTestUtil
RonnyFrayRegato Sep 7, 2022
9dc1f04
Update WebTestUtil
RonnyFrayRegato Sep 7, 2022
38b9091
Update WebTestUtil
RonnyFrayRegato Sep 7, 2022
5d01c47
Run WebTestLdap
RonnyFrayRegato Sep 8, 2022
54e24bf
Update web elements for integration tests
RonnyFrayRegato Sep 8, 2022
c106ccf
Merge branch 'main' into CWS-687-LDAP-CI-test
RonnyFrayRegato Sep 8, 2022
e26e68e
Update WebTestUtil
RonnyFrayRegato Sep 8, 2022
2ccad0f
Update workflow file
RonnyFrayRegato Sep 8, 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
110 changes: 110 additions & 0 deletions .github/workflows/ldap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: CWS CI LDAP

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

jobs:

build-and-test-cws:

runs-on: ubuntu-latest
env:
SECURITY: "LDAP"

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: Set up CWS database using Docker
run: docker run -d -p 3306:3306 -e MYSQL_DATABASE=cws_dev -e MYSQL_ROOT_PASSWORD=adminpw --name mdb103 mariadb:10.3

- name: Set up CWS LDAP Server
run: |
cd cws-opensource-ldap
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
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 LDAP Integration Tests
id: ldap
run: mvn -DfailIfNoTests=false -Dtest=WebTestLdap clean test
shell: bash

- name: Send custom JSON data to Slack workflow
if: ${{ always() }}
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 LDAP build and test result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}\nCWS build result: ${{ steps.build.outcome }}\nLDAP integration test result: ${{ steps.ldap.outcome }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "CWS CI LDAP build and test result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}\nCWS build result: ${{ steps.build.outcome }}\nLDAP integration test result: ${{ steps.ldap.outcome }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
78 changes: 70 additions & 8 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CWS CI
name: CWS CI Camunda

# Triggers the workflow on push
on:
Expand All @@ -9,71 +9,96 @@ on:

jobs:

build-cws:
build-and-test-cws:

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

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: Set up CWS database using Docker
run: docker run -d -p 3306:3306 -e MYSQL_DATABASE=cws_dev -e MYSQL_ROOT_PASSWORD=adminpw --name mdb103 mariadb:10.3

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

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

- name: Show CWS Log
run: |
cd dist/console-only/cws/server/apache-tomcat-9.0.33/logs
ls -al
- uses: browser-actions/setup-chrome@latest
- run: chrome --version

- 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
uses: actions/upload-artifact@v3
with:
name: test-screenshots
path: test-screenshots/

- name: Send custom JSON data to Slack workflow
if: ${{ always() }}
id: slack
Expand All @@ -82,16 +107,53 @@ jobs:
# This data can be any valid JSON from a previous step in the GitHub Action
payload: |
{
"status": "GitHub Action build result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}",
"status": "CWS CI Camunda build and test result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}\nCWS build result: ${{ steps.build.outcome }}\nUnit test result: ${{ steps.unit.outcome }}\nIntegration test result: ${{ steps.integration.outcome }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "GitHub Action build result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}"
"text": "CWS CI Camunda build and test result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}\nCWS build result: ${{ steps.build.outcome }}\nUnit test result: ${{ steps.unit.outcome }}\nIntegration test result: ${{ steps.integration.outcome }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}


publish-cws-image:

if: contains(github.event.head_commit.message, 'version')
env:
CWS_VERSION: "2.3.0-pre.1" # update this each CWS release
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? Shouldn't it pull the version from the tag?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'll make the relevant changes

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The github.ref_name context variable contains the branch or tag name that triggered the workflow run, which will be used in the Docker image tag when the CD portion is triggered.

needs: build-and-test-cws
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:${{ env.CWS_VERSION }} ${{ secrets.DOCKER_USERNAME }}/common-workflow-service:${{ env.CWS_VERSION }}

- name: Push CWS Docker image
run: docker push ${{ secrets.DOCKER_USERNAME }}/common-workflow-service:${{ env.CWS_VERSION }}
12 changes: 6 additions & 6 deletions ci/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ source ${ROOT}/../utils.sh

cat > ci_console.conf.template <<- EOF
cam_server_url=NA
cws_ldap_url_default=ldaps://localhost:636
cws_ldap_url_default=ldap://localhost:389
cam_ldap_identity_plugin_class=jpl.cws.core.identity.cam.CamLdapIdentityProviderPlugin
cam_ldap_security_filter_class=jpl.cws.core.web.CwsCamSecurityFilter
ldap_identity_plugin_class=org.camunda.bpm.identity.impl.ldap.plugin.LdapIdentityProviderPlugin
Expand Down Expand Up @@ -81,8 +81,8 @@ elasticsearch_username=${ES_USERNAME}
elasticsearch_password=${ES_PASSWORD}
smtp_hostname=smtp.localhost
default_smtp_hostname=smtp.localhost
default_cws_ldap_url=ldaps://localhost:636
cws_ldap_url=ldaps://localhost:636
default_cws_ldap_url=ldap://localhost:389
cws_ldap_url=ldap://localhost:389
default_elasticsearch_use_auth=n
aws_cloudwatch_endpoint=monitoring.us-west-1.amazonaws.com
default_elasticsearch_port=9200
Expand All @@ -98,7 +98,7 @@ EOF

cat > ci_worker.conf.template <<- EOF
cam_server_url=NA
cws_ldap_url_default=ldaps://localhost:636
cws_ldap_url_default=ldap://localhost:389
cam_ldap_identity_plugin_class=jpl.cws.core.identity.cam.CamLdapIdentityProviderPlugin
cam_ldap_security_filter_class=jpl.cws.core.web.CwsCamSecurityFilter
ldap_identity_plugin_class=org.camunda.bpm.identity.impl.ldap.plugin.LdapIdentityProviderPlugin
Expand Down Expand Up @@ -142,8 +142,8 @@ elasticsearch_username=${ES_USERNAME}
elasticsearch_password=${ES_PASSWORD}
smtp_hostname=smtp.localhost
default_smtp_hostname=smtp.localhost
default_cws_ldap_url=ldaps://localhost:636
cws_ldap_url=ldaps://localhost:636
default_cws_ldap_url=ldap://localhost:389
cws_ldap_url=ldap://localhost:389
project_webapp_root=
default_elasticsearch_use_auth=n
aws_cloudwatch_endpoint=monitoring.us-west-1.amazonaws.com
Expand Down
2 changes: 1 addition & 1 deletion ci/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ printf "\nHostname set to '%s'\n\n" $HOSTNAME
# Used in cws-test
echo "$HOSTNAME" > ../cws-test/src/test/resources/hostname.txt

SECURITY="CAMUNDA"
SECURITY=${1} # parameter is passed as an env through workflow file

# Stop CWS is it is currently running
#./stop_dev.sh
Expand Down
12 changes: 6 additions & 6 deletions cws-opensource-ldap/user.ldif
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ dn: ou=Users,dc=example,dc=com
objectClass: organizationalUnit
ou: Users

dn: cn=cwsuser,ou=Users,dc=example,dc=com
dn: cn=cwsci,ou=Users,dc=example,dc=com
objectclass: inetOrgPerson
cn: cwsuser
givenName: cws
sn: user
uid: cwsuser
userpassword: ldapcwspassword
cn: cwsci
givenName: Ronny
sn: Fray
uid: cwsci
userpassword: changeme
mail: [email protected]
12 changes: 6 additions & 6 deletions cws-test/src/test/java/jpl/cws/test/WebTestIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void runDeployTest() {
// Start Instance
WebElement tasks = driver.findElement(By.xpath("//a[@href='/camunda/app/tasklist']"));
tasks.click();
findOnPage("<title>Camunda Tasklist</title>");
findOnPage("Camunda Tasklist");

sleep(10000);

Expand All @@ -118,7 +118,7 @@ public void runDeployTest() {
// Go back to CWS
WebElement cws = driver.findElement(By.xpath("//a[@href='/cws-ui']"));
cws.click();
findOnPage("<title>CWS - Deployments</title>");
findOnPage("CWS - Deployments");


// Wait for Finish
Expand Down Expand Up @@ -163,7 +163,7 @@ public void runErrorHandlingTest() {
// Start Instance (1) through Camunda
WebElement tasks = driver.findElement(By.xpath("//a[@href='/camunda/app/tasklist']"));
tasks.click();
findOnPage("<title>Camunda Tasklist</title>");
findOnPage("Camunda Tasklist");

sleep(10000);

Expand All @@ -187,7 +187,7 @@ public void runErrorHandlingTest() {
// Go back to CWS
WebElement cws = driver.findElement(By.xpath("//a[@href='/cws-ui']"));
cws.click();
findOnPage("<title>CWS - Deployments</title>");
findOnPage("CWS - Deployments");

// Wait for Finish
sleep(180000);
Expand Down Expand Up @@ -228,7 +228,7 @@ public void runHelloWorldTest() {

WebElement tasks = driver.findElement(By.xpath("//a[@href='/camunda/app/tasklist']"));
tasks.click();
findOnPage("<title>Camunda Tasklist</title>");
findOnPage("Camunda Tasklist");

sleep(10000);

Expand All @@ -252,7 +252,7 @@ public void runHelloWorldTest() {
// Go back to CWS
WebElement cws = driver.findElement(By.xpath("//a[@href='/cws-ui']"));
cws.click();
findOnPage("<title>CWS - Deployments</title>");
findOnPage("CWS - Deployments");

// Wait for Finish
sleep(90000);
Expand Down
Loading