Skip to content

Commit 6975fab

Browse files
authored
Merge pull request #557 from Labelbox/jt/al-1707
[AL-1707] Update to Delegated Access Test Cases
2 parents 83ecb8d + 5679390 commit 6975fab

File tree

5 files changed

+50
-17
lines changed

5 files changed

+50
-17
lines changed

.github/workflows/python-package.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@ jobs:
1717
- python-version: 3.6
1818
prod-key: LABELBOX_API_KEY
1919
staging-key: STAGING_LABELBOX_API_KEY
20+
da-test-key: DA_GCP_LABELBOX_API_KEY
2021
- python-version: 3.7
2122
prod-key: PROD_LABELBOX_API_KEY_2
2223
staging-key: STAGING_LABELBOX_API_KEY_2
24+
da-test-key: DA_GCP_LABELBOX_API_KEY
2325
- python-version: 3.8
2426
prod-key: PROD_LABELBOX_API_KEY_3
2527
staging-key: STAGING_LABELBOX_API_KEY_3
28+
da-test-key: DA_GCP_LABELBOX_API_KEY
2629

2730
steps:
2831
- name: Cancel previous workflow
@@ -83,5 +86,7 @@ jobs:
8386
LABELBOX_TEST_API_KEY_PROD: ${{ secrets[matrix.prod-key] }}
8487

8588
LABELBOX_TEST_API_KEY_STAGING: ${{ secrets[matrix.staging-key] }}
89+
90+
DA_GCP_LABELBOX_API_KEY: ${{ secrets[matrix.da-test-key] }}
8691
run: |
8792
tox -e py -- -svv --reruns 5 --reruns-delay 10

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,28 @@ build:
66
test-local: build
77
docker run -it -v ${PWD}:/usr/src -w /usr/src \
88
-e LABELBOX_TEST_ENVIRON="local" \
9+
-e DA_GCP_LABELBOX_API_KEY=${DA_GCP_LABELBOX_API_KEY} \
910
-e LABELBOX_TEST_API_KEY_LOCAL=${LABELBOX_TEST_API_KEY_LOCAL} \
1011
local/labelbox-python:test pytest $(PATH_TO_TEST)
1112

1213
test-staging: build
1314
docker run -it -v ${PWD}:/usr/src -w /usr/src \
1415
-e LABELBOX_TEST_ENVIRON="staging" \
16+
-e DA_GCP_LABELBOX_API_KEY=${DA_GCP_LABELBOX_API_KEY} \
1517
-e LABELBOX_TEST_API_KEY_STAGING=${LABELBOX_TEST_API_KEY_STAGING} \
1618
local/labelbox-python:test pytest $(PATH_TO_TEST)
1719

1820
test-prod: build
1921
docker run -it -v ${PWD}:/usr/src -w /usr/src \
2022
-e LABELBOX_TEST_ENVIRON="prod" \
23+
-e DA_GCP_LABELBOX_API_KEY=${DA_GCP_LABELBOX_API_KEY} \
2124
-e LABELBOX_TEST_API_KEY_PROD=${LABELBOX_TEST_API_KEY_PROD} \
2225
local/labelbox-python:test pytest $(PATH_TO_TEST)
2326

2427
test-onprem: build
2528
docker run -it -v ${PWD}:/usr/src -w /usr/src \
2629
-e LABELBOX_TEST_ENVIRON="onprem" \
30+
-e DA_GCP_LABELBOX_API_KEY=${DA_GCP_LABELBOX_API_KEY} \
2731
-e LABELBOX_TEST_API_KEY_ONPREM=${LABELBOX_TEST_API_KEY_ONPREM} \
2832
-e LABELBOX_TEST_ONPREM_HOSTNAME=${LABELBOX_TEST_ONPREM_HOSTNAME} \
2933
local/labelbox-python:test pytest $(PATH_TO_TEST)

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,6 @@ make test-prod # with an optional flag: PATH_TO_TEST=tests/integration/...etc LA
121121
```
122122
make -B {build|test-staging|test-prod}
123123
```
124+
125+
6. Testing against Delegated Access will be skipped unless the local env contains the key:
126+
DA_GCP_LABELBOX_API_KEY. These tests will be included when run against a PR. If you would like to test it manually, please reach out to the Devops team for information on the key.

tests/integration/test_delegated_access.py

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,56 @@
1+
import os
2+
13
import requests
24
import pytest
35

6+
from labelbox import Client
7+
48

5-
@pytest.mark.skip("Can only be tested in specific organizations.")
6-
def test_default_integration(client):
7-
# This tests assumes the following:
8-
# 1. gcp delegated access is configured to work with utkarsh-da-test-bucket
9-
# 2. the integration name is gcp test
10-
# 3. This integration is the default
9+
@pytest.mark.skipif(os.environ.get("DA_GCP_LABELBOX_API_KEY") is None,
10+
reason="DA_GCP_LABELBOX_API_KEY not found")
11+
def test_default_integration():
12+
"""
13+
This tests assumes the following:
14+
1. gcp delegated access is configured to work with jtso-gcs-sdk-da-tests
15+
2. the integration name is gcs sdk test bucket
16+
3. This integration is the default
17+
18+
Currently tests against:
19+
Org ID: cl269lvvj78b50zau34s4550z
20+
Email: jtso+gcp_sdk_tests@labelbox.com"""
21+
client = Client(api_key=os.environ.get("DA_GCP_LABELBOX_API_KEY"))
1122
ds = client.create_dataset(name="new_ds")
1223
dr = ds.create_data_row(
1324
row_data=
14-
"gs://utkarsh-da-test-bucket/mathew-schwartz-8rj4sz9YLCI-unsplash.jpg")
25+
"gs://jtso-gcs-sdk-da-tests/nikita-samokhin-D6QS6iv_CTY-unsplash.jpg")
1526
assert requests.get(dr.row_data).status_code == 200
16-
assert ds.iam_integration().name == "GCP Test"
27+
assert ds.iam_integration().name == "gcs sdk test bucket"
1728
ds.delete()
1829

1930

20-
@pytest.mark.skip("Can only be tested in specific organizations.")
21-
def test_non_default_integration(client):
22-
# This tests assumes the following:
23-
# 1. aws delegated access is configured to work with lbox-test-bucket
24-
# 2. an integration called aws is available to the org
31+
@pytest.mark.skipif(os.environ.get("DA_GCP_LABELBOX_API_KEY") is None,
32+
reason="DA_GCP_LABELBOX_API_KEY not found")
33+
def test_non_default_integration():
34+
"""
35+
This tests assumes the following:
36+
1. aws delegated access is configured to work with lbox-test-bucket
37+
2. an integration called aws is available to the org
38+
39+
Currently tests against:
40+
Org ID: cl26d06tk0gch10901m7jeg9v
41+
Email: jtso+aws_sdk_tests@labelbox.com
42+
"""
43+
client = Client(api_key=os.environ.get("DA_GCP_LABELBOX_API_KEY"))
2544
integrations = client.get_organization().get_iam_integrations()
26-
integration = [inte for inte in integrations if 'aws' in inte.name][0]
45+
integration = [
46+
inte for inte in integrations if 'aws-da-test-bucket' in inte.name
47+
][0]
2748
assert integration.valid
2849
ds = client.create_dataset(iam_integration=integration, name="new_ds")
29-
assert ds.iam_integration().name == "aws"
50+
assert ds.iam_integration().name == "aws-da-test-bucket"
3051
dr = ds.create_data_row(
3152
row_data=
32-
"https://lbox-test-bucket.s3.us-east-1.amazonaws.com/2021_09_08_0hz_Kleki.png"
53+
"https://jtso-aws-da-sdk-tests.s3.us-east-2.amazonaws.com/adrian-yu-qkN4D3Rf1gw-unsplash.jpg"
3354
)
3455
assert requests.get(dr.row_data).status_code == 200
3556
ds.delete()

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ deps =
99
pytest < 7.0.0
1010
pytest-cases
1111
pytest-rerunfailures
12-
passenv = LABELBOX_TEST_API_KEY_PROD LABELBOX_TEST_API_KEY_STAGING LABELBOX_TEST_ENVIRON
12+
passenv = LABELBOX_TEST_API_KEY_PROD LABELBOX_TEST_API_KEY_STAGING LABELBOX_TEST_ENVIRON DA_GCP_LABELBOX_API_KEY
1313
commands = pytest {posargs}

0 commit comments

Comments
 (0)