Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Properties Arg Format Inconsistencies #109

Open
scottcurtis2605 opened this issue Dec 5, 2024 · 0 comments
Open

Custom Properties Arg Format Inconsistencies #109

scottcurtis2605 opened this issue Dec 5, 2024 · 0 comments

Comments

@scottcurtis2605
Copy link

scottcurtis2605 commented Dec 5, 2024

Hello,

There are inconsistencies with configuring synthetic test custom-properties across create/update/patch operations.

When passing custom properties during creation of a synthetic test, these are to be specified in dict format:

synctl create test -t 1 \
    --custom-properties '{"key1":"value1"}'

Ref, synctl docs

The source for this can be found here:

synthetic-synctl/synctl/cli.py

Lines 1200 to 1203 in 6d4d7de

def set_custom_properties(self, custom_prop: dict):
"""customProperties"""
if custom_prop is not None and isinstance(custom_prop, dict):
self.syn_test_config["customProperties"] = custom_prop

However, when passing custom properties during an update of a synthetic test, properties are to be specified in a map format:

# Update a Synthetic test with multiple options.
synctl update test <synthetic-id> \
    --custom-properties "key1=value1,key2=value2"

Ref, synctl docs.

The source for this can be found here:

synthetic-synctl/synctl/cli.py

Lines 3711 to 3720 in 6d4d7de

def update_custom_properties(self, custom_property):
"""update custom properties"""
if any(s == '' or s.isspace() for s in custom_property):
self.exit_synctl(ERROR_CODE, "Custom property should be <key>=<value>")
for item in custom_property:
key, value = item.split('=')
if key == '' or value == '':
self.exit_synctl(ERROR_CODE, "Custom property should be <key>=<value>")
self.update_config["customProperties"][key] = value

....additionally, when looking at the format for patch operations, these follow the update path's format:

# Set multiple custom properties of a test
synctl patch test <synthetic-id> \ 
    --custom-properties "key1=value1,key2=value2,key3=value3"

The source for this can be found here:

synthetic-synctl/synctl/cli.py

Lines 4246 to 4259 in 6d4d7de

def patch_custom_properties(self, test_id, custom_property):
"""update custom properties"""
test_result = self.retrieve_a_synthetic_test(test_id)
payload = test_result[0]
if any(s == '' or s.isspace() for s in custom_property):
self.exit_synctl(ERROR_CODE, "Custom property should be <key>=<value>")
for item in custom_property:
key, value = item.split('=')
if key == '' or value == '':
self.exit_synctl(ERROR_CODE, "Custom property should be <key>=<value>")
payload["customProperties"][key] = value
self.__patch_a_synthetic_test(self.test_id, json.dumps(payload))

Ref, synctl docs

Please make passing custom-properties consistent between create/update/patch operations.

Other synctl arguments within a consistent format, but the differing format for custom-properties results in difficulty when attempting to automate management of synthetic tests, especially when synctl is used in an automation framework.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant