-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1473 from daizhenyu/develop-database-write-prohib…
…ition-integration database write prohibition integration: mongodb and mysql action
- Loading branch information
Showing
9 changed files
with
230 additions
and
31 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
.github/actions/scenarios/database-write-prohibition/mongodb/action.yml
This file contains 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,58 @@ | ||
name: "Database Write Prohibition Plugin MongoDB Test" | ||
description: "Auto test for mongodb write prohibition" | ||
runs: | ||
using: composite | ||
steps: | ||
- name: entry | ||
uses: ./.github/actions/common/entry | ||
with: | ||
log-dir: ./logs/databse-write-prohibition/mongodb | ||
- name: start mongodb | ||
shell: bash | ||
run: | | ||
sudo apt-get install gnupg curl | ||
curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \ | ||
sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \ | ||
--dearmor | ||
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list | ||
sudo apt-get update | ||
sudo apt-get install -y mongodb-org | ||
sudo systemctl start mongod | ||
sudo systemctl status mongod | ||
nohup mongo test & | ||
- name: package demos | ||
shell: bash | ||
run: | | ||
mvn package -Dmongodb.version=${{ matrix.mongodbClientVersion }} -DskipTests -Pmongodb-test --file \ | ||
sermant-integration-tests/database-write-prohibition-test/pom.xml | ||
- name: start mongodb demo | ||
shell: bash | ||
run: | | ||
nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar -jar \ | ||
-Dsermant_log_dir=${{ env.logDir }}/mongodb \ | ||
sermant-integration-tests/database-write-prohibition-test/mongodb-demo/target/mongodb-demo.jar > ${{ env.logDir }}/mongodb.log 2>&1 & | ||
- name: waiting for services start | ||
shell: bash | ||
run: | | ||
ps -ef | grep java | ||
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:9098/checkStatus 120 | ||
- name: test mongodb | ||
shell: bash | ||
run: | | ||
mvn test -Ddatabase.write.prohibition.integration.test.type=MONGODB --file \ | ||
sermant-integration-tests/database-write-prohibition-test/database-write-prohibition-integration-test/pom.xml | ||
- name: exit | ||
if: always() | ||
uses: ./.github/actions/common/exit | ||
with: | ||
processor-keyword: mongo | ||
- name: if failure then upload error log | ||
uses: actions/upload-artifact@v3 | ||
if: ${{ failure() || cancelled() }} | ||
with: | ||
name: (${{ github.job }})-database-write-prohibition-mongodb-(${{ matrix.mongodbClientVersion }})-logs | ||
path: | | ||
./*.log | ||
./logs/** | ||
if-no-files-found: warn | ||
retention-days: 2 |
56 changes: 56 additions & 0 deletions
56
.github/actions/scenarios/database-write-prohibition/mysql/action.yml
This file contains 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,56 @@ | ||
name: "Database Write Prohibition Plugin MySQL Test" | ||
description: "Auto test for mysql write prohibition" | ||
runs: | ||
using: composite | ||
steps: | ||
- name: entry | ||
uses: ./.github/actions/common/entry | ||
with: | ||
log-dir: ./logs/databse-write-prohibition/mysql | ||
- name: start mysql | ||
shell: bash | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y mysql-server | ||
sudo systemctl start mysql.service | ||
user=$(sudo awk -F '=' '/user/ {print $2; exit}' "/etc/mysql/debian.cnf" | tr -d '[:space:]') | ||
password=$(sudo awk -F '=' '/password/ {print $2; exit}' "/etc/mysql/debian.cnf" | tr -d '[:space:]') | ||
sudo mysql -u $user -p$password -e "CREATE DATABASE IF NOT EXISTS test;" | ||
echo "MYSQL_USER=$user" >> $GITHUB_ENV | ||
echo "MYSQL_PASSWORD=$password" >> $GITHUB_ENV | ||
- name: package demos | ||
shell: bash | ||
run: | | ||
mvn package -Dmariadb.version=${{ matrix.mysqlClientVersion }} -DskipTests -Pmysql-test --file \ | ||
sermant-integration-tests/database-write-prohibition-test/pom.xml | ||
- name: start mysql demo | ||
shell: bash | ||
run: | | ||
nohup java -javaagent:sermant-agent-${{ env.sermantVersion }}/agent/sermant-agent.jar -jar \ | ||
-Dsermant_log_dir=${{ env.logDir }}/mysql -Dmysql.user=${{ env.MYSQL_USER }} -Dmysql.password=${{ env.MYSQL_PASSWORD }} \ | ||
sermant-integration-tests/database-write-prohibition-test/mariadb-demo/target/mariadb-demo.jar > ${{ env.logDir }}/mariadb.log 2>&1 & | ||
- name: waiting for services start | ||
shell: bash | ||
run: | | ||
ps -ef | grep java | ||
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:9098/static/checkStatus 120 | ||
- name: test mysql | ||
shell: bash | ||
run: | | ||
mvn test -Ddatabase.write.prohibition.integration.test.type=MARIADB --file \ | ||
sermant-integration-tests/database-write-prohibition-test/database-write-prohibition-integration-test/pom.xml | ||
- name: exit | ||
if: always() | ||
uses: ./.github/actions/common/exit | ||
with: | ||
processor-keyword: mariadb | ||
- name: if failure then upload error log | ||
uses: actions/upload-artifact@v3 | ||
if: ${{ failure() || cancelled() }} | ||
with: | ||
name: (${{ github.job }})-database-write-prohibition-mariadb-(${{ matrix.mysqlClientVersion }})-logs | ||
path: | | ||
./*.log | ||
./logs/** | ||
if-no-files-found: warn | ||
retention-days: 2 |
This file contains 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 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 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 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.