Skip to content

Latest commit

 

History

History
100 lines (89 loc) · 4.28 KB

templates-readme.md

File metadata and controls

100 lines (89 loc) · 4.28 KB

Azure Pipeline Test

This is Azure pipeline test created for sap-hana/deploy

Table of contents

Supported Scenarios

  1. allNew-SN: create all resources from scratch for single node
  2. allNew-HA: create all resources from scratch for HA pair
  3. reuseRG-SN: use existing resource group (generated inside the job) for single node
  4. reuseVNET-SN: use existing vnet (management generated from allNew) for single node
  5. reuseNSG-SN: use existing NSG (nsg geneareted from allNew) for single node

Design

pipeline_workflow

  • All PRs against master and include code change in sap-hana/deploy will trigger this pipeline test.
  • Each scenario will create a testcase with name that contains name of the testcase, os version and buildId, eg. sap-allNew-SN-SLES12-289.
  • Each testcase will create resources under it's own resource group, which has the same name as the testcase, eg. resource group sap-allNew-SN-SLES12-289.
  • Terraform will run with varible file generated during the test, which has name as the testcase as well, eg. sap-allNew-SN-SLES12-289.json
  • After the deployment is done (successful/fail), cleanup job will delete the resource group

Add New Scenario

1. Maintain custom JSON

  • create a custom json under templates/tempGen/<scenario>.json
    • the json need to include key(s) that will be customized for this scenario
    • for values that requires to be replaced, please put a different placeholder for each one:
      • for name of resource group, replace with var-rg-name
      • for arm id of the reuse reousrce, replace with <reuse resource name>-arm-id
      • sample:
      {
        "infrastructure" : {
                "resource_group" : {
                        "is_existing" : "true",
                        "name" : "var-rg-name",
                        "arm_id" : "rg-arm-id"
                }
        }
      }

2. Maintain templates/job-template-per-os.yaml

  • create a new job under jobs
  • define the scenario by setting variable scenario
  • in script section, add necessary step(s) to retrieve the value(s) for placeholder(s) (eg. using az cli)
  • use templates/test-case-template-update.yaml as many times as needed to replace the above values into templates/tempGen/<scenario>.json
  • sample:
    - job: reuseRG${{parameters.osVersion}}
      variables:
        scenario: sap-reuseRG
        testcase: $(scenario)-${{parameters.osVersion}}-$(Build.BuildId)
      steps:
      - script: |
          az login --service-principal --user $(hana-pipeline-spn-id) --password  $(hana-pipeline-spn-pw) --tenant $(landscape-tenant) --output none
          az group create --location eastus -n $(testcase)
          echo '##vso[task.setvariable variable=arm_id]$(az group show --name $(testcase) --query id --output tsv)'
      - template: test-case-template-update.yaml
        parameters:
          scenario: $(scenario)
          testCaseName: $(testcase)
          placeHolder: var-rg-name
          value: $(testcase)
      - template: test-case-template-update.yaml
        parameters:
          scenario: $(scenario)
          testCaseName: $(testcase)
          placeHolder: rg-arm-id
          value: $(arm_id)
      - template: terraform-deployment-steps.yaml
        parameters:
          testCaseName: $(testcase)
          osImage: ${{parameters.osImage}}
      - template: ansible-deployment-steps.yaml
        parameters:
          testCaseName: $(testcase)
  • add the new scenario to stage: DestroyingResources -> job: cleanUp -> varible scenario_list.

Add new OS verification

1. Maintain azure-pipeline.yaml

  • create a new job with template under jobs with osVersion and string for osImage
  • sample:
    - template: templates/job-template-per-os.yaml
      parameters:
        osVersion: "SLES12"
        osImage: '\"offer\": \"sles-sap-12-sp5\", 
                  \"publisher\": \"SUSE\", 
                  \"sku\": \"gen1\"'
  • add the new OS into os_list under stage: DestroyingResources -> job: cleanUp -> varible os_list.