Add nDPI tasks 53/33453/1
authorYujun Zhang <zhang.yujunz@zte.com.cn>
Tue, 18 Apr 2017 08:34:05 +0000 (16:34 +0800)
committerYujun Zhang <zhang.yujunz@zte.com.cn>
Tue, 18 Apr 2017 08:34:29 +0000 (16:34 +0800)
Change-Id: I18b797d7fb8e5ca1bfd74dbcb836ec4feb318378
Signed-off-by: Yujun Zhang <zhang.yujunz@zte.com.cn>
.gitignore
resources/metric/nDPI.yaml [new file with mode: 0644]
tests/integration/group_vars/all
tests/integration/run.yaml

index 2b3bc64..a098d85 100644 (file)
@@ -75,7 +75,8 @@ ChangeLog
 !/tests/data/**/*
 
 # integration data
+/tests/integration/*.retry
+/tests/integration/dump
 /tests/integration/hosts
+/tests/integration/reports
 /tests/integration/ssh.cfg
-/tests/integration/*.retry
-/tests/integration/reports/*
diff --git a/resources/metric/nDPI.yaml b/resources/metric/nDPI.yaml
new file mode 100644 (file)
index 0000000..c73d367
--- /dev/null
@@ -0,0 +1,76 @@
+##############################################################################
+# Copyright (c) 2017 ZTE Corporation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+
+- name: prepare sample pcap file
+  get_url:
+    url: "https://build.opnfv.org/artifacts.opnfv.org/qtip/utilities/test.pcap"
+    dest: "{{ qtip_dump }}/localhost/{{ nDPI_file }}"
+    validate_certs: no  # required when using proxy for https
+  run_once: yes
+  delegate_to: localhost
+
+- name: installing nDPI dependencies if CentOS
+  yum:
+    name: '{{ item }}'
+    state: present
+  when: ansible_os_family == "RedHat"
+  with_items:
+    - git
+    - gcc
+    - patch
+    - perl-Time-HiRes
+    - autofconf
+    - automake
+    - libpcap-devel libtool
+
+- name: installing nDPI dependencies if Ubuntu
+  apt:
+    name: build-essential
+    state: present
+  when: ansible_os_family == "Debian"
+
+- name: making nDPI temporary directory
+  file:
+    path: "{{ nDPI_cwd }}"
+    state: directory
+
+- name: clone nDPI
+  git:
+    repo: https://github.com/ntop/nDPI.git
+    dest: "{{ nDPI_cwd }}"
+    depth: 1
+
+- name: build nDPI library
+  command: '{{ item }}'
+  with_items:
+    - ./autogen.sh
+    - ./configure
+    - make
+  args:
+    chdir: "{{ nDPI_cwd }}"
+
+- name: copy sample packet file
+  copy:
+    src: "{{ qtip_dump }}/localhost/{{ nDPI_file }}"
+    dest: "{{ nDPI_cwd }}/example/{{ nDPI_file }}"
+
+- name:
+  command: "./ndpiReader -i {{ nDPI_file }}"
+  args:
+    chdir: "{{ nDPI_cwd }}/example/"
+  register: nDPI_out
+
+- name: collect DPI metrics from nDPI
+  collect:
+    string: "{{ nDPI_out.stdout }}"
+    patterns:
+      - '^\s+nDPI throughput:.+?(?P<pps>\d+.\d+)\s.+\spps.+?(?P<bps>\d+.\d+)\s.+\/sec'
+    dump: 'nDPI.log'
+  register: dpi_metrics
index 16a93f4..a84ab51 100644 (file)
@@ -1,3 +1,4 @@
 qtip_resources: ../../resources
 qtip_reports: ./reports
 qtip_fixtures: ./fixtures
+qtip_dump: ./dump
index 7545a65..99bee5e 100644 (file)
   - 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: [nDPI]
 
 - hosts: compute
   tasks: