Skip to content

Commit 281a257

Browse files
Fix merge conflicts
2 parents df2d8c1 + 10d3685 commit 281a257

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1641
-394
lines changed

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

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ on:
22
pull_request:
33
workflow_dispatch:
44
inputs:
5-
test_path:
6-
description: 'Enter specific test path. E.g. linode_client/test_linode_client.py, models/test_account.py'
5+
test_suite:
6+
description: 'Enter specific test suite. E.g. domain, linode_client'
77
required: false
88
sha:
99
description: 'The hash value of the commit.'
@@ -26,7 +26,7 @@ jobs:
2626
- uses: actions-ecosystem/action-regex-match@v2
2727
id: validate-tests
2828
with:
29-
text: ${{ inputs.test_path }}
29+
text: ${{ inputs.test_suite }}
3030
regex: '[^a-z0-9-:.\/_]' # Tests validation
3131
flags: gi
3232

@@ -71,6 +71,14 @@ jobs:
7171
- name: Install Python deps
7272
run: pip install -U setuptools wheel boto3 certifi
7373

74+
- name: Download kubectl and calicoctl for LKE clusters
75+
run: |
76+
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
77+
curl -LO "https://github.com/projectcalico/calico/releases/download/v3.25.0/calicoctl-linux-amd64"
78+
chmod +x calicoctl-linux-amd64 kubectl
79+
mv calicoctl-linux-amd64 /usr/local/bin/calicoctl
80+
mv kubectl /usr/local/bin/kubectl
81+
7482
- name: Install Python SDK
7583
run: make dev-install
7684
env:
@@ -80,26 +88,28 @@ jobs:
8088
run: |
8189
timestamp=$(date +'%Y%m%d%H%M')
8290
report_filename="${timestamp}_sdk_test_report.xml"
83-
status=0
84-
if ! python3 -m pytest test/integration/${INTEGRATION_TEST_PATH} --disable-warnings --junitxml="${report_filename}"; then
85-
echo "EXIT_STATUS=1" >> $GITHUB_ENV
86-
fi
91+
make testint TEST_ARGS="--junitxml=${report_filename}" TEST_SUITE="${{ github.event.inputs.test_suite }}"
92+
env:
93+
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}
94+
95+
- name: Apply Calico Rules to LKE
96+
if: always()
97+
run: |
98+
cd scripts && ./lke_calico_rules_e2e.sh
8799
env:
88100
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}
89101

90-
- name: Add additional information to XML report
102+
- name: Upload test results
103+
if: always()
91104
run: |
92105
filename=$(ls | grep -E '^[0-9]{12}_sdk_test_report\.xml$')
93106
python tod_scripts/add_to_xml_test_report.py \
94107
--branch_name "${GITHUB_REF#refs/*/}" \
95108
--gha_run_id "$GITHUB_RUN_ID" \
96109
--gha_run_number "$GITHUB_RUN_NUMBER" \
97110
--xmlfile "${filename}"
98-
99-
- name: Upload test results
100-
run: |
101-
report_filename=$(ls | grep -E '^[0-9]{12}_sdk_test_report\.xml$')
102-
python3 tod_scripts/test_report_upload_script.py "${report_filename}"
111+
sync
112+
python3 tod_scripts/test_report_upload_script.py "${filename}"
103113
env:
104114
LINODE_CLI_OBJ_ACCESS_KEY: ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }}
105115
LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}
@@ -131,12 +141,3 @@ jobs:
131141
conclusion: process.env.conclusion
132142
});
133143
return result;
134-
135-
- name: Test Execution Status Handler
136-
run: |
137-
if [[ "$EXIT_STATUS" != 0 ]]; then
138-
echo "Test execution contains failure(s)"
139-
exit $EXIT_STATUS
140-
else
141-
echo "Tests passed!"
142-
fi

.github/workflows/e2e-test.yml

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
name: Integration Tests
22

33
on:
4-
workflow_dispatch: null
4+
workflow_dispatch:
5+
inputs:
6+
use_minimal_test_account:
7+
description: 'Use minimal test account'
8+
required: false
9+
default: 'false'
10+
sha:
11+
description: 'The hash value of the commit'
12+
required: false
13+
default: ''
514
push:
615
branches:
716
- main
@@ -13,7 +22,16 @@ jobs:
1322
env:
1423
EXIT_STATUS: 0
1524
steps:
16-
- name: Clone Repository
25+
- name: Clone Repository with SHA
26+
if: ${{ inputs.sha != '' }}
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
submodules: 'recursive'
31+
ref: ${{ inputs.sha }}
32+
33+
- name: Clone Repository without SHA
34+
if: ${{ inputs.sha == '' }}
1735
uses: actions/checkout@v4
1836
with:
1937
fetch-depth: 0
@@ -32,13 +50,32 @@ jobs:
3250
env:
3351
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3452

53+
- name: Download kubectl and calicoctl for LKE clusters
54+
run: |
55+
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
56+
curl -LO "https://github.com/projectcalico/calico/releases/download/v3.25.0/calicoctl-linux-amd64"
57+
chmod +x calicoctl-linux-amd64 kubectl
58+
mv calicoctl-linux-amd64 /usr/local/bin/calicoctl
59+
mv kubectl /usr/local/bin/kubectl
60+
61+
- name: Set LINODE_TOKEN
62+
run: |
63+
echo "LINODE_TOKEN=${{ secrets[inputs.use_minimal_test_account == 'true' && 'MINIMAL_LINODE_TOKEN' || 'LINODE_TOKEN'] }}" >> $GITHUB_ENV
64+
3565
- name: Run Integration tests
3666
run: |
3767
timestamp=$(date +'%Y%m%d%H%M')
3868
report_filename="${timestamp}_sdk_test_report.xml"
3969
make testint TEST_ARGS="--junitxml=${report_filename}"
4070
env:
41-
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}
71+
LINODE_TOKEN: ${{ env.LINODE_TOKEN }}
72+
73+
- name: Apply Calico Rules to LKE
74+
if: always()
75+
run: |
76+
cd scripts && ./lke_calico_rules_e2e.sh
77+
env:
78+
LINODE_TOKEN: ${{ env.LINODE_TOKEN }}
4279

4380
- name: Upload test results
4481
if: always()

docs/linode_api4/linode_client.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,15 @@ with buckets and objects, use the s3 API directly with a library like `boto3`_.
155155

156156
.. _boto3: https://github.com/boto/boto3
157157

158+
PlacementAPIGroup
159+
^^^^^^^^^^^^
160+
161+
Includes methods related to VM placement.
162+
163+
.. autoclass:: linode_api4.linode_client.PlacementAPIGroup
164+
:members:
165+
:special-members:
166+
158167
PollingGroup
159168
^^^^^^^^^^^^
160169

docs/linode_api4/objects/models.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,15 @@ Object Storage Models
104104
:undoc-members:
105105
:inherited-members:
106106

107+
Placement Models
108+
--------------
109+
110+
.. automodule:: linode_api4.objects.placement
111+
:members:
112+
:exclude-members: api_endpoint, properties, derived_url_path, id_attribute, parent_id_name
113+
:undoc-members:
114+
:inherited-members:
115+
107116
Profile Models
108117
--------------
109118

linode_api4/groups/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from .networking import *
1313
from .nodebalancer import *
1414
from .object_storage import *
15+
from .placement import *
1516
from .polling import *
1617
from .profile import *
1718
from .region import *

linode_api4/groups/account.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
ServiceTransfer,
2020
User,
2121
)
22-
from linode_api4.objects.profile import PersonalAccessToken
2322

2423

2524
class AccountGroup(Group):
@@ -503,6 +502,8 @@ def child_accounts(self, *filters):
503502
"""
504503
Returns a list of all child accounts under the this parent account.
505504
505+
NOTE: Parent/Child related features may not be generally available.
506+
506507
API doc: TBD
507508
508509
:returns: a list of all child accounts.

linode_api4/groups/linode.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,22 @@
33
from collections.abc import Iterable
44
from typing import Optional, Union
55

6-
from linode_api4 import InstanceDiskEncryptionType, Profile
7-
from linode_api4.common import SSH_KEY_TYPES, load_and_validate_keys
6+
from linode_api4 import InstanceDiskEncryptionType
7+
from linode_api4.common import load_and_validate_keys
88
from linode_api4.errors import UnexpectedResponseError
99
from linode_api4.groups import Group
1010
from linode_api4.objects import (
11-
AuthorizedApp,
1211
Base,
1312
ConfigInterface,
1413
Firewall,
1514
Image,
1615
Instance,
1716
Kernel,
18-
PersonalAccessToken,
19-
SSHKey,
2017
StackScript,
2118
Type,
2219
)
2320
from linode_api4.objects.filtering import Filter
21+
from linode_api4.objects.linode import _expand_placement_group_assignment
2422
from linode_api4.paginated_list import PaginatedList
2523

2624

@@ -280,6 +278,8 @@ def instance_create(
280278
:param interfaces: An array of Network Interfaces to add to this Linode’s Configuration Profile.
281279
At least one and up to three Interface objects can exist in this array.
282280
:type interfaces: list[ConfigInterface] or list[dict[str, Any]]
281+
:param placement_group: A Placement Group to create this Linode under.
282+
:type placement_group: Union[InstancePlacementGroupAssignment, PlacementGroup, Dict[str, Any], int]
283283
284284
:returns: A new Instance object, or a tuple containing the new Instance and
285285
the generated password.
@@ -326,6 +326,11 @@ def instance_create(
326326
for i in interfaces
327327
]
328328

329+
if "placement_group" in kwargs:
330+
kwargs["placement_group"] = _expand_placement_group_assignment(
331+
kwargs.get("placement_group")
332+
)
333+
329334
params = {
330335
"type": ltype.id if issubclass(type(ltype), Base) else ltype,
331336
"region": region.id if issubclass(type(region), Base) else region,

0 commit comments

Comments
 (0)