|
| 1 | +name: 'Runs the cypress test suite' |
| 2 | +description: 'Re-usable workflow to run cypress tests against a cluster with or without security' |
| 3 | + |
| 4 | +inputs: |
| 5 | + with-security: |
| 6 | + description: 'Whether security should be installed on the cluster the tests are run with' |
| 7 | + required: true |
| 8 | + |
| 9 | +runs: |
| 10 | + using: "composite" |
| 11 | + steps: |
| 12 | + - name: Set up JDK |
| 13 | + uses: actions/setup-java@v1 |
| 14 | + with: |
| 15 | + # TODO: Parse this from index management plugin |
| 16 | + java-version: 21 |
| 17 | + - name: Checkout index management |
| 18 | + uses: actions/checkout@v2 |
| 19 | + with: |
| 20 | + path: index-management |
| 21 | + repository: opensearch-project/index-management |
| 22 | + ref: 'main' |
| 23 | + - name: Run opensearch with plugin |
| 24 | + shell: bash |
| 25 | + if: ${{ inputs.with-security == 'false' }} |
| 26 | + run: | |
| 27 | + cd index-management |
| 28 | + ./gradlew run & |
| 29 | + sleep 300 |
| 30 | + # timeout 300 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9200)" != "200" ]]; do sleep 5; done' |
| 31 | + - name: Run opensearch with plugin |
| 32 | + shell: bash |
| 33 | + if: ${{ inputs.with-security == 'true' }} |
| 34 | + run: | |
| 35 | + cd index-management |
| 36 | + ./gradlew run -Dsecurity=true -Dhttps=true & |
| 37 | + sleep 300 |
| 38 | + # timeout 300 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9200)" != "200" ]]; do sleep 5; done' |
| 39 | + - name: Checkout Index Management Dashboards plugin |
| 40 | + uses: actions/checkout@v2 |
| 41 | + with: |
| 42 | + path: index-management-dashboards-plugin |
| 43 | + - name: Checkout Security Dashboards plugin |
| 44 | + uses: actions/checkout@v2 |
| 45 | + with: |
| 46 | + repository: opensearch-project/security-dashboards-plugin |
| 47 | + path: security-dashboards-plugin |
| 48 | + ref: ${{ env.OPENSEARCH_DASHBOARDS_VERSION }} |
| 49 | + - name: Checkout OpenSearch-Dashboards |
| 50 | + uses: actions/checkout@v2 |
| 51 | + with: |
| 52 | + repository: opensearch-project/OpenSearch-Dashboards |
| 53 | + path: OpenSearch-Dashboards |
| 54 | + ref: ${{ env.OPENSEARCH_DASHBOARDS_VERSION }} |
| 55 | + - name: Setup Node |
| 56 | + uses: actions/setup-node@v3 |
| 57 | + with: |
| 58 | + node-version-file: './OpenSearch-Dashboards/.nvmrc' |
| 59 | + registry-url: 'https://registry.npmjs.org' |
| 60 | + - name: Install Yarn |
| 61 | + # Need to use bash to avoid having a windows/linux specific step |
| 62 | + shell: bash |
| 63 | + run: | |
| 64 | + YARN_VERSION=$(node -p "require('./OpenSearch-Dashboards/package.json').engines.yarn") |
| 65 | + echo "Installing yarn@$YARN_VERSION" |
| 66 | + npm i -g yarn@$YARN_VERSION |
| 67 | + - run: node -v |
| 68 | + shell: bash |
| 69 | + - run: yarn -v |
| 70 | + shell: bash |
| 71 | + - name: Configure OpenSearch Dashboards for cypress |
| 72 | + shell: bash |
| 73 | + if: ${{ inputs.with-security == 'true' }} |
| 74 | + run: | |
| 75 | + cat << 'EOT' > ./OpenSearch-Dashboards/config/opensearch_dashboards.yml |
| 76 | + server.host: "0.0.0.0" |
| 77 | + opensearch.hosts: ["https://localhost:9200"] |
| 78 | + opensearch.ssl.verificationMode: none |
| 79 | + opensearch.username: "kibanaserver" |
| 80 | + opensearch.password: "kibanaserver" |
| 81 | + opensearch.requestHeadersWhitelist: [ authorization,securitytenant ] |
| 82 | + opensearch_security.multitenancy.enabled: true |
| 83 | + opensearch_security.multitenancy.tenants.preferred: ["Private", "Global"] |
| 84 | + opensearch_security.readonly_mode.roles: ["kibana_read_only"] |
| 85 | + opensearch_security.cookie.secure: false |
| 86 | + EOT |
| 87 | + - name: Print Dashboards Config |
| 88 | + shell: bash |
| 89 | + if: ${{ inputs.with-security == 'true' }} |
| 90 | + run: | |
| 91 | + cat ./OpenSearch-Dashboards/config/opensearch_dashboards.yml |
| 92 | + - name: Bootstrap plugin/OpenSearch-Dashboards |
| 93 | + shell: bash |
| 94 | + if: ${{ inputs.with-security == 'false' }} |
| 95 | + run: | |
| 96 | + mkdir -p OpenSearch-Dashboards/plugins |
| 97 | + mv index-management-dashboards-plugin OpenSearch-Dashboards/plugins |
| 98 | + - name: Bootstrap plugin/OpenSearch-Dashboards |
| 99 | + shell: bash |
| 100 | + if: ${{ inputs.with-security == 'true' }} |
| 101 | + run: | |
| 102 | + mkdir -p OpenSearch-Dashboards/plugins |
| 103 | + mv index-management-dashboards-plugin OpenSearch-Dashboards/plugins |
| 104 | + mv security-dashboards-plugin OpenSearch-Dashboards/plugins |
| 105 | + - name: Bootstrap the OpenSearch Dashboard |
| 106 | + uses: nick-fields/retry@v2 |
| 107 | + with: |
| 108 | + timeout_minutes: 20 |
| 109 | + max_attempts: 2 |
| 110 | + command: yarn --cwd OpenSearch-Dashboards osd bootstrap --oss --single-version=loose |
| 111 | + - name: Compile OpenSearch Dashboards |
| 112 | + shell: bash |
| 113 | + run: | |
| 114 | + cd OpenSearch-Dashboards |
| 115 | + node scripts/build_opensearch_dashboards_platform_plugins --no-examples --workers=10 --verbose |
| 116 | + - name: Run OpenSearch-Dashboards server |
| 117 | + shell: bash |
| 118 | + run: | |
| 119 | + cd OpenSearch-Dashboards |
| 120 | + yarn start --no-base-path --no-watch --server.host="0.0.0.0" & |
| 121 | + sleep 30 |
| 122 | + # in main branch, OSD server requires more time to bundle and bootstrap |
| 123 | + # timeout 300 bash -c 'while [[ "$(curl -s localhost:5601/api/status | jq -r '.status.overall.state')" != "green" ]]; do sleep 5; done' |
| 124 | + # for now just chrome, use matrix to do all browsers later |
| 125 | + - name: Cypress tests |
| 126 | + uses: cypress-io/github-action@v2 |
| 127 | + if: ${{ inputs.with-security == 'false' }} |
| 128 | + with: |
| 129 | + working-directory: OpenSearch-Dashboards/plugins/index-management-dashboards-plugin |
| 130 | + command: yarn run cypress run |
| 131 | + wait-on: 'http://localhost:5601' |
| 132 | + browser: chrome |
| 133 | + - name: Cypress tests |
| 134 | + uses: cypress-io/github-action@v2 |
| 135 | + if: ${{ inputs.with-security == 'true' }} |
| 136 | + with: |
| 137 | + working-directory: OpenSearch-Dashboards/plugins/index-management-dashboards-plugin |
| 138 | + command: yarn run cypress run --env SECURITY_ENABLED=true,openSearchUrl=https://localhost:9200,WAIT_FOR_LOADER_BUFFER_MS=500 |
| 139 | + wait-on: 'http://localhost:5601' |
| 140 | + browser: chrome |
| 141 | + # Screenshots are only captured on failure, will change this once we do visual regression tests |
| 142 | + - uses: actions/upload-artifact@v3 |
| 143 | + if: failure() |
| 144 | + with: |
| 145 | + name: cypress-screenshots |
| 146 | + path: OpenSearch-Dashboards/plugins/index-management-dashboards-plugin/cypress/screenshots |
| 147 | + # Test run video was always captured, so this action uses "always()" condition |
| 148 | + - uses: actions/upload-artifact@v3 |
| 149 | + if: always() |
| 150 | + with: |
| 151 | + name: cypress-videos |
| 152 | + path: OpenSearch-Dashboards/plugins/index-management-dashboards-plugin/cypress/videos |
0 commit comments