Skip to content

Commit a157e2e

Browse files
committed
Revamp 'make test' to not require local 'tox.ini' configuration.
1 parent e2afc4e commit a157e2e

File tree

6 files changed

+67
-52
lines changed

6 files changed

+67
-52
lines changed

instrumentation-genai/opentelemetry-instrumentation-google-genai/pytest.ini

Lines changed: 0 additions & 17 deletions
This file was deleted.

instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/requirements.latest.txt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,19 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
1615
# This variant of the requirements aims to test the system using
1716
# the newest supported version of external depenendencies.
1817

1918
pytest==7.4.4
2019
pytest-asyncio==0.21.0
2120
pytest-vcr==1.0.2
2221

23-
google-auth ~= 2.38.0
24-
google-genai ~= 1.0.0
25-
opentelemetry-api ~= 1.30.0
26-
opentelemetry-sdk ~= 1.30.0
27-
opentelemetry-semantic-conventions ~= 0.51b0
28-
opentelemetry-instrumentation ~=0.51b0
22+
google-auth==2.38.0
23+
google-genai==1.0.0
24+
opentelemetry-api==1.30.0
25+
opentelemetry-sdk==1.30.0
26+
opentelemetry-semantic-conventions==0.51b0
27+
opentelemetry-instrumentation==0.51b0
2928

3029
# Install locally from the folder. This path is relative to the
3130
# root directory, given invocation from "tox" at root level.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
# Copyright The OpenTelemetry Authors
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Helper script of "test.sh".
18+
#
19+
# Assumptions:
20+
# - Working directory: top-level root project directory
21+
# - Virtual environment:
22+
# - Activated
23+
# - Contains the "tox" script
24+
# - Arguments:
25+
# - One argument
26+
# - Argument supplies name of a configured tox environment
27+
#
28+
# Action:
29+
#
30+
# Runs the given tox environment, with additional parameters
31+
# to provide for more verbose debug output when testing.
32+
33+
function main() {
34+
local tox_env="$1"
35+
tox -e "${tox_env}" -- -o log_cli_level=debug
36+
exit $?
37+
}
38+
39+
main "$@"

instrumentation-genai/opentelemetry-instrumentation-google-genai/tools/test.sh

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@
1616

1717
SCRIPT_DIR=$(cd $(dirname "${BASH_SOURCE:-$0}"); pwd)
1818
PROJECT_DIR=$(readlink -f "${SCRIPT_DIR}/..")
19+
TOP_LEVEL_DIR=$(readlink -f "${PROJECT_DIR}/../../")
1920
TESTS_DIR="${PROJECT_DIR}/tests"
2021
TESTS_OUTPUT_DIR="${PROJECT_DIR}/.test"
2122
TEST_ENV="${TESTS_OUTPUT_DIR}/.venv"
2223

24+
function run_tox_test() {
25+
local tox_env="$1"
26+
tox -e "${tox_env}" -- -o log_cli_level=debug
27+
}
28+
2329
function main() {
2430
if [ ! -d "${TEST_ENV}" ] ; then
2531
mkdir -p "${TEST_ENV}" || exit 1
@@ -28,11 +34,22 @@ function main() {
2834
python3 -m venv "${TEST_ENV}" || exit 1
2935
fi
3036
source "${TEST_ENV}/bin/activate" || exit 1
31-
pip install -r "${TESTS_DIR}/requirements.txt" || exit 1
3237
pip install tox || exit 1
33-
cd "${PROJECT_DIR}" || exit 1
34-
make install || exit 1
35-
python3 -m tox || exit 1
38+
pip install pytest || exit 1
39+
cd "${TOP_LEVEL_DIR_DIR}" || exit 1
40+
41+
local tox_environments=$(tox -l | grep 'test-instrumentation-google-genai')
42+
local successful=0
43+
for tox_environment in ${tox_environments} ; do
44+
echo "[INFO] Testing environment: ${tox_environmenmt}" >&2
45+
${SCRIPT_DIR}/test-with-tox.sh "${tox_environment}"|| exit $?
46+
successful=$(expr ${successful} + 1)
47+
done
48+
if [ $successful -eq 0 ] ; then
49+
echo "[FATAL] No tests ran." >&2
50+
exit 1
51+
fi
52+
echo "[DONE] Succesfully passed ${successful} environments." >&2
3653
}
3754

3855
main

instrumentation-genai/opentelemetry-instrumentation-google-genai/tox.ini

Lines changed: 0 additions & 23 deletions
This file was deleted.

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ envlist =
2020
lint-instrumentation-vertexai
2121

2222
; instrumentation-google-genai
23-
py3{9, 10,11,12,13}-test-instrumentation-google-genai-{old-deps,recent-deps}
23+
py3{9,10,11,12,13}-test-instrumentation-google-genai-{old-deps,recent-deps}
2424
# Disabling pypy3 as shapely does not have wheels and fails to compile
2525
# pypy3-test-instrumentation-google-genai-{0,1}
2626
lint-instrumentation-google-genai

0 commit comments

Comments
 (0)