Compare commits

...

36 Commits

Author SHA1 Message Date
Harsh Jha
8140cf94ca Merge branch 'sample-testing-strategy-js-sh' of https://github.com/googleapis/genai-toolbox into sample-testing-strategy-js-poc 2025-09-23 17:46:44 +05:30
Harsh Jha
2c0a0d0083 chore: removed deps.json 2025-09-23 17:44:49 +05:30
Harsh Jha
f5d3edeb45 Merge branch 'main' into sample-testing-strategy-js-sh 2025-09-23 17:40:25 +05:30
Anmol Shukla
98bd8cc4c7 Merge branch 'main' into sample-testing-strategy-js-sh 2025-09-23 13:52:42 +05:30
Anmol Shukla
c9a396d0e0 Merge branch 'main' into sample-testing-strategy-js-sh 2025-09-22 11:51:41 +05:30
Anmol Shukla
298485fd95 Merge branch 'main' into sample-testing-strategy-js-sh 2025-09-18 15:30:29 +05:30
Anmol Shukla
dd3d52eec0 Merge branch 'main' into sample-testing-strategy-js-sh 2025-09-18 15:14:00 +05:30
Anmol Shukla
3e794bea08 Merge branch 'main' into sample-testing-strategy-js-sh 2025-09-18 14:15:28 +05:30
Harsh Jha
ecdc52f847 Merge branch 'main' into sample-testing-strategy-js-sh 2025-09-18 12:39:27 +05:30
Anmol Shukla
eca1599264 Merge branch 'main' into sample-testing-strategy-js-sh 2025-09-18 12:29:20 +05:30
Harsh Jha
0f35761792 chore: modified test function 2025-09-17 16:40:36 +05:30
Harsh Jha
89d3b10749 chore: revamp test function 2025-09-17 16:36:37 +05:30
Harsh Jha
9ac0138a15 chore: changes for testing ci 2025-09-17 16:31:57 +05:30
Harsh Jha
7a3d05d7df chore: revamp test function 2025-09-17 16:27:14 +05:30
Harsh Jha
54f67fd6c9 chore: fix variable name 2025-09-17 16:04:12 +05:30
Harsh Jha
0d5831af81 chore: testing ci pipeline 2025-09-17 15:54:19 +05:30
Harsh Jha
54e1db46d7 added: ci files 2025-09-17 15:41:23 +05:30
Harsh Jha
269f247f2b fix: file name in ci file 2025-09-17 15:29:54 +05:30
Harsh Jha
5c4cc4d70c fix: ci script for js testing 2025-09-17 15:29:54 +05:30
AnmolShukla2002
e22d24dd34 chore(ci): testing script for JS 2025-09-17 15:29:54 +05:30
Anmol Shukla
4c27279f47 Merge branch 'main' into sample-testing-strategy-js-test 2025-09-17 14:55:02 +05:30
Anmol Shukla
0993284d6f Merge branch 'main' into sample-testing-strategy-js-test 2025-09-17 13:35:59 +05:30
Anmol Shukla
115e63be09 Merge branch 'main' into sample-testing-strategy-js-test 2025-09-16 14:29:41 +05:30
Anmol Shukla
c692d29401 Merge branch 'main' into sample-testing-strategy-js-test 2025-09-15 22:17:23 +05:30
Anmol Shukla
8bd4fda931 Merge branch 'main' into sample-testing-strategy-js-test 2025-09-15 16:55:12 +05:30
Anmol Shukla
f77376b96d Merge branch 'main' into sample-testing-strategy-js-test 2025-09-15 11:24:27 +05:30
Anmol Shukla
b1746f7ff6 Merge branch 'main' into sample-testing-strategy-js-test 2025-09-12 16:51:02 +05:30
Anmol Shukla
1564237eda Merge branch 'main' into sample-testing-strategy-js-test 2025-09-12 15:49:08 +05:30
AnmolShukla2002
7745962f7a rename test in test script 2025-09-11 12:52:33 +05:30
Anmol Shukla
98af650bb2 Merge branch 'main' into sample-testing-strategy-js-test 2025-09-11 10:57:52 +05:30
Anmol Shukla
c725036bb1 Merge branch 'main' into sample-testing-strategy-js-test 2025-09-11 00:16:53 +05:30
AnmolShukla2002
493c41dec4 chore(testing): update test script path 2025-09-10 12:35:47 +05:30
Anmol Shukla
97ea33ffe0 Merge branch 'main' into sample-testing-strategy-js-test 2025-09-10 12:25:40 +05:30
Anmol Shukla
10f346b14b Merge branch 'main' into sample-testing-strategy-js-test 2025-09-10 11:48:48 +05:30
Harsh Jha
2c0eadee88 Merge branch 'main' into sample-testing-strategy-js-test 2025-09-10 01:59:35 +05:30
AnmolShukla2002
058d11d35f chore(testing): testcases for JS 2025-09-08 12:26:42 +05:30
3 changed files with 175 additions and 1 deletions

View File

@@ -0,0 +1,47 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
steps:
- name: 'node:20'
id: 'js-quickstart-test'
entrypoint: 'bash'
args:
# The '-c' flag tells bash to execute the following string as a command.
# The 'set -ex' enables debug output and exits on error for easier troubleshooting.
- -c
- |
set -ex
export VERSION=$(cat ./cmd/version.txt)
chmod +x .ci/quickstart_test/run_js_tests.sh
.ci/quickstart_test/run_js_tests.sh
env:
- 'CLOUD_SQL_INSTANCE=${_CLOUD_SQL_INSTANCE}'
- 'GCP_PROJECT=${_GCP_PROJECT}'
- 'DATABASE_NAME=${_DATABASE_NAME}'
- 'DB_USER=${_DB_USER}'
secretEnv: ['TOOLS_YAML_CONTENT', 'GOOGLE_API_KEY', 'DB_PASSWORD']
availableSecrets:
secretManager:
- versionName: projects/${_GCP_PROJECT}/secrets/${_TOOLS_YAML_SECRET}/versions/6
env: 'TOOLS_YAML_CONTENT'
- versionName: projects/${_GCP_PROJECT_NUMBER}/secrets/${_API_KEY_SECRET}/versions/latest
env: 'GOOGLE_API_KEY'
- versionName: projects/${_GCP_PROJECT}/secrets/${_DB_PASS_SECRET}/versions/latest
env: 'DB_PASSWORD'
timeout: 1000s
options:
logging: CLOUD_LOGGING_ONLY

View File

@@ -0,0 +1,127 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#!/bin/bash
set -e
TABLE_NAME="hotels_js"
QUICKSTART_JS_DIR="docs/en/getting-started/quickstart/js"
SQL_FILE=".ci/quickstart_test/setup_hotels_sample.sql"
# Initialize process IDs to empty at the top of the script
PROXY_PID=""
TOOLBOX_PID=""
install_system_packages() {
apt-get update && apt-get install -y \
postgresql-client \
wget \
gettext-base \
netcat-openbsd
}
start_cloud_sql_proxy() {
wget "https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.10.0/cloud-sql-proxy.linux.amd64" -O /usr/local/bin/cloud-sql-proxy
chmod +x /usr/local/bin/cloud-sql-proxy
cloud-sql-proxy "${CLOUD_SQL_INSTANCE}" &
PROXY_PID=$!
for i in {1..30}; do
if nc -z 127.0.0.1 5432; then
echo "Cloud SQL Proxy is up and running."
return
fi
sleep 1
done
echo "Cloud SQL Proxy failed to start within the timeout period."
exit 1
}
setup_toolbox() {
TOOLBOX_YAML="/tools.yaml"
echo "${TOOLS_YAML_CONTENT}" > "$TOOLBOX_YAML"
if [ ! -f "$TOOLBOX_YAML" ]; then echo "Failed to create tools.yaml"; exit 1; fi
wget "https://storage.googleapis.com/genai-toolbox/v${VERSION}/linux/amd64/toolbox" -O "/toolbox"
chmod +x "/toolbox"
/toolbox --tools-file "$TOOLBOX_YAML" &
TOOLBOX_PID=$!
sleep 2
}
setup_orch_table() {
export TABLE_NAME
envsubst < "$SQL_FILE" | psql -h "$PGHOST" -p "$PGPORT" -U "$DB_USER" -d "$DATABASE_NAME"
}
run_orch_test() {
local orch_dir="$1"
local orch_name
orch_name=$(basename "$orch_dir")
(
set -e
echo "--- Preparing environment for $orch_name ---"
setup_orch_table
# Go into the specific framework directory to install dependencies
cd "$orch_dir"
if [ -f "package.json" ]; then
echo "Installing dependencies for $orch_name..."
npm install
fi
# Go back to the parent directory ('js/') to run the test
cd ..
# Export the framework name as an environment variable and run the test
echo "--- Running tests for $orch_name ---"
export ORCH_NAME="$orch_name"
node --test quickstart.test.js
# Clean up the installed dependencies directly without changing directories
echo "--- Cleaning environment for $orch_name ---"
rm -rf "${orch_name}/node_modules"
)
}
cleanup_all() {
echo "--- Final cleanup: Shutting down processes and dropping table ---"
if [ -n "$TOOLBOX_PID" ]; then
kill $TOOLBOX_PID || true
fi
if [ -n "$PROXY_PID" ]; then
kill $PROXY_PID || true
fi
}
trap cleanup_all EXIT
# Main script execution
install_system_packages
start_cloud_sql_proxy
export PGHOST=127.0.0.1
export PGPORT=5432
export PGPASSWORD="$DB_PASSWORD"
export GOOGLE_API_KEY="$GOOGLE_API_KEY"
setup_toolbox
for ORCH_DIR in "$QUICKSTART_JS_DIR"/*/; do
if [ ! -d "$ORCH_DIR" ]; then
continue
fi
run_orch_test "$ORCH_DIR"
done

View File

@@ -3,7 +3,7 @@ import { ToolboxClient } from "@toolbox-sdk/core";
const TOOLBOX_URL = "http://127.0.0.1:5000"; // Update if needed
const GOOGLE_API_KEY = process.env.GOOGLE_API_KEY || 'your-api-key'; // Replace it with your API key
const GOOGLE_API_KEY = process.env.GOOGLE_API_KEY || 'api-key'; // Replace it with your API key
const prompt = `
You're a helpful hotel assistant. You handle hotel searching, booking, and