Skip to content

Commit 2a53a7f

Browse files
Adds explicit dashboard config in workflow
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
1 parent 4ac3ec4 commit 2a53a7f

File tree

1 file changed

+53
-16
lines changed

1 file changed

+53
-16
lines changed

.github/workflows/cypress-test-resource-sharing-enabled-e2e.yml

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,33 @@ jobs:
4949
shell: bash
5050
run: |
5151
set -euo pipefail
52-
53-
# Shallow clone at main
54-
git clone --depth 1 https://github.com/opensearch-project/security.git security-src
52+
OSV="${OPENSEARCH_VERSION}"
53+
# Map 3.2.0[-anything] -> 3.2
54+
SEC_REF="$(echo "$OSV" | sed -E 's/^([0-9]+)\.([0-9]+).*/\1.\2/')"
55+
echo "Derived security repo ref: $SEC_REF (from $OSV)"
56+
57+
# Prefer branch/tag = X.Y; fall back to main if not found
58+
if git ls-remote --exit-code --heads https://github.com/opensearch-project/security.git "$SEC_REF" >/dev/null 2>&1 \
59+
|| git ls-remote --exit-code --tags https://github.com/opensearch-project/security.git "$SEC_REF" >/dev/null 2>&1; then
60+
REF="$SEC_REF"
61+
else
62+
echo "Ref $SEC_REF not found; falling back to main"
63+
REF="main"
64+
fi
65+
66+
git clone --depth 1 --branch "$REF" https://github.com/opensearch-project/security.git security-src
5567
5668
pushd security-src
57-
# Build the sample plugin from the repo root
5869
chmod +x ./gradlew
70+
# Build the sample resource plugin
5971
./gradlew :opensearch-sample-resource-plugin:assemble
60-
61-
# Pick the built zip
6272
ZIP_PATH=$(ls -t sample-resource-plugin/build/distributions/*.zip | head -n1)
6373
echo "Built sample plugin: $ZIP_PATH"
64-
65-
# Copy to workspace for installation
6674
cp "$ZIP_PATH" "$GITHUB_WORKSPACE/sample-resource-plugin.zip"
6775
popd
6876
77+
echo "SAMPLE_PLUGIN_ZIP=$GITHUB_WORKSPACE/opensearch-sample-resource-plugin.zip" >> "$GITHUB_ENV"
6978
70-
echo "SAMPLE_PLUGIN_ZIP=$GITHUB_WORKSPACE/sample-resource-plugin.zip" >> $GITHUB_ENV
7179
7280
- name: Run Opensearch with security + sample resource plugin
7381
uses: derek-ho/start-opensearch@v8
@@ -96,6 +104,29 @@ jobs:
96104
shell: bash
97105
working-directory: OpenSearch-Dashboards
98106

107+
- name: Create OpenSearch Dashboards Config
108+
if: ${{ runner.os == 'Linux' }}
109+
run: |
110+
cat << 'EOT' > resource_sharing_config.yml
111+
server.host: "localhost"
112+
opensearch.hosts: ["https://localhost:9200"]
113+
opensearch.ssl.verificationMode: none
114+
opensearch.username: "kibanaserver"
115+
opensearch.password: "kibanaserver"
116+
opensearch.requestHeadersWhitelist: [ authorization,securitytenant ]
117+
opensearch_security.multitenancy.enabled: true
118+
opensearch_security.multitenancy.tenants.preferred: ["Private", "Global"]
119+
opensearch_security.readonly_mode.roles: ["kibana_read_only"]
120+
opensearch_security.cookie.secure: false
121+
home.disableWelcomeScreen: true
122+
EOT
123+
shell: bash
124+
125+
- name: Replace opensearch_dashboards.yml
126+
run: |
127+
mv resource_sharing_config.yml $GITHUB_WORKSPACE/OpenSearch-Dashboards/config/opensearch_dashboards.yml
128+
shell: bash
129+
99130
- name: Run OpenSearch Dashboards
100131
run: |
101132
nohup yarn start --no-base-path --no-watch --csp.warnLegacyBrowsers=false | tee dashboard.log &
@@ -112,21 +143,27 @@ jobs:
112143
OSD_PASS: ${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }}
113144
run: |
114145
set -euo pipefail
115-
TIMEOUT=300; INTERVAL=5; end=$((SECONDS + TIMEOUT))
116-
code=""; resp=""
146+
TIMEOUT=300
147+
INTERVAL=5
148+
end=$((SECONDS + TIMEOUT))
117149
150+
echo "Waiting up to ${TIMEOUT}s for ${OSD_URL}/api/status ..."
118151
while (( SECONDS < end )); do
119-
resp="$(curl -s -k -u "${OSD_USER}:${OSD_PASS}" -H 'kbn-xsrf: true' "${OSD_URL}/api/status" || echo "")"
120-
code="$(curl -s -k -o /dev/null -w '%{http_code}' -u "${OSD_USER}:${OSD_PASS}" -H 'kbn-xsrf: true' "${OSD_URL}/api/status" || echo "")"
121-
122-
if [ "${code:-}" = "200" ] && echo "${resp:-}" | grep -Eiq '"(overall|status)".*"(available|green)"'; then
123-
echo "OpenSearch Dashboards status is green."
152+
out="$(curl -s -k -u "${OSD_USER}:${OSD_PASS}" -H 'kbn-xsrf: true' \
153+
-w 'HTTPSTATUS:%{http_code}' "${OSD_URL}/api/status" || true)"
154+
code="${out##*HTTPSTATUS:}"
155+
body="${out%HTTPSTATUS:*}"
156+
157+
# Ready when HTTP 200 AND overall.state === "green"
158+
if [ "${code:-}" = "200" ] && printf '%s' "${body:-}" | grep -Eiq '"state"[[:space:]]*:[[:space:]]*"green"'; then
159+
echo "OpenSearch Dashboards status is green (HTTP ${code})."
124160
exit 0
125161
fi
126162
sleep "${INTERVAL}"
127163
done
128164
129165
echo "Timed out after ${TIMEOUT}s waiting for OpenSearch Dashboards status."
166+
echo "Last 200 lines of dashboard.log:"
130167
tail -n 200 dashboard.log || true
131168
exit 1
132169

0 commit comments

Comments
 (0)