Skip to content

Commit 009c7d4

Browse files
Fix conflicts
2 parents 0c039d8 + 78574da commit 009c7d4

Some content is hidden

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

55 files changed

+1259
-390
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: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,39 +32,40 @@ jobs:
3232
env:
3333
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3434

35+
- name: Download kubectl and calicoctl for LKE clusters
36+
run: |
37+
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
38+
curl -LO "https://github.com/projectcalico/calico/releases/download/v3.25.0/calicoctl-linux-amd64"
39+
chmod +x calicoctl-linux-amd64 kubectl
40+
mv calicoctl-linux-amd64 /usr/local/bin/calicoctl
41+
mv kubectl /usr/local/bin/kubectl
42+
3543
- name: Run Integration tests
3644
run: |
3745
timestamp=$(date +'%Y%m%d%H%M')
3846
report_filename="${timestamp}_sdk_test_report.xml"
39-
status=0
40-
if ! python3 -m pytest test/integration/${INTEGRATION_TEST_PATH} --disable-warnings --junitxml="${report_filename}"; then
41-
echo "EXIT_STATUS=1" >> $GITHUB_ENV
42-
fi
47+
make testint TEST_ARGS="--junitxml=${report_filename}"
48+
env:
49+
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}
50+
51+
- name: Apply Calico Rules to LKE
52+
if: always()
53+
run: |
54+
cd scripts && ./lke_calico_rules_e2e.sh
4355
env:
4456
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}
4557

46-
- name: Add additional information to XML report
58+
- name: Upload test results
59+
if: always()
4760
run: |
4861
filename=$(ls | grep -E '^[0-9]{12}_sdk_test_report\.xml$')
4962
python tod_scripts/add_to_xml_test_report.py \
5063
--branch_name "${GITHUB_REF#refs/*/}" \
5164
--gha_run_id "$GITHUB_RUN_ID" \
5265
--gha_run_number "$GITHUB_RUN_NUMBER" \
5366
--xmlfile "${filename}"
54-
55-
- name: Upload test results
56-
run: |
57-
report_filename=$(ls | grep -E '^[0-9]{12}_sdk_test_report\.xml$')
58-
python3 tod_scripts/test_report_upload_script.py "${report_filename}"
67+
sync
68+
python3 tod_scripts/test_report_upload_script.py "${filename}"
5969
env:
6070
LINODE_CLI_OBJ_ACCESS_KEY: ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }}
6171
LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}
62-
63-
- name: Test Execution Status Handler
64-
run: |
65-
if [[ "$EXIT_STATUS" != 0 ]]; then
66-
echo "Test execution contains failure(s)"
67-
exit $EXIT_STATUS
68-
else
69-
echo "Tests passed!"
70-
fi

.github/workflows/release-cross-repo-test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ jobs:
2626
with:
2727
python-version: '3.10'
2828

29-
- name: Install linode_api4
30-
run: make install
31-
3229
- name: checkout repo
3330
uses: actions/checkout@v3
3431
with:
@@ -48,12 +45,15 @@ jobs:
4845
cd .ansible/collections/ansible_collections/linode/cloud
4946
make install
5047
48+
- name: Install linode_api4 # Need to install from source after all ansible dependencies have been installed
49+
run: make install
50+
5151
- name: replace existing keys
5252
run: |
5353
cd .ansible/collections/ansible_collections/linode/cloud
5454
rm -rf ~/.ansible/test && mkdir -p ~/.ansible/test && ssh-keygen -m PEM -q -t rsa -N '' -f ~/.ansible/test/id_rsa
5555
56-
- name: run tests
56+
- name: Run Ansible Tests
5757
run: |
5858
cd .ansible/collections/ansible_collections/linode/cloud
5959
make testall

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.8.10
1+
linode_api4-python

Makefile

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
PYTHON ?= python3
22

3-
INTEGRATION_TEST_PATH :=
43
TEST_CASE_COMMAND :=
5-
MODEL_COMMAND :=
4+
TEST_SUITE :=
5+
TEST_ARGS :=
66

77
LINODE_SDK_VERSION ?= "0.0.0.dev"
88
VERSION_MODULE_DOCSTRING ?= \"\"\"\nThe version of this linode_api4 package.\n\"\"\"\n\n
99
VERSION_FILE := ./linode_api4/version.py
1010

1111
ifdef TEST_CASE
12-
TEST_CASE_COMMAND = -k $(TEST_CASE)
12+
TEST_CASE_COMMAND = -k $(TEST_CASE)
1313
endif
1414

15-
ifdef TEST_MODEL
16-
MODEL_COMMAND = models/$(TEST_MODEL)
15+
ifdef TEST_SUITE
16+
ifneq ($(TEST_SUITE),linode_client)
17+
ifneq ($(TEST_SUITE),login_client)
18+
TEST_COMMAND = models/$(TEST_SUITE)
19+
else
20+
TEST_COMMAND = login_client
21+
endif
22+
else
23+
TEST_COMMAND = linode_client
24+
endif
1725
endif
1826

1927
.PHONY: clean
@@ -67,7 +75,7 @@ lint: build
6775

6876
.PHONY: testint
6977
testint:
70-
$(PYTHON) -m pytest test/integration/${INTEGRATION_TEST_PATH}${MODEL_COMMAND} ${TEST_CASE_COMMAND}
78+
$(PYTHON) -m pytest test/integration/${TEST_COMMAND} ${TEST_CASE_COMMAND} ${TEST_ARGS}
7179

7280
.PHONY: testunit
7381
testunit:

README.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,10 @@ Run the tests locally using the make command. Run the entire test suite using co
150150

151151
make testint
152152

153-
To run a specific package, use environment variable `INTEGRATION_TEST_PATH` with `testint` command::
153+
To run a specific package/suite, use the environment variable `TEST_SUITE` using directory names in `integration/...` folder ::
154154

155-
make INTEGRATION_TEST_PATH="linode_client" testint
156-
157-
To run a specific model test suite, set the environment variable `TEST_MODEL` using file name in `integration/models`::
158-
159-
make TEST_MODEL="test_account.py" testint
155+
make TEST_SUITE="account" testint // Runs tests in `integration/models/account` directory
156+
make TEST_SUITE="linode_client" testint // Runs tests in `integration/linode_client` directory
160157

161158
Lastly to run a specific test case use environment variable `TEST_CASE` with `testint` command::
162159

linode_api4/groups/account.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
AccountBetaProgram,
99
AccountSettings,
1010
BetaProgram,
11+
ChildAccount,
1112
Event,
1213
Invoice,
1314
Login,
@@ -487,12 +488,23 @@ def join_beta_program(self, beta: Union[str, BetaProgram]):
487488

488489
def availabilities(self, *filters):
489490
"""
490-
Returns a list of all available regions and the resources which are NOT available
491+
Returns a list of all available regions and the resource types which are available
491492
to the account.
492493
493-
API doc: TBD
494+
API doc: https://www.linode.com/docs/api/account/#region-service-availability
494495
495496
:returns: a list of region availability information.
496497
:rtype: PaginatedList of AccountAvailability
497498
"""
498499
return self.client._get_and_filter(AccountAvailability, *filters)
500+
501+
def child_accounts(self, *filters):
502+
"""
503+
Returns a list of all child accounts under the this parent account.
504+
505+
API doc: TBD
506+
507+
:returns: a list of all child accounts.
508+
:rtype: PaginatedList of ChildAccount
509+
"""
510+
return self.client._get_and_filter(ChildAccount, *filters)

linode_api4/groups/linode.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,16 @@
22
import os
33
from collections.abc import Iterable
44

5-
from linode_api4 import InstancePlacementGroupAssignment, Profile
6-
from linode_api4.common import SSH_KEY_TYPES, load_and_validate_keys
5+
from linode_api4.common import load_and_validate_keys
76
from linode_api4.errors import UnexpectedResponseError
87
from linode_api4.groups import Group
98
from linode_api4.objects import (
10-
AuthorizedApp,
119
Base,
1210
ConfigInterface,
1311
Firewall,
1412
Image,
1513
Instance,
1614
Kernel,
17-
PersonalAccessToken,
18-
SSHKey,
1915
StackScript,
2016
Type,
2117
)

linode_api4/groups/lke.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1+
from typing import Any, Dict, Union
2+
13
from linode_api4.errors import UnexpectedResponseError
24
from linode_api4.groups import Group
3-
from linode_api4.objects import Base, KubeVersion, LKECluster
5+
from linode_api4.objects import (
6+
Base,
7+
JSONObject,
8+
KubeVersion,
9+
LKECluster,
10+
LKEClusterControlPlaneOptions,
11+
drop_null_keys,
12+
)
413

514

615
class LKEGroup(Group):
@@ -47,7 +56,17 @@ def clusters(self, *filters):
4756
"""
4857
return self.client._get_and_filter(LKECluster, *filters)
4958

50-
def cluster_create(self, region, label, node_pools, kube_version, **kwargs):
59+
def cluster_create(
60+
self,
61+
region,
62+
label,
63+
node_pools,
64+
kube_version,
65+
control_plane: Union[
66+
LKEClusterControlPlaneOptions, Dict[str, Any]
67+
] = None,
68+
**kwargs,
69+
):
5170
"""
5271
Creates an :any:`LKECluster` on this account in the given region, with
5372
the given label, and with node pools as described. For example::
@@ -80,6 +99,8 @@ def cluster_create(self, region, label, node_pools, kube_version, **kwargs):
8099
formatted dicts.
81100
:param kube_version: The version of Kubernetes to use
82101
:type kube_version: KubeVersion or str
102+
:param control_plane: Dict[str, Any] or LKEClusterControlPlaneRequest
103+
:type control_plane: The control plane configuration of this LKE cluster.
83104
:param kwargs: Any other arguments to pass along to the API. See the API
84105
docs for possible values.
85106
@@ -112,10 +133,15 @@ def cluster_create(self, region, label, node_pools, kube_version, **kwargs):
112133
if issubclass(type(kube_version), Base)
113134
else kube_version
114135
),
136+
"control_plane": (
137+
control_plane.dict
138+
if issubclass(type(control_plane), JSONObject)
139+
else control_plane
140+
),
115141
}
116142
params.update(kwargs)
117143

118-
result = self.client.post("/lke/clusters", data=params)
144+
result = self.client.post("/lke/clusters", data=drop_null_keys(params))
119145

120146
if "id" not in result:
121147
raise UnexpectedResponseError(

0 commit comments

Comments
 (0)