From fbb90535ba1ed3989d0d54a4904bfe16f77d6668 Mon Sep 17 00:00:00 2001 From: Amanda Rodrigues da Silva Date: Mon, 14 Feb 2022 14:33:00 -0300 Subject: [PATCH] edit agent name and tag scenarios --- .../docs/agents/edit_agent_name_and_tags.md | 17 +++++ python-test/docs/development_guide.md | 71 ++++++++++--------- python-test/docs/index.md | 4 ++ ...t_agent_name_and_apply_policies_to_then.md | 16 +++++ ...ply_policies_to_group_matching_new_tags.md | 15 ++++ python-test/docs/sanity.md | 4 ++ python-test/docs/smoke.md | 2 + python-test/features/agentsProvider.feature | 67 +++++++++++++++-- python-test/features/integration.feature | 52 ++++++++++---- .../steps/control_plane_agent_groups.py | 4 +- .../features/steps/control_plane_agents.py | 26 ++++++- python-test/features/steps/utils.py | 2 +- python-test/mkdocs.yml | 10 ++- 13 files changed, 233 insertions(+), 57 deletions(-) create mode 100644 python-test/docs/agents/edit_agent_name_and_tags.md create mode 100644 python-test/docs/integration/edit_agent_name_and_apply_policies_to_then.md create mode 100644 python-test/docs/integration/insert_tags_in_agents_created_without_tags_and_apply_policies_to_group_matching_new_tags.md diff --git a/python-test/docs/agents/edit_agent_name_and_tags.md b/python-test/docs/agents/edit_agent_name_and_tags.md new file mode 100644 index 000000000..fe1b29a4a --- /dev/null +++ b/python-test/docs/agents/edit_agent_name_and_tags.md @@ -0,0 +1,17 @@ +## Scenario: Edit agent name and tags +## Steps: +1 - Create an agent + +- REST API Method: POST +- endpoint: /agents +- header: {authorization:token} + +2- Edit this agent and tags + +- REST API Method: PUT +- endpoint: /agents/agent_id +- header: {authorization:token} + + +## Expected Result: +- Request must have status code 200 (ok) and changes must be applied \ No newline at end of file diff --git a/python-test/docs/development_guide.md b/python-test/docs/development_guide.md index 9c5103d88..b1d037e45 100644 --- a/python-test/docs/development_guide.md +++ b/python-test/docs/development_guide.md @@ -1,35 +1,37 @@ ## **INTEGRATION** -| Integration Scenario | Automated via API | Automated via UI | Smoke | Sanity | -|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-----------------:|:----------------:|:-----:|:------:| -| [Check if sink is active while scraping metrics](integration/sink_active_while_scraping_metrics.md) | ✅ | | 👍 | 👍 | -| [Check if sink with invalid credentials becomes active](integration/sink_error_invalid_credentials.md) | ✅ | | 👍 | 👍 | -| [Check if after 30 minutes without data sink becomes idle](integration/sink_idle_30_minutes.md) | | | | | -| [Provision agent before group (check if agent subscribes to the group)](integration/provision_agent_before_group.md) | ✅ | | 👍 | 👍 | -| [Provision agent after group (check if agent subscribes to the group)](integration/provision_agent_after_group.md) | ✅ | | 👍 | 👍 | -| [Provision agent with tag matching existing group linked to a valid dataset](integration/multiple_agents_subscribed_to_a_group.md) | ✅ | | 👍 | 👍 | -| [Apply multiple policies to a group](integration/apply_multiple_policies.md) | ✅ | | 👍 | 👍 | -| [Apply multiple policies to a group and remove one policy](integration/remove_one_of_multiple_policies.md) | ✅ | | 👍 | 👍 | -| [Apply multiple policies to a group and remove all of them](integration/remove_all_policies.md) | | | | | -| [Apply multiple policies to a group and remove one dataset](integration/remove_one_of_multiple_datasets.md) | ✅ | | 👍 | 👍 | -| [Apply multiple policies to a group and remove all datasets](integration/remove_all_datasets.md) | | | | | -| [Apply the same policy twice to the agent](integration/apply_policy_twice.md) | ✅ | | 👍 | 👍 | -| [Delete sink linked to a dataset, create another one and edit dataset using new sink](integration/change_sink_on_dataset.md) | | | | | -| [Remove one of multiples datasets that apply the same policy to the agent](integration/remove_one_dataset_of_multiples_with_same_policy.md) | | | | | -| [Remove group (invalid dataset, agent logs)](integration/remove_group.md) | ✅ | | 👍 | 👍 | -| [Remove sink (invalid dataset, agent logs)](integration/remove_sink.md) | | | 👍 | 👍 | -| [Remove policy (invalid dataset, agent logs, heartbeat)](integration/remove_policy.md) | ✅ | | 👍 | 👍 | -| [Remove dataset (check agent logs, heartbeat)](integration/remove_dataset.md) | ✅ | | 👍 | 👍 | -| [Remove agent container (logs, agent groups matches)](integration/remove_agent_container.md) | | | 👍 | 👍 | -| [Remove agent container force (logs, agent groups matches)](integration/remove_agent_container_force.md) | | | 👍 | 👍 | -| [Remove agent (logs, agent groups matches)](integration/remove_agent.md) | | | 👍 | 👍 | -| [Subscribe an agent to multiple groups created before agent provisioning](integration/subscribe_an_agent_to_multiple_groups_created_before_agent_provisioning.md) | ✅ | | 👍 | 👍 | -| [Subscribe an agent to multiple groups created after agent provisioning](integration/subscribe_an_agent_to_multiple_groups_created_after_agent_provisioning.md) | ✅ | | 👍 | 👍 | -| [Agent subscription to group after editing agent's tags (editing before agent provision)](integration/agent_subscription_to_group_after_editing_agent's_tags.md) | ✅ | | 👍 | 👍 | -| [Agent subscription to group after editing agent's tags (editing after agent provision and after groups creation)](integration/agent_subscription_to_group_after_editing_agent's_tags.md) | ✅ | | 👍 | 👍 | -| [Agent subscription to group after editing agent's tags (editing after agent provision and before second group creation)](integration/agent_subscription_to_group_after_editing_agent's_tags.md) | ✅ | | 👍 | 👍 | -| [Agent subscription to group with policies after editing agent's tags](integration/agent_subscription_to_group_with_policies_after_editing_agent's_tags.md) | ✅ | | 👍 | 👍 | -| [Agent subscription to multiple groups with policies after editing agent's tags](integration/agent_subscription_to_group_with_policies_after_editing_agent's_tags.md) | ✅ | | 👍 | 👍 | +| Integration Scenario | Automated via API | Automated via UI | Smoke | Sanity | +|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-----------------:|:----------------:|:-----:|:------:| +| [Check if sink is active while scraping metrics](integration/sink_active_while_scraping_metrics.md) | ✅ | | 👍 | 👍 | +| [Check if sink with invalid credentials becomes active](integration/sink_error_invalid_credentials.md) | ✅ | | 👍 | 👍 | +| [Check if after 30 minutes without data sink becomes idle](integration/sink_idle_30_minutes.md) | | | | | +| [Provision agent before group (check if agent subscribes to the group)](integration/provision_agent_before_group.md) | ✅ | | 👍 | 👍 | +| [Provision agent after group (check if agent subscribes to the group)](integration/provision_agent_after_group.md) | ✅ | | 👍 | 👍 | +| [Provision agent with tag matching existing group linked to a valid dataset](integration/multiple_agents_subscribed_to_a_group.md) | ✅ | | 👍 | 👍 | +| [Apply multiple policies to a group](integration/apply_multiple_policies.md) | ✅ | | 👍 | 👍 | +| [Apply multiple policies to a group and remove one policy](integration/remove_one_of_multiple_policies.md) | ✅ | | 👍 | 👍 | +| [Apply multiple policies to a group and remove all of them](integration/remove_all_policies.md) | | | | | +| [Apply multiple policies to a group and remove one dataset](integration/remove_one_of_multiple_datasets.md) | ✅ | | 👍 | 👍 | +| [Apply multiple policies to a group and remove all datasets](integration/remove_all_datasets.md) | | | | | +| [Apply the same policy twice to the agent](integration/apply_policy_twice.md) | ✅ | | 👍 | 👍 | +| [Delete sink linked to a dataset, create another one and edit dataset using new sink](integration/change_sink_on_dataset.md) | | | | | +| [Remove one of multiples datasets that apply the same policy to the agent](integration/remove_one_dataset_of_multiples_with_same_policy.md) | | | | | +| [Remove group (invalid dataset, agent logs)](integration/remove_group.md) | ✅ | | 👍 | 👍 | +| [Remove sink (invalid dataset, agent logs)](integration/remove_sink.md) | | | 👍 | 👍 | +| [Remove policy (invalid dataset, agent logs, heartbeat)](integration/remove_policy.md) | ✅ | | 👍 | 👍 | +| [Remove dataset (check agent logs, heartbeat)](integration/remove_dataset.md) | ✅ | | 👍 | 👍 | +| [Remove agent container (logs, agent groups matches)](integration/remove_agent_container.md) | | | 👍 | 👍 | +| [Remove agent container force (logs, agent groups matches)](integration/remove_agent_container_force.md) | | | 👍 | 👍 | +| [Remove agent (logs, agent groups matches)](integration/remove_agent.md) | | | 👍 | 👍 | +| [Subscribe an agent to multiple groups created before agent provisioning](integration/subscribe_an_agent_to_multiple_groups_created_before_agent_provisioning.md) | ✅ | | 👍 | 👍 | +| [Subscribe an agent to multiple groups created after agent provisioning](integration/subscribe_an_agent_to_multiple_groups_created_after_agent_provisioning.md) | ✅ | | 👍 | 👍 | +| [Agent subscription to group after editing agent's tags (editing before agent provision)](integration/agent_subscription_to_group_after_editing_agent's_tags.md) | ✅ | | 👍 | 👍 | +| [Agent subscription to group after editing agent's tags (editing after agent provision and after groups creation)](integration/agent_subscription_to_group_after_editing_agent's_tags.md) | ✅ | | 👍 | 👍 | +| [Agent subscription to group after editing agent's tags (editing after agent provision and before second group creation)](integration/agent_subscription_to_group_after_editing_agent's_tags.md) | ✅ | | 👍 | 👍 | +| [Agent subscription to group with policies after editing agent's tags](integration/agent_subscription_to_group_with_policies_after_editing_agent's_tags.md) | ✅ | | 👍 | 👍 | +| [Agent subscription to multiple groups with policies after editing agent's tags](integration/agent_subscription_to_group_with_policies_after_editing_agent's_tags.md) | ✅ | | 👍 | 👍 | +| [Edit agent name and apply policies to then](integration/edit_agent_name_and_apply_policies_to_then.md) | ✅ | | 👍 | 👍 | +| [Insert tags in agents created without tags and apply policies to group matching new tags.md](integration/insert_tags_in_agents_created_without_tags_and_apply_policies_to_group_matching_new_tags.md) | ✅ | | 👍 | 👍 | --------------------------------- ## **LOGIN** @@ -70,10 +72,11 @@ | [Test agent filters](agents/test_agent_filters.md) | | | | | | [Check agent details](agents/check_agent_details.md) | | | | 👍 | | [Edit an agent through the details modal](agents/edit_an_agent_through_the_details_modal.md) | | | | 👍 | -| [Edit agent name](agents/edit_agent_name.md) | | | 👍 | 👍 | -| [Edit agent tag](agents/edit_agent_tag.md) | | | 👍 | 👍 | -| [Save agent without tag](agents/save_agent_without_tag.md) | | | | 👍 | -| [Insert tags in agents created without tags](agents/insert_tags_in_agents_created_without_tags.md) | | | 👍 | 👍 | +| [Edit agent name](agents/edit_agent_name.md) | ✅ | | 👍 | 👍 | +| [Edit agent tag](agents/edit_agent_tag.md) | ✅ | | 👍 | 👍 | +| [Edit agent name and tag](agents/edit_agent_name_and_tags.md) | ✅ | | | 👍 | +| [Save agent without tag](agents/save_agent_without_tag.md) | ✅ | | | 👍 | +| [Insert tags in agents created without tags](agents/insert_tags_in_agents_created_without_tags.md) | ✅ | | 👍 | 👍 | | [Check if is possible cancel operations with no change](agents/check_if_is_possible_cancel_operations_with_no_change.md) | | | | | | [Remove agent using correct name](agents/remove_agent_using_correct_name.md) | ✅ | | 👍 | 👍 | | [Remove agent using incorrect name](agents/remove_agent_using_incorrect_name.md) | | | | 👍 | diff --git a/python-test/docs/index.md b/python-test/docs/index.md index 61d422ddc..828e8a67a 100644 --- a/python-test/docs/index.md +++ b/python-test/docs/index.md @@ -39,6 +39,8 @@ - [Remove agent using incorrect name](agents/remove_agent_using_incorrect_name.md) - [Run two orb agents on the same port](agents/run_two_orb_agents_on_the_same_port.md) - [Run two orb agents on different ports](agents/run_two_orb_agents_on_different_ports.md) +- [Edit agent name and tag](agents/edit_agent_name_and_tags.md) + ## Agent Groups @@ -149,6 +151,8 @@ - [Subscribe an agent to multiple groups created after agent provisioning](integration/subscribe_an_agent_to_multiple_groups_created_after_agent_provisioning.md) - [Agent subscription to group after editing agent's tags](integration/agent_subscription_to_group_after_editing_agent's_tags.md) - [Agent subscription to group with policies after editing agent's tags](integration/agent_subscription_to_group_with_policies_after_editing_agent's_tags.md) +- [Edit agent name and apply policies to then](integration/edit_agent_name_and_apply_policies_to_then.md) +- [Insert tags in agents created without tags and apply policies to group matching new tags.md](integration/insert_tags_in_agents_created_without_tags_and_apply_policies_to_group_matching_new_tags.md) ## Pktvisor Agent diff --git a/python-test/docs/integration/edit_agent_name_and_apply_policies_to_then.md b/python-test/docs/integration/edit_agent_name_and_apply_policies_to_then.md new file mode 100644 index 000000000..dc485b6ac --- /dev/null +++ b/python-test/docs/integration/edit_agent_name_and_apply_policies_to_then.md @@ -0,0 +1,16 @@ +## Scenario: Edit agent name and apply policies to then +Steps: +- +1. Provision an agent with tags +2. Create a group with same tags as agent +3. Create a sink +4. Create 1 policy +5. Create a dataset linking the group, the sink and the policy +8. Edit agent name + +Expected result: +- +- Agent heartbeat must show just one group matching +- Agent logs must show that agent is subscribed to the group +- The container logs contain the message "policy applied successfully" referred to the policy applied to the second group +- The container logs that were output after all policies have been applied contains the message "scraped metrics for policy" referred to each applied policy diff --git a/python-test/docs/integration/insert_tags_in_agents_created_without_tags_and_apply_policies_to_group_matching_new_tags.md b/python-test/docs/integration/insert_tags_in_agents_created_without_tags_and_apply_policies_to_group_matching_new_tags.md new file mode 100644 index 000000000..5a44f4905 --- /dev/null +++ b/python-test/docs/integration/insert_tags_in_agents_created_without_tags_and_apply_policies_to_group_matching_new_tags.md @@ -0,0 +1,15 @@ +## Scenario: Insert tags in agents created without tags and apply policies to group matching new tags +## Steps: +1. Provision an agent without tags +2. Create a group with tags +3. Create a sink +4. Create 1 policy +5. Create a dataset linking the group, the sink and the policy +8. Edit agent name and tags, using the same tag as the group + +Expected result: +- +- Agent heartbeat must show just one group matching +- Agent logs must show that agent is subscribed to the group +- The container logs contain the message "policy applied successfully" referred to the policy applied to the second group +- The container logs that were output after all policies have been applied contains the message "scraped metrics for policy" referred to each applied policy diff --git a/python-test/docs/sanity.md b/python-test/docs/sanity.md index da1789b66..b5ecf056a 100644 --- a/python-test/docs/sanity.md +++ b/python-test/docs/sanity.md @@ -37,6 +37,8 @@ - [Remove agent using incorrect name](agents/remove_agent_using_incorrect_name.md) - [Run two orb agents on the same port](agents/run_two_orb_agents_on_the_same_port.md) - [Run two orb agents on different ports](agents/run_two_orb_agents_on_different_ports.md) +- [Edit agent name and tag](agents/edit_agent_name_and_tags.md) + ## Agent Groups @@ -127,3 +129,5 @@ - [Subscribe an agent to multiple groups created after agent provisioning](integration/subscribe_an_agent_to_multiple_groups_created_after_agent_provisioning.md) - [Agent subscription to group after editing agent's tags](integration/agent_subscription_to_group_after_editing_agent's_tags.md) - [Agent subscription to group with policies after editing agent's tags](integration/agent_subscription_to_group_with_policies_after_editing_agent's_tags.md) +- [Edit agent name and apply policies to then](integration/edit_agent_name_and_apply_policies_to_then.md) +- [Insert tags in agents created without tags and apply policies to group matching new tags.md](integration/insert_tags_in_agents_created_without_tags_and_apply_policies_to_group_matching_new_tags.md) diff --git a/python-test/docs/smoke.md b/python-test/docs/smoke.md index 1817598f9..8a6045140 100644 --- a/python-test/docs/smoke.md +++ b/python-test/docs/smoke.md @@ -84,3 +84,5 @@ - [Subscribe an agent to multiple groups created after agent provisioning](integration/subscribe_an_agent_to_multiple_groups_created_after_agent_provisioning.md) - [Agent subscription to group after editing agent's tags](integration/agent_subscription_to_group_after_editing_agent's_tags.md) - [Agent subscription to group with policies after editing agent's tags](integration/agent_subscription_to_group_with_policies_after_editing_agent's_tags.md) +- [Edit agent name and apply policies to then](integration/edit_agent_name_and_apply_policies_to_then.md) +- [Insert tags in agents created without tags and apply policies to group matching new tags.md](integration/insert_tags_in_agents_created_without_tags_and_apply_policies_to_group_matching_new_tags.md) diff --git a/python-test/features/agentsProvider.feature b/python-test/features/agentsProvider.feature index 419d86ad9..e7633d98b 100644 --- a/python-test/features/agentsProvider.feature +++ b/python-test/features/agentsProvider.feature @@ -31,17 +31,72 @@ Feature: agent provider Scenario: Provision agent without tags Given the Orb user has a registered account - And the Orb user logs in + And the Orb user logs in When a new agent is created with 0 orb tag(s) - And the agent container is started on port default + And the agent container is started on port default Then the agent status in Orb should be online - And the container logs should contain the message "sending capabilities" within 10 seconds + And the container logs should contain the message "sending capabilities" within 10 seconds Scenario: Provision agent with multiple tags Given the Orb user has a registered account - And the Orb user logs in + And the Orb user logs in When a new agent is created with 5 orb tag(s) - And the agent container is started on port default + And the agent container is started on port default Then the agent status in Orb should be online - And the container logs should contain the message "sending capabilities" within 10 seconds \ No newline at end of file + And the container logs should contain the message "sending capabilities" within 10 seconds + + + Scenario: Edit agent tag + Given the Orb user has a registered account + And the Orb user logs in + And a new agent is created with 5 orb tag(s) + And the agent container is started on port default + When edit the agent tags and use 3 orb tag(s) + Then the container logs should contain the message "sending capabilities" within 10 seconds + And agent must have 3 tags + And the agent status in Orb should be online + + + Scenario: Save agent without tag + Given the Orb user has a registered account + And the Orb user logs in + And a new agent is created with 5 orb tag(s) + And the agent container is started on port default + When edit the agent tags and use 0 orb tag(s) + Then the container logs should contain the message "sending capabilities" within 10 seconds + And agent must have 0 tags + And the agent status in Orb should be online + + + Scenario: Insert tags in agents created without tags + Given the Orb user has a registered account + And the Orb user logs in + And a new agent is created with 0 orb tag(s) + And the agent container is started on port default + When edit the agent tags and use 2 orb tag(s) + Then the container logs should contain the message "sending capabilities" within 10 seconds + And agent must have 2 tags + And the agent status in Orb should be online + + + Scenario: Edit agent name + Given the Orb user has a registered account + And the Orb user logs in + And a new agent is created with 1 orb tag(s) + And the agent container is started on port default + When edit the agent name + Then the container logs should contain the message "sending capabilities" within 10 seconds + And agent must have 1 tags + And the agent status in Orb should be online + + + Scenario: Edit agent name and tags + Given the Orb user has a registered account + And the Orb user logs in + And a new agent is created with 1 orb tag(s) + And the agent container is started on port default + When edit the agent name and edit agent tags using 3 orb tag(s) + Then the container logs should contain the message "sending capabilities" within 10 seconds + And agent must have 3 tags + And the agent status in Orb should be online \ No newline at end of file diff --git a/python-test/features/integration.feature b/python-test/features/integration.feature index 1ec3ea113..d9c35c368 100644 --- a/python-test/features/integration.feature +++ b/python-test/features/integration.feature @@ -240,18 +240,46 @@ Scenario: Agent subscription to multiple group with policies after editing agent Scenario: Agent subscription to group with policies after editing agent's tags (editing tags after agent provision) Given the Orb user has a registered account - And the Orb user logs in - And that an agent with 1 orb tag(s) already exists and is online - And referred agent is subscribed to a group - And that a sink already exists - And 2 policies are applied to the group - And this agent's heartbeat shows that 2 policies are successfully applied - And an Agent Group is created with region:br orb tag(s) - And 1 policies are applied to the group + And the Orb user logs in + And that an agent with 1 orb tag(s) already exists and is online + And referred agent is subscribed to a group + And that a sink already exists + And 2 policies are applied to the group + And this agent's heartbeat shows that 2 policies are successfully applied + And an Agent Group is created with region:br orb tag(s) + And 1 policies are applied to the group When edit the agent tags and use region:br orb tag(s) Then the container logs contain the message "completed RPC subscription to group" referred to each matching group within 10 seconds - And this agent's heartbeat shows that 1 policies are successfully applied - And this agent's heartbeat shows that 1 groups are matching the agent - And the container logs contain the message "policy applied successfully" referred to each policy within 10 seconds - And the container logs that were output after all policies have been applied contain the message "scraped metrics for policy" referred to each applied policy within 180 seconds + And this agent's heartbeat shows that 1 policies are successfully applied + And this agent's heartbeat shows that 1 groups are matching the agent + And the container logs contain the message "policy applied successfully" referred to each policy within 10 seconds + And the container logs that were output after all policies have been applied contain the message "scraped metrics for policy" referred to each applied policy within 180 seconds + + Scenario: Insert tags in agents created without tags and apply policies to group matching new tags + Given the Orb user has a registered account + And the Orb user logs in + And a new agent is created with 0 orb tag(s) + And the agent container is started on port default + And that a sink already exists + When edit the agent tags and use 2 orb tag(s) + And an Agent Group is created with same tag as the agent + And 1 policies are applied to the group + Then this agent's heartbeat shows that 1 policies are successfully applied + And the container logs contain the message "completed RPC subscription to group" referred to each matching group within 10 seconds + And this agent's heartbeat shows that 1 groups are matching the agent + And the container logs contain the message "policy applied successfully" referred to each policy within 10 seconds + And the container logs that were output after all policies have been applied contain the message "scraped metrics for policy" referred to each applied policy within 180 seconds + + + Scenario: Edit agent name and apply policies to then + Given the Orb user has a registered account + And the Orb user logs in + And that an agent with 5 orb tag(s) already exists and is online + And an Agent Group is created with same tag as the agent + And one agent must be matching on response field matching_agents + And that a sink already exists + And 1 policies are applied to the group + When edit the agent name and edit agent tags using 3 orb tag(s) + Then this agent's heartbeat shows that 1 policies are successfully applied + And the container logs contain the message "policy applied successfully" referred to each policy within 10 seconds \ No newline at end of file diff --git a/python-test/features/steps/control_plane_agent_groups.py b/python-test/features/steps/control_plane_agent_groups.py index d0caa113f..a23db713b 100644 --- a/python-test/features/steps/control_plane_agent_groups.py +++ b/python-test/features/steps/control_plane_agent_groups.py @@ -14,7 +14,7 @@ base_orb_url = configs.get('base_orb_url') -@when("an Agent Group is created with same tag as the agent") +@step("an Agent Group is created with same tag as the agent") def create_agent_group_matching_agent(context): agent_group_name = agent_group_name_prefix + random_string() tags = context.agent["orb_tags"] @@ -47,7 +47,7 @@ def error_response_message(context, message): assert_that(response_value, equal_to(message), "Unexpected message for error") -@then("one agent must be matching on response field matching_agents") +@step("one agent must be matching on response field matching_agents") def matching_agent(context): matching_total_agents = context.agent_group_data['matching_agents']['total'] matching_online_agents = context.agent_group_data['matching_agents']['online'] diff --git a/python-test/features/steps/control_plane_agents.py b/python-test/features/steps/control_plane_agents.py index 61e21badf..0ed4b4cb2 100644 --- a/python-test/features/steps/control_plane_agents.py +++ b/python-test/features/steps/control_plane_agents.py @@ -115,13 +115,37 @@ def list_groups_matching_an_agent(context, amount_of_groups): @step("edit the agent tags and use {orb_tags} orb tag(s)") -def editing_agent(context, orb_tags): +def editing_agent_tags(context, orb_tags): agent = get_agent(context.token, context.agent["id"]) context.orb_tags = create_tags_set(orb_tags) edit_agent(context.token, context.agent["id"], agent["name"], context.orb_tags, expected_status_code=200) context.agent = get_agent(context.token, context.agent["id"]) +@step("edit the agent name") +def editing_agent_name(context): + agent = get_agent(context.token, context.agent["id"]) + agent_new_name = generate_random_string_with_predefined_prefix(agent_name_prefix, 5) + edit_agent(context.token, context.agent["id"], agent_new_name, agent['orb_tags'], expected_status_code=200) + context.agent = get_agent(context.token, context.agent["id"]) + assert_that(context.agent["name"], equal_to(agent_new_name), "Agent name editing failed") + + +@step("edit the agent name and edit agent tags using {orb_tags} orb tag(s)") +def editing_agent_name_and_tags(context, orb_tags): + agent_new_name = generate_random_string_with_predefined_prefix(agent_name_prefix, 5) + context.orb_tags = create_tags_set(orb_tags) + edit_agent(context.token, context.agent["id"], agent_new_name, context.orb_tags, expected_status_code=200) + context.agent = get_agent(context.token, context.agent["id"]) + assert_that(context.agent["name"], equal_to(agent_new_name), "Agent name editing failed") + + +@step("agent must have {amount_of_tags} tags") +def check_agent_tags(context, amount_of_tags): + agent = get_agent(context.token, context.agent["id"]) + assert_that(len(dict(agent["orb_tags"])), equal_to(int(amount_of_tags)), "Amount of orb tags failed") + + def expect_container_status(token, agent_id, status): """ Keeps fetching agent data from Orb control plane until it gets to diff --git a/python-test/features/steps/utils.py b/python-test/features/steps/utils.py index 9043640f1..0a40b89ea 100644 --- a/python-test/features/steps/utils.py +++ b/python-test/features/steps/utils.py @@ -57,7 +57,7 @@ def insert_str(str_base, str_to_insert, index): def generate_random_string_with_predefined_prefix(string_prefix, n_random=10): """ :param (str) string_prefix: prefix to identify object created by tests - :param (str) n_random: amount of random characters + :param (int) n_random: amount of random characters :return: random_string_with_predefined_prefix """ random_string_with_predefined_prefix = string_prefix + random_string(n_random) diff --git a/python-test/mkdocs.yml b/python-test/mkdocs.yml index 7f7475588..5c8af50af 100644 --- a/python-test/mkdocs.yml +++ b/python-test/mkdocs.yml @@ -44,6 +44,7 @@ nav: - Check if is possible cancel operations with no change: agents/check_if_is_possible_cancel_operations_with_no_change.md - Remove agent using correct name: agents/remove_agent_using_correct_name.md - Remove agent using incorrect name: agents/remove_agent_using_incorrect_name.md + - Edit agent name and tag: agents/edit_agent_name_and_tags.md - Agent Groups Scenarios: - Check if total agent groups on agent groups' page is correct: agent_groups/check_if_total_agent_groups_on_agent_groups'_page_is_correct.md - Create agent group with invalid name (regex): agent_groups/create_agent_group_with_invalid_name_(regex).md @@ -145,6 +146,8 @@ nav: - Subscribe an agent to multiple groups created after agent provisioning: integration/subscribe_an_agent_to_multiple_groups_created_after_agent_provisioning.md - Agent subscription to group after editing agent's tags: integration/agent_subscription_to_group_after_editing_agent's_tags.md - Agent subscription to group with policies after editing agent's tags: integration/agent_subscription_to_group_with_policies_after_editing_agent's_tags.md + - Edit agent name and apply policies to then: integration/edit_agent_name_and_apply_policies_to_then.md + - Insert tags in agents created without tags and apply policies to group matching new tags.md: integration/insert_tags_in_agents_created_without_tags_and_apply_policies_to_group_matching_new_tags.md - Suites: - Smoke: @@ -187,6 +190,8 @@ nav: - Subscribe an agent to multiple groups created after agent provisioning: integration/subscribe_an_agent_to_multiple_groups_created_after_agent_provisioning.md - Agent subscription to group after editing agent's tags: integration/agent_subscription_to_group_after_editing_agent's_tags.md - Agent subscription to group with policies after editing agent's tags: integration/agent_subscription_to_group_with_policies_after_editing_agent's_tags.md + - Edit agent name and apply policies to then: integration/edit_agent_name_and_apply_policies_to_then.md + - Insert tags in agents created without tags and apply policies to group matching new tags.md: integration/insert_tags_in_agents_created_without_tags_and_apply_policies_to_group_matching_new_tags.md - Sanity: - Sanity list: sanity.md - Sanity tests: @@ -221,4 +226,7 @@ nav: - Subscribe an agent to multiple groups created before agent provisioning: integration/subscribe_an_agent_to_multiple_groups_created_before_agent_provisioning.md - Subscribe an agent to multiple groups created after agent provisioning: integration/subscribe_an_agent_to_multiple_groups_created_after_agent_provisioning.md - Agent subscription to group after editing agent's tags: integration/agent_subscription_to_group_after_editing_agent's_tags.md - - Agent subscription to group with policies after editing agent's tags: integration/agent_subscription_to_group_with_policies_after_editing_agent's_tags.md \ No newline at end of file + - Agent subscription to group with policies after editing agent's tags: integration/agent_subscription_to_group_with_policies_after_editing_agent's_tags.md + - Edit agent name and tag: agents/edit_agent_name_and_tags.md + - Edit agent name and apply policies to then: integration/edit_agent_name_and_apply_policies_to_then.md + - Insert tags in agents created without tags and apply policies to group matching new tags.md: integration/insert_tags_in_agents_created_without_tags_and_apply_policies_to_group_matching_new_tags.md