|
| 1 | +--- |
| 2 | +title: Run tests after install or upgrade operations with Azure Operator Service Manager |
| 3 | +description: Learn about using helm test as poart of a network function install or upgrade. |
| 4 | +author: msftadam |
| 5 | +ms.author: adamdor |
| 6 | +ms.date: 02/19/2024 |
| 7 | +ms.topic: upgrade-and-migration-article |
| 8 | +ms.service: azure-operator-service-manager |
| 9 | +--- |
| 10 | + |
| 11 | +# Run tests after install or upgrade |
| 12 | +This article describes hww Azure Operator Service Manager (AOSM) users can run tests on deployed network functions (NFs) as part install or upgrade operations. When enabledd, each network function application (nfApp) will be tested after completion of the install or upgrade opreation. A successful result of the nfApp test will be required for the NF operation status to report successful. |
| 13 | + |
| 14 | +## Overview |
| 15 | +This feature's scope is to run helm tests as part of the network function install or upgrade operations. |
| 16 | +* Users will author their own tests and include within helm package during NF onboarding. |
| 17 | +* Only where enabled, AOSM will execute these helm tests on each nfApp. |
| 18 | +* Upon test success, AOSM will proceed to the next nfApp. |
| 19 | +* Upon test failure, AOSM will honor `RollbackOnTestFail` flag to determine if the nfApp will be rolled back. |
| 20 | +* The parent NF operation will terminate with failure if any nfApp fails a user configured test. |
| 21 | +* Upon parent failure, AOSM will honor the configured method of NF failure control, either `pause-on-failure` or `rollback-on-failure`. |
| 22 | + |
| 23 | +> [!NOTE] |
| 24 | +> * Helm Test is only supported as part of the install/upgrade operation and cannot be run separately. |
| 25 | +
|
| 26 | +## Authoring helm tests |
| 27 | +Helm tests are authored by the owner of the helm charts. The helm tests are defined in the helm chart under the folder: `<ChartName>/Templates/`. Each test includes a job definition that specifies a container environment and command to run. The container environment should exit successfully for a test to be considered a success. The job definition must include the Helm test hook annotation `(helm.sh/hook: test)` to be recognized as a test by Helm. |
| 28 | + |
| 29 | +## Enable helm tests during operations |
| 30 | +AOSM provides a set of configurable install and upgrade options for each component under a NF. These existing options are extended with a new configurable 'TestOptions` parameter. This will give the uses the ability to specify TestOptions per nfApp and as per the type of operation. Following are the parameters available under the TestOptions bag: |
| 31 | + |
| 32 | +* enable |
| 33 | + * This is a bool flag that will enable/disable helm test on a component after install/upgrade. |
| 34 | + * Default value is false. |
| 35 | +* timeout |
| 36 | + * This parameter takes an int that represents test timeout in minutes. |
| 37 | + * Default value is 20 minutes. |
| 38 | +* rollbackOnTestFailure |
| 39 | + * This is a bool flag that will enable/disable component rollback on helm test failure. |
| 40 | + * Default value is true. |
| 41 | +* filter |
| 42 | + * This is a list of strings and each string in the list represents a test name. This parameter will allow users to run a subset of defined tests in the chart |
| 43 | + * No filter is applied by default. |
| 44 | + |
| 45 | +## Exposing helm test control via parameters |
| 46 | +Users already can use `RoleOverrideValues` parameter in a NF payload to specify `InstallOptions` and `UpgradeOptions`. Now the `InstallOptions` and `UpgradeOptions` will be extended to hold `TestOptions`. Thus, `TestOptions` can be specified for each component under a NF and each method of operation. Following is an example of roleOverrideValues to be specified in the NF Payload to specify InstallOptions (inlcuding TestOptions) and UpgradeOptions (including TestOptions) for a component named: application1- |
| 47 | + |
| 48 | +``` |
| 49 | +"roleOverrideValues": [ |
| 50 | + "{\"name\":\"application1\",\"deployParametersMappingRuleProfile\":{\"helmMappingRuleProfile\":{\"helmPackageVersion\":\"2.1.3\",\"values\":\"{\\\"roleOneParam\\\":\\\"roleOneOverrideValue\\\"}\",\"options\":{\"installOptions\":{\"atomic\":\”true\”,\"wait\":\"true\",\"timeout\":\"30m\",\” testOptions \”:{\” enable \”:\”true\”,\” timeout\”:\”15\”,\”rollbackOnTestFailure\”:\”true\”,\” filter \”:[\”test1\”,\”test2\”,\”test3\”]}},\"upgradeOptions\":{\"atomic\": \”true\”,\"wait\":\"true\",\"timeout\":\"30\", \” testOptions \”:{\” enable \”:\”true\”,\” timeout\”:\”15\”,\”rollbackOnTestFailure\”:\”true\”,\” filter \”:[\”test1\”,\”test2\”,\”test3\”]}}}}}}" |
| 51 | + ] |
| 52 | +``` |
| 53 | + |
| 54 | +``` |
| 55 | +Uescaped Version: |
| 56 | +"roleOverrideValues": [ |
| 57 | + "{"name":"hellotest", |
| 58 | +"deployParametersMappingRuleProfile": |
| 59 | +{"helmMappingRuleProfile": |
| 60 | +{ |
| 61 | +"options": |
| 62 | +{ |
| 63 | +"installOptions": |
| 64 | +{ |
| 65 | +"atomic":"true", |
| 66 | +"wait":"true", |
| 67 | +"timeout":"1" |
| 68 | +“testOptions”: |
| 69 | +{ |
| 70 | +“enable”: “true”, |
| 71 | +“timeout”: “10”, |
| 72 | +“rollbackOnTestFailure”: “true”, |
| 73 | +"filter”: [“test1”, “test2”] |
| 74 | +} |
| 75 | +}, |
| 76 | +"upgradeOptions": |
| 77 | +{ |
| 78 | +"atomic":"true", |
| 79 | +"wait":"true", |
| 80 | +"timeout":"2", |
| 81 | +“testOptions”: |
| 82 | +{ |
| 83 | +“enable”: “true”, |
| 84 | +“timeout”: “10”, |
| 85 | +“rollbackOnTestFailure”: “true”, |
| 86 | +"filter”: [“test1”, “test2”] |
| 87 | +} } } } } }" ] |
| 88 | +``` |
| 89 | +## Example of TestOptions usage |
| 90 | +Following is an example NF Payload with TestOptions under InstallOptions and UpgradeOptions for a component named: application1 |
| 91 | + |
| 92 | +``` |
| 93 | +{ |
| 94 | + "location": "eastus", |
| 95 | + "properties": { |
| 96 | + "publisherName": "testVendor", |
| 97 | + "publisherScope": "Public", |
| 98 | + "networkFunctionDefinitionGroupName": "testnetworkFunctionDefinitionGroupName", |
| 99 | + "networkFunctionDefinitionVersion": "1.0.1", |
| 100 | + "networkFunctionDefinitionOfferingLocation": "eastus", |
| 101 | + "nfviType": "AzureArcKubernetes", |
| 102 | + "nfviId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testResourceGroup/providers/Microsoft.ExtendedLocation/customLocations/testCustomLocation", |
| 103 | + "allowSoftwareUpdate": true, |
| 104 | + "deploymentValues": "{\"releaseName\":\"testReleaseName\",\"namespace\":\"testNamespace\",\"wait\":\"false\"}", |
| 105 | + "roleOverrideValues": [ |
| 106 | + "{\"name\":\"application1\",\"deployParametersMappingRuleProfile\":{\"helmMappingRuleProfile\":{\"helmPackageVersion\":\"2.1.3\",\"values\":\"{\\\"roleOneParam\\\":\\\"roleOneOverrideValue\\\"}\",\"options\":{\"installOptions\":{\"atomic\":\”true\”,\"wait\":\"true\",\"timeout\":\"30m\",\” testOptions \”:{\” enable \”:\”true\”,\” timeout\”:\”15\”,\”rollbackOnTestFailure\”:\”true\”,\” filter \”:[\”test1\”,\”test2\”,\”test3\”]}},\"upgradeOptions\":{\"atomic\": \”true\”,\"wait\":\"true\",\"timeout\":\"30\", \” testOptions \”:{\” enable \”:\”true\”,\” timeout\”:\”15\”,\”rollbackOnTestFailure\”:\”true\”,\” filter \”:[\”test1\”,\”test2\”,\”test3\”]}}}}}}" |
| 107 | + ] |
| 108 | + } |
| 109 | +} |
| 110 | +``` |
0 commit comments