-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DBACLD-72801 - Add a script to validate an ODM instance (#323)
* First version of the script * Factorize curl request * Create functions * Create main function * Add usage and parameters * Fix parse_args function * Add test of Loan Validation ruleset * Clean script * Improve curlRequest to accept json filename * Improve script to manage url with spaces * Add OpenId support * Add error catching for getDeploymentIds function * Remove trailing slash * USe DSR to test ruleset and add response payload validation * Fix waiting for test completion * Handle errors in curlRequest function * Add error function * Handle errors in setDecisionServiceId function * Handle errors in runTestSuite function * Handle errors in getDeploymentIds function * Handle errors in deployRuleApp function * Handle errors in verifyRuleApp function * Handle errors in testRuleSet function * Log sucess uin green in terminal * Add default value for error code return * Use configuration file to get script parameters * Add a config file template * Add json test definition and expected response * Add timeout for while loop * Refactor to deploy and verify in one loop * Add optional clean at the end of the script * Add README and fix typos * Improve function to get deployment information and create a clean function * Add ruleapp version * Improve functions to get and use decision service id * Improve doc * Improve script name * Fix format for openId URL variable * Download Loan_Validation_Service.zip file if it does not exist locally * Do not ask for cleaning at the end of the script * Move script to validate odm in contrib folder * Improve verification of ruleApp deployment * Test if zip file is valid * Simplify by removing -f option and using .env file or environment variables * Fix error hadnling when import in DC fails * Improve error handling * Improve logs * Improve script documentation * Add image for article * Improve README and reorganize folder * Improve README * Fix error handling when import fail * Fix wait for test * Add spinner when waiting for longer steps * Fix error handling when testing ruleApp deployment * Fix syntaxe and typos after first review
- Loading branch information
1 parent
77aad82
commit aa286ac
Showing
7 changed files
with
728 additions
and
0 deletions.
There are no files selected for viewing
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,9 @@ | ||
## ODM Components URLs | ||
DC_URL=<DC_URL> | ||
RES_URL=<RES_URL> | ||
DSR_URL=<DSR_URL> | ||
## Basic Authentication | ||
ODM_CREDS=<user>:<password> | ||
## OpenID Authentication | ||
# ODM_CREDS=<clientId>:<clientSecret> | ||
# OPENID_URL=<openIdUrl> |
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,94 @@ | ||
# validate-odm.sh | ||
|
||
The script [validate-odm.sh](./validate-odm.sh) can be used to validate the installation of ODM. | ||
|
||
![Script Logs](images/script-logs.gif) | ||
|
||
The script performs the following scenario: | ||
1. Import a decision service | ||
2. Run a test suite | ||
3. Deploy the RuleApps | ||
4. Verify the RuleApps in RES | ||
5. Execute a RuleApp in DSR | ||
6. [Optional] Delete the RuleApps in RES | ||
|
||
## Prerequisites | ||
|
||
- Start ODM components. | ||
You can use ODM docker images, ODM on K8S chart or and ODM instance deployed with the CP4BA operator. | ||
- Take a note of the endpoints of your components: | ||
- Decision Center (DC) | ||
- Decision Server Console (RES) | ||
- Decision Server Runtime (DSR) components | ||
- Set the required environment variables manually or use a `.env` file. | ||
Refer to [Environment Variables](#Environment-Variables) for more information. | ||
|
||
## Usage | ||
|
||
``` | ||
./validate-odm.sh [-c] [-h] | ||
``` | ||
|
||
Optional script parameters: | ||
- `-c` : Cleans the created ruleApps at the end of the test. | ||
- `-h` : Displays the help page. | ||
|
||
### Environment Variables | ||
|
||
The script configuration file requires the following environment variables to be defined manually or in a `.env` file: | ||
|
||
* **ODM endpoints configuration** | ||
- `DC_URL` : URL of the Decision Center instance to test. | ||
- `RES_URL` : URL of the Decision Server Console (RES) instance to test. | ||
- `DSR_URL` : URL of the Decision Server Runtime instance to test. | ||
|
||
* **Authentication configuration** | ||
- To use *basic* authentication mode, define: | ||
- `ODM_CREDS` : Credentials to connect to ODM using the format `<user>:<password>` | ||
- To use *openID* authentication mode, define: | ||
- `ODM_CREDS` : Credentials to get the token using the format `<clientId>:<clientSecret>` | ||
- `OPENID_URL` : URL of the OpenId Server | ||
|
||
> **Note** | ||
> You can fill the provided [.env.template](./.env.template) file with your configuration: | ||
> ``` | ||
> $ mv .env.template .env | ||
> $ vi .env | ||
> ``` | ||
## Examples | ||
* To validate an ODM instance described in the `.env` file and clean at the end of the test: | ||
``` | ||
$ ./validate-odm.sh -c | ||
📥 Upload Decision Service to DC: COMPLETED | ||
🧪 Running Main Scoring test suite in DC ... | ||
▪ Wait for Main Scoring test suite to be completed in DC: DONE | ||
▪ Test report status in DC: SUCCEEDED | ||
🚀 Deploy RuleApp test_deployment/1.0 to DC: COMPLETED | ||
🔎 Verifying test_deployment RuleApp deployment ... | ||
▪ Get RuleApp test_deployment/1.0 in RES: DONE | ||
▪ Verify last RuleSet deployed test_deployment/1.0/loan_validation_production/1.0 in RES: SUCCEEDED | ||
▪ Verify last RuleSet deployed test_deployment/1.0/loan_validation_with_score_and_grade/1.0 in RES: SUCCEEDED | ||
🚀 Deploy RuleApp production_deployment/1.0 to DC: COMPLETED | ||
🔎 Verifying test_deployment RuleApp deployment ... | ||
▪ Get RuleApp production_deployment/1.0 in RES: DONE | ||
▪ Verify last RuleSet deployed production_deployment/1.0/loan_validation_production/1.0 in RES: SUCCEEDED | ||
🧪 Running RuleSet test ... | ||
▪ Test RuleSet production_deployment/1.0/loan_validation_production/1.0 in DSR: COMPLETED | ||
▪ Check RuleSet test result in DSR: SUCCEEDED | ||
🗑️ Cleaning ... | ||
▪ Delete RuleApp test_deployment/1.0 in RES: DONE | ||
▪ Delete RuleApp production_deployment/1.0 in RES: DONE | ||
🎉 ODM has been successfully validated! | ||
``` | ||
* To validate an ODM instance using basic authentication and setting environment variables manually: | ||
``` | ||
$ export DC_URL=https://<clusterip>:<dc-port> | ||
$ export RES_URL=https://<clusterip>:<res-port> | ||
$ export DSR_URL=https://<clusterip>:<dsr-port> | ||
$ export ODM_CREDS=<user>:<password> | ||
|
||
$ ./validate-odm.sh | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions
40
contrib/validate-odm/test-ruleset/loan_validation_test.json
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,40 @@ | ||
{ | ||
"loan": { | ||
"numberOfMonthlyPayments": 3, | ||
"startDate": "2006-08-19T19:27:14.000+0200", | ||
"amount": 3, | ||
"loanToValue": 10517320 | ||
}, | ||
"__DecisionID__": "string", | ||
"borrower": { | ||
"firstName": "string", | ||
"lastName": "string", | ||
"birth": "2008-09-29T03:49:45.000+0200", | ||
"SSN": { | ||
"areaNumber": "string", | ||
"groupCode": "string", | ||
"serialNumber": "string" | ||
}, | ||
"yearlyIncome": 3, | ||
"zipCode": "string", | ||
"creditScore": 3, | ||
"spouse": { | ||
"birth": "2022-12-08T15:13:09.850+0100", | ||
"SSN": { | ||
"areaNumber": "", | ||
"groupCode": "", | ||
"serialNumber": "" | ||
}, | ||
"yearlyIncome": 0, | ||
"creditScore": 0, | ||
"latestBankruptcy": { | ||
"chapter": 0 | ||
} | ||
}, | ||
"latestBankruptcy": { | ||
"date": "2014-09-19T01:18:33.000+0200", | ||
"chapter": 3, | ||
"reason": "string" | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
contrib/validate-odm/test-ruleset/loan_validation_test_response.json
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,52 @@ | ||
{ | ||
"report": { | ||
"borrower": { | ||
"firstName": "string", | ||
"lastName": "string", | ||
"birth": "2008-09-29T01:49:45.000+0000", | ||
"SSN": { | ||
"areaNumber": "string", | ||
"groupCode": "string", | ||
"serialNumber": "string" | ||
}, | ||
"yearlyIncome": 3, | ||
"zipCode": "string", | ||
"creditScore": 3, | ||
"spouse": { | ||
"birth": "2022-12-08T14:13:09.850+0000", | ||
"SSN": { | ||
"areaNumber": "", | ||
"groupCode": "", | ||
"serialNumber": "" | ||
}, | ||
"yearlyIncome": 0, | ||
"creditScore": 0, | ||
"latestBankruptcy": { | ||
"chapter": 0 | ||
} | ||
}, | ||
"latestBankruptcy": { | ||
"date": "2014-09-18T23:18:33.000+0000", | ||
"chapter": 3, | ||
"reason": "string" | ||
} | ||
}, | ||
"loan": { | ||
"numberOfMonthlyPayments": 3, | ||
"startDate": "2006-08-19T17:27:14.000+0000", | ||
"amount": 3, | ||
"loanToValue": 1.051732E7 | ||
}, | ||
"validData": true, | ||
"insuranceRequired": true, | ||
"insuranceRate": 0.02, | ||
"approved": true, | ||
"messages": [], | ||
"yearlyInterestRate": 0.0, | ||
"monthlyRepayment": 0.0, | ||
"insurance": "2%", | ||
"message": "", | ||
"yearlyRepayment": 0.0 | ||
}, | ||
"__DecisionID__": "string" | ||
} |
Oops, something went wrong.