Fix workspace creator 75/33575/5
authorYujun Zhang <zhang.yujunz@zte.com.cn>
Thu, 20 Apr 2017 10:08:42 +0000 (18:08 +0800)
committerYujun Zhang <zhang.yujunz@zte.com.cn>
Thu, 20 Apr 2017 11:55:00 +0000 (19:55 +0800)
- handle relative path in workspace
- handle differences between installers
- create working directories

Change-Id: I5fbe66c1218c29db0fafd87085a6cf5c15a91dc5
Signed-off-by: Yujun Zhang <zhang.yujunz@zte.com.cn>
18 files changed:
.gitignore
resources/roles/qtip-bootstrap/defaults/main.yml
resources/roles/qtip-bootstrap/files/copy/fixtures/case.json [moved from resources/roles/qtip-bootstrap/files/fixtures/case.json with 100% similarity]
resources/roles/qtip-bootstrap/files/copy/fixtures/pod.json [moved from resources/roles/qtip-bootstrap/files/fixtures/pod.json with 100% similarity]
resources/roles/qtip-bootstrap/files/copy/fixtures/project.json [moved from resources/roles/qtip-bootstrap/files/fixtures/project.json with 100% similarity]
resources/roles/qtip-bootstrap/files/copy/group_vars/.gitkeep [new file with mode: 0644]
resources/roles/qtip-bootstrap/files/copy/host_vars/.gitkeep [new file with mode: 0644]
resources/roles/qtip-bootstrap/files/copy/run.yml [moved from resources/roles/qtip-bootstrap/files/run.yml with 90% similarity]
resources/roles/qtip-bootstrap/files/copy/setup.yml [moved from resources/roles/qtip-bootstrap/files/setup.yml with 80% similarity]
resources/roles/qtip-bootstrap/files/copy/templates/hosts [moved from resources/template/hosts.j2 with 81% similarity]
resources/roles/qtip-bootstrap/files/copy/templates/ssh.cfg [moved from resources/template/ssh.cfg.j2 with 78% similarity]
resources/roles/qtip-bootstrap/files/render/ansible.cfg [moved from resources/roles/qtip-bootstrap/templates/ansible.cfg.j2 with 99% similarity]
resources/roles/qtip-bootstrap/files/render/group_vars/all.yml [moved from resources/roles/qtip-bootstrap/files/host_vars/localhost.yml with 68% similarity]
resources/roles/qtip-bootstrap/files/render/host_vars/localhost.yml [moved from resources/roles/qtip-bootstrap/files/group_vars/all.yml with 81% similarity]
resources/roles/qtip-bootstrap/files/render/hosts [moved from resources/roles/qtip-bootstrap/templates/hosts.j2 with 59% similarity]
resources/roles/qtip-bootstrap/tasks/main.yml
tests/integration/roles [deleted symlink]
tests/integration/workspace-create.yml

index fcd2894..f2849f1 100644 (file)
@@ -75,5 +75,5 @@ ChangeLog
 !/tests/data/**/*
 
 # integration data
-/tests/integration/*.retry
-/tests/integration/*-workspace
+*.retry
+/tests/integration/workspace/
index 10e464e..55e2cbc 100644 (file)
@@ -8,7 +8,12 @@
 ##############################################################################
 
 installer: fuel
+
 installer_master: fuel-master
 
-workspace: "./{{ installer }}-workspace"
-qtip_package: ../..
+installer_master_group:
+  fuel: fuel-masters
+  apex: apex-underclouds
+
+workspace: "workspace"
+qtip_package: ../../..
diff --git a/resources/roles/qtip-bootstrap/files/copy/group_vars/.gitkeep b/resources/roles/qtip-bootstrap/files/copy/group_vars/.gitkeep
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/resources/roles/qtip-bootstrap/files/copy/host_vars/.gitkeep b/resources/roles/qtip-bootstrap/files/copy/host_vars/.gitkeep
new file mode 100644 (file)
index 0000000..e69de29
 # - system information
 # - test condition
 # - performance metrics
+
 - hosts: compute
-  tasks:
+
+  pre_tasks:
   - name: check ssh connection
     ping:
-  tags: [setup]
 
-- hosts: compute
   roles:
-    - development-tools
+  - development-tools
+
+  post_tasks:
+  - name: create dumping directories
+    file:
+      path: "{{ qtip_dump }}/{{ inventory_hostname }}"
+      state: directory
+    delegate_to: localhost
+
   tags: [setup]
 
+
 - hosts: compute
+
   roles:
-    - unixbench
-  tags: [unixbench]
 
-- hosts: compute
+    - { role: unixbench, tags: [unixbench] }
+
   tasks:
+
   - name: collect system information
     include: "{{ qtip_resources }}/metric/inxi.yaml"
+
   - name: ssl metrics
     include: "{{ qtip_resources }}/metric/openssl.yaml"
     tags: [ssl]
+
   - name: DPI metrics
     include: "{{ qtip_resources }}/metric/nDPI.yaml"
     vars:
       nDPI_cwd: "{{ ansible_env.HOME }}/qtip/nDPI"
       nDPI_file: "dpi.pcap"
     tags: [dpi]
+
   - name: memory metrics
     include: "{{ qtip_resources }}/metric/ramspeed.yaml"
     vars:
       cwd: "{{ ansible_env.HOME }}/qtip/ramspeed"
     tags: [mem]
-- hosts: compute
-  tasks:
+
   - name: calculate QPI of compute
     calculate:
       metrics:
     delegate_to: localhost
     tags: [calculate]
 
+
 - hosts: localhost
+
   tasks:
+
   - name: aggregate QPI results from all tested nodes
     aggregate:
       group: compute
     register: pod_result
 
-# Generate and publish report
+  # Generate and publish report
 
-- hosts: localhost
-  tasks:
   - name: create report folder
     file:
       path: "{{ qtip_reports }}"
       state: directory
+
   - name: create system information report
     template:
       src: "{{ qtip_resources }}/template/system-info.j2"
       dest: "{{ qtip_reports }}/system-info"
+
   - name: create qpi report
     template:
       src: "{{ qtip_resources }}/template/qpi-report.j2"
       dest: "{{ qtip_reports }}/qpi-report"
     tags: [report]
+
   - name: create dpi metrics report
     template:
       src: "{{ qtip_resources }}/template/dpi-metrics.j2"
       dest: "{{ qtip_reports }}/dpi-metrics"
     tags: [report, dpi]
+
   - name: push result to testapi
     uri:
       url: "{{ testapi_url }}/results"
@@ -8,19 +8,13 @@
 ##############################################################################
 
 # Prepare connection to SUT (System Under Test)
-- hosts: fuel-master
+- hosts: fuel-masters
   gather_facts: no
   tasks:
   - name: collect facts of fuel hosts
     fuel:
-  - name: update inventory file
-    template: src={{ qtip_resources }}/template/hosts.j2 dest=./hosts
-    delegate_to: localhost
-  - name: update ssh.cfg file
-    template: src={{ qtip_resources }}/template/ssh.cfg.j2 dest=./ssh.cfg
-    delegate_to: localhost
 
-- hosts: apex-undercloud
+- hosts: apex-underclouds
   gather_facts: no
 
   tasks:
     apex_generate_inventory:
       baremetal_info: "{{ baremetal_info.stdout | from_json }}"
       server_info: "{{ server_info.stdout | from_json }}"
+
+- hosts:
+  - fuel-masters
+  - apex-underclouds
+  tasks:
   - name: update inventory file
-    template: src={{ qtip_resources }}/template/hosts.j2 dest=./hosts
+    template: src=templates/hosts dest=./hosts
     delegate_to: localhost
   - name: update ssh.cfg file
-    template: src={{ qtip_resources }}/template/ssh.cfg.j2 dest=./ssh.cfg
+    template: src=templates/ssh.cfg dest=./ssh.cfg
     delegate_to: localhost
 
+- hosts: localhost
+  tasks:
+  - name: create output directories
+    file:
+      path: "{{ item }}"
+      state: directory
+    with_items:
+      - "{{ qtip_cache }}"
+      - "{{ qtip_reports }}"
+
 # Initialize testapi database
 - hosts: localhost
   tasks:
similarity index 81%
rename from resources/template/hosts.j2
rename to resources/roles/qtip-bootstrap/files/copy/templates/hosts
index 2ebf3c8..27c8d1d 100644 (file)
@@ -1,6 +1,8 @@
-fuel-master
 localhost   ansible_connection=local
 
+[{{ installer_master_group[installer] }}]
+{{ installer_master }}
+
 [fuel-groups:children]
 {% for group in hosts|sort %}
 {{ group }}
similarity index 78%
rename from resources/template/ssh.cfg.j2
rename to resources/roles/qtip-bootstrap/files/copy/templates/ssh.cfg
index 2fe049e..d6a266b 100644 (file)
@@ -9,6 +9,6 @@
 Host {{ name }}
   HostName {{ host.ansible_ssh_host }}
   User root
-  ProxyCommand ssh -o 'ForwardAgent yes' fuel-master 'ssh-add && nc %h %p'
+  ProxyCommand ssh -o 'ForwardAgent yes' {{ installer_master }} 'ssh-add && nc %h %p'
 
 {% endfor %}
@@ -56,6 +56,7 @@ gathering = smart
 
 # additional paths to search for roles in, colon separated
 #roles_path    = /etc/ansible/roles
+roles_path = {{ qtip_package }}/resources/roles
 
 # uncomment this to disable SSH key host checking
 #host_key_checking = False
@@ -172,7 +173,7 @@ callback_whitelist = profile_tasks
 
 
 # set plugin path directories here, separate with colons
-action_plugins     = {{ qtip_package }}/ansible_library/plugins/action
+action_plugins     = {{ qtip_package }}/qtip/ansible_library/plugins/action
 #cache_plugins      = /usr/share/ansible/plugins/cache
 #callback_plugins   = /usr/share/ansible/plugins/callback
 #connection_plugins = /usr/share/ansible/plugins/connection
@@ -329,7 +330,6 @@ filter_plugins     = {{ qtip_package }}/qtip/ansible_library/plugins/filter
 # Leaving off ControlPersist will result in poor performance, so use
 # paramiko on older platforms rather than removing it, -C controls compression use
 #ssh_args = -C -o ControlMaster=auto -o ControlPersist=60s
-ssh_args = -F ssh.cfg
 
 # The base directory for the ControlPath sockets.
 # This is the "%(directory)s" in the control_path option
@@ -7,10 +7,21 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 
+qtip_resources: "{{ qtip_package }}/resources"
+qtip_reports: reports
+qtip_fixtures: fixtures
+qtip_dump: dump
+qtip_cache: .cache
+
 testapi_url: http://localhost:8000/api/v1
 project_name: qtip
 case_name: compute
 pod_name: qtip-pod
-installer: fuel
+installer: "{{ installer }}"
 version: master
 scenario: demo
+
+installer_master: "{{ installer_master }}"
+installer_master_group:
+  fuel: fuel-masters
+  apex: apex-underclouds
@@ -7,7 +7,3 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 
-qtip_resources: ../../resources
-qtip_reports: ./reports
-qtip_fixtures: ./fixtures
-qtip_dump: ./dump
@@ -1,3 +1,4 @@
 localhost   ansible_connection=local
 
+[{{ installer_master_group[installer] }}]
 {{ installer_master }}
index 96d6c7d..e198732 100644 (file)
@@ -9,17 +9,13 @@
 
 - name: copy initial files
   synchronize:
-    src:  "{{ item }}"
-    dest: "{{ workspace }}"
-  with_items:
-    - group_vars
-    - host_vars
-    - fixtures
+    src:  copy/
+    dest: "{{ workspace }}/"
 
 - name: generate default configuration
   template:
-    src: "{{ item }}.j2"
-    dest: "{{ workspace }}/{{ item }}"
-  with_items:
-    - ansible.cfg
-    - hosts
+    src: "{{ item.src }}"
+    dest: "{{ workspace }}/{{ item.path }}"
+    force: yes
+  with_filetree: render
+  when: item.state == 'file'
diff --git a/tests/integration/roles b/tests/integration/roles
deleted file mode 120000 (symlink)
index a2363ee..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../../resources/roles
\ No newline at end of file
index 83e0fad..71fd08d 100644 (file)
 ---
 - hosts: localhost
   roles:
-    - { role: qtip-bootstrap, installer: fuel }
+    - role: qtip-bootstrap
+      installer: fuel         # fuel|apex
+      pod_name: qtip-pod
+      scenario: default
+      version: master
+      testapi_url: http://localhost:8000/api/v1
+      installer_master: f5    # hostname of installer master
+      qtip_package: ../../..  # note the relative path in workspace might be different from current working directory