Skip to content

Commit 1db527a

Browse files
Merge pull request #334 from linode/dev
Release v5.9.0
2 parents 5b9e283 + 9b0d360 commit 1db527a

File tree

11 files changed

+287
-14
lines changed

11 files changed

+287
-14
lines changed

.github/workflows/e2e-test-pr.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,37 @@ jobs:
7878
env:
7979
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8080

81-
- run: make INTEGRATION_TEST_PATH="${{ inputs.test_path }}" testint
82-
if: ${{ steps.validate-tests.outputs.match == '' }}
81+
- name: Run Integration tests
82+
run: |
83+
timestamp=$(date +'%Y%m%d%H%M')
84+
report_filename="${timestamp}_sdk_test_report.xml"
85+
status=0
86+
if ! python3 -m pytest test/integration/${INTEGRATION_TEST_PATH} --junitxml="${report_filename}"; then
87+
echo "Tests failed, but attempting to upload results anyway"
88+
fi
8389
env:
8490
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}
8591

92+
- name: Set release version env
93+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
94+
95+
- name: Add additional information to XML report
96+
run: |
97+
filename=$(ls | grep -E '^[0-9]{12}_sdk_test_report\.xml$')
98+
python test/script/add_to_xml_test_report.py \
99+
--branch_name "${{ env.RELEASE_VERSION }}" \
100+
--gha_run_id "$GITHUB_RUN_ID" \
101+
--gha_run_number "$GITHUB_RUN_NUMBER" \
102+
--xmlfile "${filename}"
103+
104+
- name: Upload test results
105+
run: |
106+
report_filename=$(ls | grep -E '^[0-9]{12}_sdk_test_report\.xml$')
107+
python3 test/script/test_report_upload_script.py "${report_filename}"
108+
env:
109+
LINODE_CLI_OBJ_ACCESS_KEY: ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }}
110+
LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}
111+
86112
- uses: actions/github-script@v6
87113
id: update-check-run
88114
if: ${{ inputs.pull_request_number != '' && fromJson(steps.commit-hash.outputs.data).repository.pullRequest.headRef.target.oid == inputs.sha }}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ release: build
2828
twine upload dist/*
2929

3030
@PHONEY: install
31-
install: clean
31+
install: clean requirements
3232
python3 -m pip install .
3333

3434
@PHONEY: requirements

linode_api4/objects/linode.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ class Type(Base):
232232
"label": Property(),
233233
"network_out": Property(),
234234
"price": Property(),
235+
"region_prices": Property(),
235236
"addons": Property(),
236237
"memory": Property(),
237238
"transfer": Property(),
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"quota": 471,
3+
"used": 737373,
4+
"billable": 0,
5+
6+
"region_transfers": [
7+
{
8+
"id": "ap-west",
9+
"used": 1,
10+
"quota": 5010,
11+
"billable": 0
12+
}
13+
]
14+
}

test/fixtures/linode_types.json

Lines changed: 105 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"results": 4,
3-
"pages": 1,
4-
"page": 1,
5-
"data": [
2+
"results": 4,
3+
"pages": 1,
4+
"page": 1,
5+
"data": [
66
{
77
"disk": 20480,
88
"memory": 1024,
@@ -12,7 +12,19 @@
1212
"price": {
1313
"hourly": 0.003,
1414
"monthly": 2
15-
}
15+
},
16+
"region_prices": [
17+
{
18+
"id": "ap-west",
19+
"hourly": 0.02,
20+
"monthly": 20
21+
},
22+
{
23+
"id": "ap-northeast",
24+
"hourly": 0.02,
25+
"monthly": 20
26+
}
27+
]
1628
}
1729
},
1830
"class": "nanode",
@@ -25,6 +37,18 @@
2537
"hourly": 0.0075,
2638
"monthly": 5
2739
},
40+
"region_prices": [
41+
{
42+
"id": "us-east",
43+
"hourly": 0.02,
44+
"monthly": 20
45+
},
46+
{
47+
"id": "ap-northeast",
48+
"hourly": 0.02,
49+
"monthly": 20
50+
}
51+
],
2852
"successor": null
2953
},
3054
{
@@ -36,7 +60,19 @@
3660
"price": {
3761
"hourly": 0.008,
3862
"monthly": 5
39-
}
63+
},
64+
"region_prices": [
65+
{
66+
"id": "ap-west",
67+
"hourly": 0.02,
68+
"monthly": 20
69+
},
70+
{
71+
"id": "ap-northeast",
72+
"hourly": 0.02,
73+
"monthly": 20
74+
}
75+
]
4076
}
4177
},
4278
"class": "highmem",
@@ -49,6 +85,18 @@
4985
"hourly": 0.09,
5086
"monthly": 60
5187
},
88+
"region_prices": [
89+
{
90+
"id": "us-east",
91+
"hourly": 0.02,
92+
"monthly": 20
93+
},
94+
{
95+
"id": "ap-northeast",
96+
"hourly": 0.02,
97+
"monthly": 20
98+
}
99+
],
52100
"successor": null
53101
},
54102
{
@@ -60,7 +108,19 @@
60108
"price": {
61109
"hourly": 0.004,
62110
"monthly": 2.5
63-
}
111+
},
112+
"region_prices": [
113+
{
114+
"id": "ap-west",
115+
"hourly": 0.02,
116+
"monthly": 20
117+
},
118+
{
119+
"id": "ap-northeast",
120+
"hourly": 0.02,
121+
"monthly": 20
122+
}
123+
]
64124
}
65125
},
66126
"class": "standard",
@@ -73,6 +133,18 @@
73133
"hourly": 0.015,
74134
"monthly": 10
75135
},
136+
"region_prices": [
137+
{
138+
"id": "us-east",
139+
"hourly": 0.02,
140+
"monthly": 20
141+
},
142+
{
143+
"id": "ap-northeast",
144+
"hourly": 0.02,
145+
"monthly": 20
146+
}
147+
],
76148
"successor": null
77149
},
78150
{
@@ -84,7 +156,19 @@
84156
"price": {
85157
"hourly": 0.008,
86158
"monthly": 5
87-
}
159+
},
160+
"region_prices": [
161+
{
162+
"id": "ap-west",
163+
"hourly": 0.02,
164+
"monthly": 20
165+
},
166+
{
167+
"id": "ap-northeast",
168+
"hourly": 0.02,
169+
"monthly": 20
170+
}
171+
]
88172
}
89173
},
90174
"class": "gpu",
@@ -97,7 +181,19 @@
97181
"hourly": 0.03,
98182
"monthly": 20
99183
},
184+
"region_prices": [
185+
{
186+
"id": "us-east",
187+
"hourly": 0.02,
188+
"monthly": 20
189+
},
190+
{
191+
"id": "ap-northeast",
192+
"hourly": 0.02,
193+
"monthly": 20
194+
}
195+
],
100196
"successor": null
101197
}
102198
]
103-
}
199+
}

test/integration/conftest.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,27 @@
33

44
import pytest
55

6-
from linode_api4.linode_client import LinodeClient, LongviewSubscription
6+
from linode_api4.linode_client import LinodeClient
77

88
ENV_TOKEN_NAME = "LINODE_TOKEN"
9+
ENV_API_URL_NAME = "LINODE_API_URL"
10+
ENV_API_CA_NAME = "LINODE_API_CA"
911
RUN_LONG_TESTS = "RUN_LONG_TESTS"
1012

1113

1214
def get_token():
1315
return os.environ.get(ENV_TOKEN_NAME, None)
1416

1517

18+
def get_api_url():
19+
return os.environ.get(ENV_API_URL_NAME, "https://api.linode.com/v4beta")
20+
21+
22+
def get_api_ca_file():
23+
result = os.environ.get(ENV_API_CA_NAME, None)
24+
return result if result != "" else None
25+
26+
1627
def run_long_tests():
1728
return os.environ.get(RUN_LONG_TESTS, None)
1829

@@ -71,7 +82,13 @@ def ssh_key_gen():
7182
@pytest.fixture(scope="session")
7283
def get_client():
7384
token = get_token()
74-
client = LinodeClient(token)
85+
api_url = get_api_url()
86+
api_ca_file = get_api_ca_file()
87+
client = LinodeClient(
88+
token,
89+
base_url=api_url,
90+
ca_path=api_ca_file,
91+
)
7592
return client
7693

7794

test/integration/models/test_linode.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,22 @@ def test_get_linode_types(get_client):
398398
assert "g6-nanode-1" in ids
399399

400400

401+
def test_get_linode_types_overrides(get_client):
402+
types = get_client.linode.types()
403+
404+
target_types = [
405+
v
406+
for v in types
407+
if len(v.region_prices) > 0 and v.region_prices[0].hourly > 0
408+
]
409+
410+
assert len(target_types) > 0
411+
412+
for linode_type in target_types:
413+
assert linode_type.region_prices[0].hourly >= 0
414+
assert linode_type.region_prices[0].monthly >= 0
415+
416+
401417
def test_get_linode_type_by_id(get_client):
402418
pytest.skip(
403419
"Might need Type to match how other object models are behaving e.g. client.load(Type, 123)"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import argparse
2+
import xml.etree.ElementTree as ET
3+
4+
# Parse command-line arguments
5+
parser = argparse.ArgumentParser(
6+
description="Modify XML with workflow information"
7+
)
8+
parser.add_argument("--branch_name", required=True)
9+
parser.add_argument("--gha_run_id", required=True)
10+
parser.add_argument("--gha_run_number", required=True)
11+
parser.add_argument(
12+
"--xmlfile", required=True
13+
) # Added argument for XML file path
14+
15+
args = parser.parse_args()
16+
17+
# Open and parse the XML file
18+
xml_file_path = args.xmlfile
19+
tree = ET.parse(xml_file_path)
20+
root = tree.getroot()
21+
22+
# Create new elements for the information
23+
branch_name_element = ET.Element("branch_name")
24+
branch_name_element.text = args.branch_name
25+
26+
gha_run_id_element = ET.Element("gha_run_id")
27+
gha_run_id_element.text = args.gha_run_id
28+
29+
gha_run_number_element = ET.Element("gha_run_number")
30+
gha_run_number_element.text = args.gha_run_number
31+
32+
# Add the new elements to the root of the XML
33+
root.append(branch_name_element)
34+
root.append(gha_run_id_element)
35+
root.append(gha_run_number_element)
36+
37+
# Save the modified XML
38+
modified_xml_file_path = xml_file_path # Overwrite it
39+
tree.write(modified_xml_file_path)
40+
41+
print(f"Modified XML saved to {modified_xml_file_path}")

0 commit comments

Comments
 (0)