Skip to content

Commit

Permalink
Merge branch 'main' of github.com:derek-ho/start-opensearch into grac…
Browse files Browse the repository at this point in the history
…eful-t
  • Loading branch information
derek-ho committed Mar 27, 2024
2 parents a1be099 + 8ff0865 commit 585fd0e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,25 @@ jobs:
run: curl http://localhost:9200/_cat/plugins -v
shell: bash

test-no-plugins-port-9201:
strategy:
fail-fast: false
matrix:
platform: [windows-latest, ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4

- uses: ./ # Use the action
with:
opensearch-version: 3.0.0
security-enabled: false
port: 9201

- name: Checks that OpenSearch is healthy
run: curl http://localhost:9201/_cat/plugins -v
shell: bash

test-with-security:
strategy:
fail-fast: false
Expand Down
16 changes: 8 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ inputs:
description: 'Path to a security config file to replace the default. Leave empty if security is not enabled or using the default config'
required: false

opensearch_yml_file:
description: 'Path to a opensearch.yml file to replace the default. Leave empty to use the default config'
port:
description: 'Port to run OpenSearch. Leave empty to use the default config (9200)'
required: false

runs:
Expand Down Expand Up @@ -145,9 +145,9 @@ runs:
shell: bash

- name: Replace opensearch.yml file if applicable
if: ${{ inputs.opensearch_yml_file != '' }}
if: ${{ inputs.port != '' }}
run: |
mv ${{ inputs.opensearch_yml_file }} ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/config/opensearch.yml
echo -e "\nhttp.port: ${{ inputs.port }}" >> ./opensearch-${{ inputs.opensearch-version }}-SNAPSHOT/config/opensearch.yml
shell: bash

# Run OpenSearch
Expand All @@ -172,9 +172,9 @@ runs:
if: ${{ runner.os != 'Windows'}}
run: |
if [ "${{ inputs.security-enabled }}" == "true" ]; then
curl https://localhost:9200/_cat/plugins -u 'admin:${{ inputs.admin-password }}' -k -v --fail-with-body
curl https://localhost:${{ inputs.port || 9200 }}/_cat/plugins -u 'admin:${{ inputs.admin-password }}' -k -v --fail-with-body
else
curl http://localhost:9200/_cat/plugins -v
curl http://localhost:${{ inputs.port || 9200 }}/_cat/plugins -v
fi
shell: bash

Expand All @@ -186,10 +186,10 @@ runs:
$encodedCredentials = [Convert]::ToBase64String($credentialBytes)
$baseCredentials = "Basic $encodedCredentials"
$Headers = @{ Authorization = $baseCredentials }
$url = 'https://localhost:9200/_cat/plugins'
$url = 'https://localhost:${{ inputs.port || 9200 }}/_cat/plugins'
} else {
$Headers = @{ }
$url = 'http://localhost:9200/_cat/plugins'
$url = 'http://localhost:${{ inputs.port || 9200 }}/_cat/plugins'
}
Invoke-WebRequest -SkipCertificateCheck -Uri $url -Headers $Headers;
shell: pwsh
Expand Down

0 comments on commit 585fd0e

Please sign in to comment.