From 655ddf7fb259ca7056423d91f37fc3fa7066016c Mon Sep 17 00:00:00 2001 From: Dmitry Belyaninov Date: Tue, 20 Dec 2016 04:57:04 +0000 Subject: [PATCH] Configs modification for 'fuel role' commands So Fuel was changed. There is mandatory config field 'tags'. Appropriate test configs should be changed too. Change-Id: I6d4d3699369187d2c1408092bbee65c3d3e2198a Closes-Bug: 1650497 --- .../config_templates/create_primary_role.yaml | 2 + .../config_templates/create_primary_tag.yaml | 3 + .../config_templates/create_role.yaml | 2 + fuelweb_test/config_templates/create_tag.yaml | 3 + fuelweb_test/tests/tests_cli/test_cli_role.py | 314 +++++++++++------- 5 files changed, 198 insertions(+), 126 deletions(-) create mode 100644 fuelweb_test/config_templates/create_primary_tag.yaml create mode 100644 fuelweb_test/config_templates/create_tag.yaml diff --git a/fuelweb_test/config_templates/create_primary_role.yaml b/fuelweb_test/config_templates/create_primary_role.yaml index 809c07739..4a722dc64 100644 --- a/fuelweb_test/config_templates/create_primary_role.yaml +++ b/fuelweb_test/config_templates/create_primary_role.yaml @@ -5,6 +5,8 @@ meta: description: New role has_primary: true name: Test primary role + tags: + - test-primary-tag name: test-primary-role volumes_roles_mapping: - allocate_size: min diff --git a/fuelweb_test/config_templates/create_primary_tag.yaml b/fuelweb_test/config_templates/create_primary_tag.yaml new file mode 100644 index 000000000..966e15a22 --- /dev/null +++ b/fuelweb_test/config_templates/create_primary_tag.yaml @@ -0,0 +1,3 @@ +meta: + has_primary: true +name: test-primary-tag \ No newline at end of file diff --git a/fuelweb_test/config_templates/create_role.yaml b/fuelweb_test/config_templates/create_role.yaml index fcd4814e2..3db1d418c 100644 --- a/fuelweb_test/config_templates/create_role.yaml +++ b/fuelweb_test/config_templates/create_role.yaml @@ -4,6 +4,8 @@ meta: - compute description: New role name: Test role + tags: + - test-tag name: test-role volumes_roles_mapping: - allocate_size: min diff --git a/fuelweb_test/config_templates/create_tag.yaml b/fuelweb_test/config_templates/create_tag.yaml new file mode 100644 index 000000000..7753cf06a --- /dev/null +++ b/fuelweb_test/config_templates/create_tag.yaml @@ -0,0 +1,3 @@ +meta: + has_primary: false +name: test-tag \ No newline at end of file diff --git a/fuelweb_test/tests/tests_cli/test_cli_role.py b/fuelweb_test/tests/tests_cli/test_cli_role.py index 80ba1f0ad..3636299de 100644 --- a/fuelweb_test/tests/tests_cli/test_cli_role.py +++ b/fuelweb_test/tests/tests_cli/test_cli_role.py @@ -37,11 +37,11 @@ class CommandLineRoleTests(test_cli_base.CommandLine): 1. Setup master node 2. SSH to the master node 3. Download to file controller role with command: - fuel role --rel 2 --role controller --file controller.yaml - 4. Edit the controller.yaml file, + fuel2 role download -r 2 -n controller -f yaml -d /tmp + 4. Edit the /tmp/release_2/controller.yaml file, remove section "conflicts" under "meta" section. Save file 5. Update role from file with command: - fuel role --rel 2 --update --file controller.yaml + fuel2 role update -r 2 -n controller -d /tmp -f yaml 6. Go to the Fuel UI and try to create a new environment 7. Add new node to the environment, choose controller and compute roles for node @@ -54,24 +54,25 @@ class CommandLineRoleTests(test_cli_base.CommandLine): self.fuel_web.client.list_nodes()]) release_id = self.fuel_web.get_releases_list_for_os( release_name=OPENSTACK_RELEASE)[0] + role_descr = '/tmp/releases_{}/controller.yaml'.format(release_id) self.show_step(2) self.show_step(3) self.ssh_manager.execute_on_remote( ip=self.ssh_manager.admin_ip, - cmd='fuel role --rel {} --role controller --file' - ' /tmp/controller.yaml'.format(release_id)) + cmd='fuel2 role download -r {} -n controller -f yaml' + ' -d /tmp'.format(release_id)) self.show_step(4) self.ssh_manager.execute_on_remote( ip=self.ssh_manager.admin_ip, - cmd="sed -i '/conflicts/,+1 d' /tmp/controller.yaml") + cmd="sed -i '/conflicts/,+1 d' {}".format(role_descr)) self.show_step(5) self.ssh_manager.execute_on_remote( ip=self.ssh_manager.admin_ip, - cmd='fuel role --rel {} --update --file' - ' /tmp/controller.yaml'.format(release_id)) + cmd='fuel2 role update -r {} -n controller' + ' -d /tmp -f yaml'.format(release_id)) if NEUTRON_SEGMENT_TYPE: nst = '--nst={0}'.format(NEUTRON_SEGMENT_TYPE) @@ -88,8 +89,8 @@ class CommandLineRoleTests(test_cli_base.CommandLine): )['stdout_json'] cluster_id = env_result['id'] self.show_step(7) - cmd = ('fuel --env-id={0} node set --node {1} --role=controller,' - 'compute'.format(cluster_id, node_ids[0])) + cmd = ('fuel2 env add nodes -e {0} -n {1} -r controller' + ' compute'.format(cluster_id, node_ids[0])) result = self.ssh_manager.execute( ip=self.ssh_manager.admin_ip, cmd=cmd, @@ -109,29 +110,29 @@ class CommandLineRoleTests(test_cli_base.CommandLine): Scenario: 1. Create environment using fuel-qa 2. SSH to the master node - 3. Create new file "role.yaml" and paste the above: - + 3. Create new file "release_2/tag.yaml" and paste the above: meta: - conflicts: - - controller - - compute - - description: New role - - has_primary: true - - name: Test role - + has_primary: false + name: test-tag + 4. Define new tag with command: + fuel2 tag create -r 2 -n tag -f yaml + 5. Create new file "release_2/role.yaml" and paste the above: + meta: + conflicts: + - controller + - compute + description: New role + name: Test role + tags: + - test-tag name: test-role volumes_roles_mapping: - allocate_size: min - id: os - - 4. Create new role with command: - fuel role --rel 2 --create --file role.yaml - 5. Go to the Fuel UI and try to create a new environment - 6. Add new node to the environment, choose test-role + 6. Create new role with command: + fuel2 role create -r 2 -n role -f yaml + 7. Go to the Fuel UI and try to create a new environment + 8. Add new node to the environment, choose test-role and try to add compute or controller role to the same node Duration 20m @@ -142,25 +143,43 @@ class CommandLineRoleTests(test_cli_base.CommandLine): self.fuel_web.client.list_nodes()]) release_id = self.fuel_web.get_releases_list_for_os( release_name=OPENSTACK_RELEASE)[0] - templates_path = os.path.join( - '{0}/fuelweb_test/config_templates/'.format(os.environ.get( - "WORKSPACE", "./")), 'create_role.yaml') + release_path = '/tmp/releases_{}'.format(release_id) self.show_step(2) - if os.path.exists(templates_path): - self.ssh_manager.upload_to_remote(self.ssh_manager.admin_ip, - templates_path, '/tmp') + self.ssh_manager.execute_on_remote( + ip=self.ssh_manager.admin_ip, + cmd='mkdir {}'.format(release_path)) self.show_step(3) + tag_template_path = os.path.join( + '{0}/fuelweb_test/config_templates/'.format(os.environ.get( + "WORKSPACE", "./")), 'create_tag.yaml') + if os.path.exists(tag_template_path): + self.ssh_manager.upload_to_remote(self.ssh_manager.admin_ip, + tag_template_path, release_path) self.show_step(4) self.ssh_manager.execute_on_remote( ip=self.ssh_manager.admin_ip, - cmd='fuel role --rel {} --create --file' - ' /tmp/create_role.yaml'.format(release_id)) + cmd='fuel2 tag create -r {} -n create_tag' + ' -f yaml -d /tmp'.format(release_id)) + + self.show_step(5) + role_template_path = os.path.join( + '{0}/fuelweb_test/config_templates/'.format(os.environ.get( + "WORKSPACE", "./")), 'create_role.yaml') + + if os.path.exists(role_template_path): + self.ssh_manager.upload_to_remote(self.ssh_manager.admin_ip, + role_template_path, release_path) + self.show_step(6) + self.ssh_manager.execute_on_remote( + ip=self.ssh_manager.admin_ip, + cmd='fuel2 role create -r {} -n create_role' + ' -f yaml -d /tmp'.format(release_id)) if NEUTRON_SEGMENT_TYPE: nst = '--nst={0}'.format(NEUTRON_SEGMENT_TYPE) else: nst = '' - self.show_step(5) + self.show_step(7) cmd = ('fuel env create --name={0} --release={1} ' '{2} --json'.format(self.__class__.__name__, release_id, nst)) @@ -170,9 +189,9 @@ class CommandLineRoleTests(test_cli_base.CommandLine): jsonify=True )['stdout_json'] cluster_id = env_result['id'] - self.show_step(6) - cmd = ('fuel --env-id={0} node set --node {1}' - ' --role=test-role'.format(cluster_id, node_ids[0])) + self.show_step(8) + cmd = ('fuel2 env add nodes -e {0} -n {1}' + ' -r test-role'.format(cluster_id, node_ids[0])) result = self.ssh_manager.execute( ip=self.ssh_manager.admin_ip, cmd=cmd, @@ -180,9 +199,9 @@ class CommandLineRoleTests(test_cli_base.CommandLine): assert_equal(result['exit_code'], 0, "Can't assign controller and compute node" " to node id {}".format(node_ids[0])) - cmd = ('fuel --env-id={0} node set --node {1}' - ' --role=test-role,controller,' - 'compute'.format(cluster_id, node_ids[1])) + cmd = ('fuel2 env add nodes -e {0} -n {1}' + ' -r test-role controller' + ' compute'.format(cluster_id, node_ids[1])) result = self.ssh_manager.execute( ip=self.ssh_manager.admin_ip, cmd=cmd, @@ -201,28 +220,30 @@ class CommandLineRoleTests(test_cli_base.CommandLine): Scenario: 1. Create environment using fuel-qa 2. SSH to the master node - 3. Create new file "role.yaml" and paste the following: - + 3. Create new file "release_2/tag.yaml" and paste the above: + meta: + has_primary: true + name: test-primary-tag + 4. Define new tag with command: + fuel2 tag create -r 2 -n tag -f yaml + 5. Create new file "role.yaml" and paste the following: meta: conflicts: - controller - compute - description: New role - has_primary: true - - name: Test role - - name: test-role + name: Test primary role + tags: + - test-primary-tag + name: test-primary-role volumes_roles_mapping: - allocate_size: min - id: os - - 4. Upload yaml to nailgun using Fuel CLI - 5. Create new role with command: - fuel role --rel 2 --create --file role.yaml + 6. Create new role with command: + fuel2 role create -r 2 -n role -f yaml + 7. Go to the Fuel UI and try to create a new environment + 8. Add new node to the environment, choose test-primary-role Duration 20m """ @@ -232,25 +253,42 @@ class CommandLineRoleTests(test_cli_base.CommandLine): self.fuel_web.client.list_nodes()]) release_id = self.fuel_web.get_releases_list_for_os( release_name=OPENSTACK_RELEASE)[0] - templates_path = os.path.join( - '{0}/fuelweb_test/config_templates/'.format(os.environ.get( - "WORKSPACE", "./")), 'create_primary_role.yaml') + release_path = '/tmp/releases_{}'.format(release_id) self.show_step(2) + self.ssh_manager.execute_on_remote( + ip=self.ssh_manager.admin_ip, + cmd='mkdir {}'.format(release_path)) self.show_step(3) - if os.path.exists(templates_path): + tag_template_path = os.path.join( + '{0}/fuelweb_test/config_templates/'.format(os.environ.get( + "WORKSPACE", "./")), 'create_primary_tag.yaml') + if os.path.exists(tag_template_path): self.ssh_manager.upload_to_remote(self.ssh_manager.admin_ip, - templates_path, '/tmp') + tag_template_path, release_path) self.show_step(4) self.ssh_manager.execute_on_remote( ip=self.ssh_manager.admin_ip, - cmd='fuel role --rel {} --create --file' - ' /tmp/create_primary_role.yaml'.format(release_id)) + cmd='fuel2 tag create -r {} -n create_primary_tag' + ' -f yaml -d /tmp'.format(release_id)) + + self.show_step(5) + role_template_path = os.path.join( + '{0}/fuelweb_test/config_templates/'.format(os.environ.get( + "WORKSPACE", "./")), 'create_primary_role.yaml') + if os.path.exists(role_template_path): + self.ssh_manager.upload_to_remote(self.ssh_manager.admin_ip, + role_template_path, release_path) + self.show_step(6) + self.ssh_manager.execute_on_remote( + ip=self.ssh_manager.admin_ip, + cmd='fuel2 role create -r {} -n create_primary_role' + ' -f yaml -d /tmp'.format(release_id)) if NEUTRON_SEGMENT_TYPE: nst = '--nst={0}'.format(NEUTRON_SEGMENT_TYPE) else: nst = '' - self.show_step(5) + self.show_step(7) cmd = ('fuel env create --name={0} --release={1} ' '{2} --json'.format(self.__class__.__name__, release_id, nst)) @@ -260,10 +298,9 @@ class CommandLineRoleTests(test_cli_base.CommandLine): jsonify=True )['stdout_json'] cluster_id = env_result['id'] - - cmd = ('fuel --env-id={0} node set --node {1}' - ' --role=test-primary-role'.format(cluster_id, - node_ids[0])) + self.show_step(8) + cmd = ('fuel2 env add nodes -e {0} -n {1}' + ' -r test-primary-role'.format(cluster_id, node_ids[0])) result = self.ssh_manager.execute( ip=self.ssh_manager.admin_ip, cmd=cmd, @@ -282,31 +319,33 @@ class CommandLineRoleTests(test_cli_base.CommandLine): Scenario: 1. Create environment using fuel-qa 2. SSH to the master node - 3. Create new file "role.yaml" with the following content: - - meta: - conflicts: - - controller - - compute - - description: New role - - name: Test role - - name: test-role - volumes_roles_mapping: - - allocate_size: min - - id: os - - 4. Create new role with command: - fuel role --rel 2 --create --file role.yaml - 5. Go to the Fuel UI and try to create a new environment - 6. Check if new role exists in the list of roles - 7. Add new nodes to the environment: controller, compute - 8. Go to the console and try to delete roles: - fuel role --rel 2 --delete --role - fuel role --rel 2 --delete --role controller + 3. Create new file "release_2/tag.yaml" and paste the above: + meta: + has_primary: false + name: test-tag + 4. Define new tag with command: + fuel2 tag create -r 2 -n tag -f yaml + 5. Create new file "release_2/role.yaml" and paste the above: + meta: + conflicts: + - controller + - compute + description: New role + name: Test role + tags: + - test-tag + name: test-role + volumes_roles_mapping: + - allocate_size: min + id: os + 6. Create new role with command: + fuel2 role create -r 2 -n role -f yaml + 7. Check if new role exists in the list of roles + 8. Go to the Fuel UI and try to create a new environment + 9. Add new node to the environment: controller + 10. Go to the console and try to delete roles: + fuel2 role delete -r 2 -n test-role + fuel2 role delete -r 2 -n controller Duration 20m """ @@ -316,22 +355,44 @@ class CommandLineRoleTests(test_cli_base.CommandLine): self.fuel_web.client.list_nodes()]) release_id = self.fuel_web.get_releases_list_for_os( release_name=OPENSTACK_RELEASE)[0] - templates_path = os.path.join( - '{0}/fuelweb_test/config_templates/'.format(os.environ.get( - "WORKSPACE", "./")), 'create_role.yaml') + release_path = '/tmp/releases_{}'.format(release_id) self.show_step(2) + self.ssh_manager.execute_on_remote( + ip=self.ssh_manager.admin_ip, + cmd='mkdir {}'.format(release_path)) self.show_step(3) - if os.path.exists(templates_path): + tag_template_path = os.path.join( + '{0}/fuelweb_test/config_templates/'.format(os.environ.get( + "WORKSPACE", "./")), 'create_tag.yaml') + if os.path.exists(tag_template_path): self.ssh_manager.upload_to_remote(self.ssh_manager.admin_ip, - templates_path, '/tmp') + tag_template_path, release_path) self.show_step(4) self.ssh_manager.execute_on_remote( ip=self.ssh_manager.admin_ip, - cmd='fuel role --rel {} --create --file' - ' /tmp/create_role.yaml'.format(release_id)) + cmd='fuel2 tag create -r {} -n create_tag' + ' -f yaml -d /tmp'.format(release_id)) + + self.show_step(5) + role_template_path = os.path.join( + '{0}/fuelweb_test/config_templates/'.format(os.environ.get( + "WORKSPACE", "./")), 'create_role.yaml') + + if os.path.exists(role_template_path): + self.ssh_manager.upload_to_remote(self.ssh_manager.admin_ip, + role_template_path, release_path) + self.show_step(6) + self.ssh_manager.execute_on_remote( + ip=self.ssh_manager.admin_ip, + cmd='fuel2 role create -r {} -n create_role' + ' -f yaml -d /tmp'.format(release_id)) + + self.show_step(7) + cmd = ('fuel2 role list -f value -c name' + ' --noindent -r {}'.format(release_id)) result = self.ssh_manager.execute_on_remote( ip=self.ssh_manager.admin_ip, - cmd='fuel role --rel {}'.format(release_id))['stdout'] + cmd=cmd)['stdout'] roles = [i.strip() for i in result] assert_true('test-role' in roles, @@ -341,8 +402,7 @@ class CommandLineRoleTests(test_cli_base.CommandLine): nst = '--nst={0}'.format(NEUTRON_SEGMENT_TYPE) else: nst = '' - self.show_step(5) - self.show_step(6) + self.show_step(8) cmd = ('fuel env create --name={0} --release={1} ' '{2} --json'.format(self.__class__.__name__, release_id, nst)) @@ -352,20 +412,20 @@ class CommandLineRoleTests(test_cli_base.CommandLine): jsonify=True )['stdout_json'] cluster_id = env_result['id'] - self.show_step(7) - cmd = ('fuel --env-id={0} node set --node {1}' - ' --role=controller'.format(cluster_id, node_ids[0])) + self.show_step(9) + cmd = ('fuel2 env add nodes -e {0} -n {1}' + ' -r controller'.format(cluster_id, node_ids[0])) result = self.ssh_manager.execute( ip=self.ssh_manager.admin_ip, cmd=cmd, ) assert_equal(result['exit_code'], 0, - "Can't assign controller and" - " compute node to node id {}".format(node_ids[0])) + "Can't assign controller" + " role to node id {}".format(node_ids[0])) - self.show_step(8) - cmd = ('fuel role --rel {} --delete' - ' --role test-role'.format(release_id)) + self.show_step(10) + cmd = ('fuel2 role delete -r {}' + ' -n test-role'.format(release_id)) result = self.ssh_manager.execute( ip=self.ssh_manager.admin_ip, cmd=cmd, @@ -375,17 +435,19 @@ class CommandLineRoleTests(test_cli_base.CommandLine): result = self.ssh_manager.execute_on_remote( ip=self.ssh_manager.admin_ip, - cmd='fuel role --rel {}'.format(release_id))['stdout'] + cmd=('fuel2 role list -r {} -c name' + ' --noindent').format(release_id))['stdout'] + roles = [i.strip() for i in result] assert_true('test-role' not in roles, - "role is not in the list {}".format(roles)) - cmd = ('fuel role --rel {} --delete' - ' --role controller'.format(release_id)) + "role is in the list {}".format(roles)) + + cmd = ('fuel2 role delete -r {}' + ' -n controller'.format(release_id)) result = self.ssh_manager.execute( ip=self.ssh_manager.admin_ip, cmd=cmd, ) - assert_equal(result['exit_code'], 1, "Controller role shouldn't be able to be deleted") @@ -401,13 +463,12 @@ class CommandLineRoleTests(test_cli_base.CommandLine): 1. Setup master node 2. SSH to the master node 3. Download to file controller role with command: - fuel role --rel 2 --role controller --file controller.yaml + fuel2 role download -r 2 -n controller -f yaml -d /tmp 4. Modify created file: change "id" value at the "volumes_roles_mapping" to something incorrect, - for ex.: "id: blabla" - 5. Save file and upload it to the nailgun with: - fuel role --rel 2 --role controller --update --file - controller.yaml + for ex.: "id: blabla". Save file. + 5. Update role from file with command: + fuel2 role update -r 2 -n controller -d /tmp -f yaml There should be an error message and role shouldn't be updated. Duration 20m @@ -416,23 +477,24 @@ class CommandLineRoleTests(test_cli_base.CommandLine): self.env.revert_snapshot("ready_with_3_slaves") release_id = self.fuel_web.get_releases_list_for_os( release_name=OPENSTACK_RELEASE)[0] + role_descr = '/tmp/releases_{}/controller.yaml'.format(release_id) self.show_step(2) self.show_step(3) self.ssh_manager.execute_on_remote( ip=self.ssh_manager.admin_ip, - cmd='fuel role --rel {} --role controller --file' - ' /tmp/controller.yaml'.format(release_id)) + cmd='fuel2 role download -r {} -n controller -f yaml' + ' -d /tmp'.format(release_id)) self.show_step(4) self.ssh_manager.execute_on_remote( ip=self.ssh_manager.admin_ip, - cmd="sed -i -r 's/id: os/id: blabla/' /tmp/controller.yaml") + cmd="sed -i -r 's/id: os/id: blabla/' {}".format(role_descr)) self.show_step(5) self.ssh_manager.execute_on_remote( ip=self.ssh_manager.admin_ip, - cmd='fuel role --rel {} --role controller --update --file' - ' /tmp/controller.yaml'.format(release_id), + cmd='fuel2 role update -r {} -n controller' + ' -d /tmp -f yaml'.format(release_id), assert_ec_equal=[1]) self.env.make_snapshot("cli_incorrect_update_role")