Skip to content

Commit 506c011

Browse files
Merge pull request #528 from linode/dev
v5.44.2
2 parents 32fd489 + 8619b72 commit 506c011

File tree

11 files changed

+69
-98
lines changed

11 files changed

+69
-98
lines changed

.github/workflows/e2e-suite.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ jobs:
4646
env:
4747
LINODE_CLI_TOKEN: ${{ secrets.LINODE_TOKEN }}
4848

49+
- name: Set release version env
50+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
51+
52+
- name: Add additional information to XML report
53+
run: |
54+
echo $RELEASE_VERSION
55+
echo ${{ env.RELEASE_VERSION }}
56+
filename=$(ls | grep -E '^[0-9]{12}_cli_test_report\.xml$')
57+
python scripts/add_to_xml_test_report.py \
58+
--branch_name "${{ env.RELEASE_VERSION }}" \
59+
--gha_run_id "$GITHUB_RUN_ID" \
60+
--gha_run_number "$GITHUB_RUN_NUMBER" \
61+
--xmlfile "${filename}"
62+
4963
- name: Upload test results
5064
run: |
5165
filename=$(ls | grep -E '^[0-9]{12}_cli_test_report\.xml$')

linodecli/api_request.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,7 @@ def _build_request_body(ctx, operation, parsed_args) -> Optional[str]:
206206

207207
# Merge defaults into body if applicable
208208
if ctx.defaults:
209-
parsed_args = ctx.config.update(
210-
parsed_args, operation.allowed_defaults, operation.action
211-
)
209+
parsed_args = ctx.config.update(parsed_args, operation.allowed_defaults)
212210

213211
to_json = {}
214212

linodecli/configuration/__init__.py

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def plugin_get_value(self, key):
216216
# might be better to move this to argparsing during refactor and just have
217217
# configuration return defaults or keys or something
218218
def update(
219-
self, namespace, allowed_defaults, action=None
219+
self, namespace, allowed_defaults
220220
): # pylint: disable=too-many-branches
221221
"""
222222
This updates a Namespace (as returned by ArgumentParser) with config values
@@ -247,17 +247,6 @@ def update(
247247
value = None
248248
if self.config.has_option(username, key):
249249
value = self.config.get(username, key)
250-
# different types of database creation use different endpoints,
251-
# so we need to set the default engine value based on the type
252-
elif key == "engine":
253-
if action == "mysql-create" and self.config.has_option(
254-
username, "mysql_engine"
255-
):
256-
value = self.config.get(username, "mysql_engine")
257-
elif action == "postgresql-create" and self.config.has_option(
258-
username, "postgresql_engine"
259-
):
260-
value = self.config.get(username, "postgresql_engine")
261250
else:
262251
value = ns_dict[key]
263252

@@ -354,15 +343,6 @@ def configure(
354343
images = [
355344
i["id"] for i in _do_get_request(self.base_url, "/images")["data"]
356345
]
357-
engines_list = _do_get_request(self.base_url, "/databases/engines")[
358-
"data"
359-
]
360-
mysql_engines = [
361-
e["id"] for e in engines_list if e["engine"] == "mysql"
362-
]
363-
postgresql_engines = [
364-
e["id"] for e in engines_list if e["engine"] == "postgresql"
365-
]
366346

367347
is_full_access = _check_full_access(self.base_url, token)
368348

@@ -414,26 +394,6 @@ def configure(
414394
),
415395
)
416396

417-
config["mysql_engine"] = _default_thing_input(
418-
"Default Engine to create a Managed MySQL Database.",
419-
mysql_engines,
420-
"Default Engine (Optional): ",
421-
"Please select a valid MySQL Database Engine, or press Enter to skip",
422-
current_value=_config_get_with_default(
423-
self.config, username, "mysql_engine"
424-
),
425-
)
426-
427-
config["postgresql_engine"] = _default_thing_input(
428-
"Default Engine to create a Managed PostgreSQL Database.",
429-
postgresql_engines,
430-
"Default Engine (Optional): ",
431-
"Please select a valid PostgreSQL Database Engine, or press Enter to skip",
432-
current_value=_config_get_with_default(
433-
self.config, username, "postgresql_engine"
434-
),
435-
)
436-
437397
if auth_users:
438398
config["authorized_users"] = _default_thing_input(
439399
"Select the user that should be given default SSH access to new Linodes.",

linodecli/output.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,7 @@ def _select_json_elements(keys, json_res):
372372

373373
results.append(selected)
374374

375-
if len(results) > 0:
376-
ret[k] = results
375+
ret[k] = results
377376

378377
return ret
379378

scripts/add_to_xml_test_report.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import argparse
2+
import xml.etree.ElementTree as ET
3+
4+
# Parse command-line arguments
5+
parser = argparse.ArgumentParser(description='Modify XML with workflow information')
6+
parser.add_argument('--branch_name', required=True)
7+
parser.add_argument('--gha_run_id', required=True)
8+
parser.add_argument('--gha_run_number', required=True)
9+
parser.add_argument('--xmlfile', required=True) # Added argument for XML file path
10+
11+
args = parser.parse_args()
12+
13+
# Open and parse the XML file
14+
xml_file_path = args.xmlfile
15+
tree = ET.parse(xml_file_path)
16+
root = tree.getroot()
17+
18+
# Create new elements for the information
19+
branch_name_element = ET.Element('branch_name')
20+
branch_name_element.text = args.branch_name
21+
22+
gha_run_id_element = ET.Element('gha_run_id')
23+
gha_run_id_element.text = args.gha_run_id
24+
25+
gha_run_number_element = ET.Element('gha_run_number')
26+
gha_run_number_element.text = args.gha_run_number
27+
28+
# Add the new elements to the root of the XML
29+
root.append(branch_name_element)
30+
root.append(gha_run_id_element)
31+
root.append(gha_run_number_element)
32+
33+
# Save the modified XML
34+
modified_xml_file_path = xml_file_path # Overwrite it
35+
tree.write(modified_xml_file_path)
36+
37+
print(f'Modified XML saved to {modified_xml_file_path}')

tests/integration/events/test_events.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ def test_filter_events_by_entity_id():
184184
)
185185

186186

187+
@pytest.mark.skip(reason="https://github.com/linode/linode-cli/issues/500")
187188
def test_create_domain_and_filter_domain_events(events_setup):
188189
domain_id = events_setup
189190
result = exec_test_command(

tests/integration/image/test_plugin_image_upload.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,8 @@ def test_file_upload(
8080
assert process.returncode == 0
8181

8282
# Assertions now using keywords due to some chars getting cut off from lack of terminal space
83-
assert re.search("cli-test", output)
83+
assert re.search("[0-9][0-9]+.[0-9]%", output)
8484
assert re.search("test", output)
85-
assert re.search("pending", output)
8685

8786
# Get the new image from the API
8887
process = exec_test_command(

tests/integration/tags/test_tags.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import pytest
44

55
from tests.integration.helpers import (
6+
delete_target_id,
67
exec_failing_test_command,
78
exec_test_command,
89
)
@@ -20,8 +21,11 @@ def test_create_tag():
2021
exec_test_command(
2122
BASE_CMD + ["create", "--label", unique_tag, "--text", "--no-headers"]
2223
).stdout.decode()
24+
2325
yield unique_tag
2426

27+
delete_target_id("tags", unique_tag)
28+
2529

2630
@pytest.mark.smoke
2731
def test_view_unique_tag(test_create_tag):

tests/unit/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
image = linode/ubuntu21.10
1818
token = notafaketoken
1919
type = g6-nanode-1
20-
mysql_engine = mysql/8.0.26
2120
"""
2221

2322
LOADED_FILES = {}

tests/unit/test_api_request.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,39 +56,37 @@ def test_request_debug_info(self):
5656
assert "> " in output
5757

5858
def test_build_request_body(self, mock_cli, create_operation):
59-
create_operation.allowed_defaults = ["region", "engine"]
60-
create_operation.action = "mysql-create"
59+
create_operation.allowed_defaults = ["region", "image"]
6160

6261
result = api_request._build_request_body(
6362
mock_cli,
6463
create_operation,
6564
SimpleNamespace(
6665
generic_arg="foo",
6766
region=None,
68-
engine=None,
67+
image=None,
6968
),
7069
)
7170
assert (
7271
json.dumps(
7372
{
7473
"generic_arg": "foo",
7574
"region": "us-southeast",
76-
"engine": "mysql/8.0.26",
75+
"image": "linode/ubuntu21.10",
7776
}
7877
)
7978
== result
8079
)
8180

8281
def test_build_request_body_null_field(self, mock_cli, create_operation):
83-
create_operation.allowed_defaults = ["region", "engine"]
84-
create_operation.action = "mysql-create"
82+
create_operation.allowed_defaults = ["region", "image"]
8583
result = api_request._build_request_body(
8684
mock_cli,
8785
create_operation,
8886
SimpleNamespace(
8987
generic_arg="foo",
9088
region=None,
91-
engine=None,
89+
image=None,
9290
nullable_int=ExplicitNullValue(),
9391
),
9492
)
@@ -97,7 +95,7 @@ def test_build_request_body_null_field(self, mock_cli, create_operation):
9795
{
9896
"generic_arg": "foo",
9997
"region": "us-southeast",
100-
"engine": "mysql/8.0.26",
98+
"image": "linode/ubuntu21.10",
10199
"nullable_int": None,
102100
}
103101
)
@@ -107,15 +105,14 @@ def test_build_request_body_null_field(self, mock_cli, create_operation):
107105
def test_build_request_body_non_null_field(
108106
self, mock_cli, create_operation
109107
):
110-
create_operation.allowed_defaults = ["region", "engine"]
111-
create_operation.action = "mysql-create"
108+
create_operation.allowed_defaults = ["region", "image"]
112109
result = api_request._build_request_body(
113110
mock_cli,
114111
create_operation,
115112
SimpleNamespace(
116113
generic_arg="foo",
117114
region=None,
118-
engine=None,
115+
image=None,
119116
nullable_int=12345,
120117
),
121118
)
@@ -124,7 +121,7 @@ def test_build_request_body_non_null_field(
124121
{
125122
"generic_arg": "foo",
126123
"region": "us-southeast",
127-
"engine": "mysql/8.0.26",
124+
"image": "linode/ubuntu21.10",
128125
"nullable_int": 12345,
129126
}
130127
)

0 commit comments

Comments
 (0)