This commit is contained in:
fbsanchez 2016-08-18 13:30:35 +02:00
commit 36ea2faaad
37 changed files with 295 additions and 121 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 6.1dev-160817 Version: 6.1dev-160818
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="6.1dev-160817" pandora_version="6.1dev-160818"
echo "Test if you has the tools for to make the packages." echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -41,7 +41,7 @@ my $Sem = undef;
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '6.1dev'; use constant AGENT_VERSION => '6.1dev';
use constant AGENT_BUILD => '160817'; use constant AGENT_BUILD => '160818';
# Agent log default file size maximum and instances # Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000; use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 6.1dev %define version 6.1dev
%define release 160817 %define release 160818
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 6.1dev %define version 6.1dev
%define release 160817 %define release 160818
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -10,7 +10,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="6.1dev" PI_VERSION="6.1dev"
PI_BUILD="160817" PI_BUILD="160818"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{160817} {160818}
ViewReadme ViewReadme
{Yes} {Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("6.1dev(Build 160817)") #define PANDORA_VERSION ("6.1dev(Build 160818)")
string pandora_path; string pandora_path;
string pandora_dir; string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST" VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent" VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(6.1dev(Build 160817))" VALUE "ProductVersion", "(6.1dev(Build 160818))"
VALUE "FileVersion", "1.0.0.0" VALUE "FileVersion", "1.0.0.0"
END END
END END

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 6.1dev-160817 Version: 6.1dev-160818
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="6.1dev-160817" pandora_version="6.1dev-160818"
package_pear=0 package_pear=0
package_pandora=1 package_pandora=1

View File

@ -277,7 +277,7 @@ function extension_db_check_tables_differences($connection_test,
ui_print_info_message( ui_print_info_message(
__('You can execute this SQL query for to fix.') . "<br />" . __('You can execute this SQL query for to fix.') . "<br />" .
'<pre>' . '<pre>' .
"ALTER TABLE " . $table . " MODIFY COLUMN " . $field . " " . $value . ";" . "ALTER TABLE " . $table . " MODIFY COLUMN " . $name_field . " " . $value . ";" .
'</pre>' '</pre>'
); );
break; break;
@ -289,7 +289,7 @@ function extension_db_check_tables_differences($connection_test,
ui_print_info_message( ui_print_info_message(
__('You can execute this SQL query for to fix.') . "<br />" . __('You can execute this SQL query for to fix.') . "<br />" .
'<pre>' . '<pre>' .
"ALTER TABLE " . $table . " MODIFY COLUMN " . $field . "INT NULL;" . "ALTER TABLE " . $table . " MODIFY COLUMN " . $name_field . "INT NULL;" .
'</pre>' '</pre>'
); );
} }
@ -297,7 +297,7 @@ function extension_db_check_tables_differences($connection_test,
ui_print_info_message( ui_print_info_message(
__('You can execute this SQL query for to fix.') . "<br />" . __('You can execute this SQL query for to fix.') . "<br />" .
'<pre>' . '<pre>' .
"ALTER TABLE " . $table . " MODIFY COLUMN " . $field . "INT NOT NULL;" . "ALTER TABLE " . $table . " MODIFY COLUMN " . $name_field . "INT NOT NULL;" .
'</pre>' '</pre>'
); );
} }

View File

@ -319,11 +319,12 @@ else {
$total_agents = db_get_sql ($sql); $total_agents = db_get_sql ($sql);
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
$order['field2'] = "";
$sql = sprintf ('SELECT * $sql = sprintf ('SELECT *
FROM tagente FROM tagente
WHERE 1=1 WHERE 1=1
%s %s
ORDER BY %s, %s %s LIMIT %d, %d', $search_sql, $order['field'], $order['field2'], ORDER BY %s %s %s LIMIT %d, %d', $search_sql, $order['field'], $order['field2'],
$order['order'], $offset, $config["block_size"]); $order['order'], $offset, $config["block_size"]);
break; break;
case "postgresql": case "postgresql":

View File

@ -73,17 +73,24 @@ $table->data[2][1] = html_print_input_text('expires', $license['limit'], '', 10,
$table->data[3][0] = '<strong>'.__('Current Platform Count').'</strong>'; $table->data[3][0] = '<strong>'.__('Current Platform Count').'</strong>';
$table->data[3][1] = html_print_input_text('expires', $license['count'], '', 10, 255, true, true) . ' ' . ($license['limit_mode'] == 0 ? __('agents') : __('modules')); $table->data[3][1] = html_print_input_text('expires', $license['count'], '', 10, 255, true, true) . ' ' . ($license['limit_mode'] == 0 ? __('agents') : __('modules'));
$table->data[4][0] = '<strong>'.__('License Mode').'</strong>'; $table->data[4][0] = '<strong>'.__('Current Platform Count (enabled: items)').'</strong>';
$table->data[4][1] = html_print_input_text('expires', $license['license_mode'], '', 10, 255, true, true); $table->data[4][1] = html_print_input_text('expires', $license['count_enabled'], '', 10, 255, true, true) . ' ' . ($license['limit_mode'] == 0 ? __('agents') : __('modules'));
$table->data[5][0] = '<strong>'.__('NMS').'</strong>'; $table->data[5][0] = '<strong>'.__('Current Platform Count (disabled: items)').'</strong>';
$table->data[5][1] = html_print_input_text('expires', ($license['nms'] == 1 ? __('enabled') : __('disabled')), '', 10, 255, true, true); $table->data[5][1] = html_print_input_text('expires', $license['count_disabled'], '', 10, 255, true, true) . ' ' . ($license['limit_mode'] == 0 ? __('agents') : __('modules'));
$table->data[6][0] = '<strong>'.__('Satellite').'</strong>'; $table->data[6][0] = '<strong>'.__('License Mode').'</strong>';
$table->data[6][1] = html_print_input_text('expires', ($license['dhpm'] == 1 ? __('enabled') : __('disabled')), '', 10, 255, true, true); $table->data[6][1] = html_print_input_text('expires', $license['license_mode'], '', 10, 255, true, true);
$table->data[7][0] = '<strong>'.__('NMS').'</strong>';
$table->data[7][1] = html_print_input_text('expires', ($license['nms'] == 1 ? __('enabled') : __('disabled')), '', 10, 255, true, true);
$table->data[8][0] = '<strong>'.__('Satellite').'</strong>';
$table->data[8][1] = html_print_input_text('expires', ($license['dhpm'] == 1 ? __('enabled') : __('disabled')), '', 10, 255, true, true);
$table->data[9][0] = '<strong>'.__('Licensed to').'</strong>';
$table->data[9][1] = html_print_input_text('licensed_to', $license['licensed_to'], '', 64, 255, true, true);
$table->data[7][0] = '<strong>'.__('Licensed to').'</strong>';
$table->data[7][1] = html_print_input_text('licensed_to', $license['licensed_to'], '', 64, 255, true, true);
html_print_table ($table); html_print_table ($table);
if (enterprise_installed()) { if (enterprise_installed()) {
echo '<div class="action-buttons" style="width: '.$table->width.'">'; echo '<div class="action-buttons" style="width: '.$table->width.'">';

View File

@ -22,7 +22,7 @@
/** /**
* Pandora build version and version * Pandora build version and version
*/ */
$build_version = 'PC160817'; $build_version = 'PC160818';
$pandora_version = 'v6.1dev'; $pandora_version = 'v6.1dev';
// Do not overwrite default timezone set if defined. // Do not overwrite default timezone set if defined.

View File

@ -108,7 +108,7 @@ function reporting_make_reporting_data($report = null, $id_report,
$contents = $report['contents']; $contents = $report['contents'];
} }
else { else {
$report = db_get_row ('treport', 'id_report', $id_report); $report = io_safe_output(db_get_row ('treport', 'id_report', $id_report));
$contents = db_get_all_rows_field_filter ('treport_content', $contents = db_get_all_rows_field_filter ('treport_content',
'id_report', $id_report, db_escape_key_identifier('order')); 'id_report', $id_report, db_escape_key_identifier('order'));
} }
@ -4432,8 +4432,8 @@ function reporting_simple_graph($report, $content, $type = 'dinamic',
$only_avg = true; $only_avg = true;
// Due to database compatibility problems, the 'only_avg' value // Due to database compatibility problems, the 'only_avg' value
// is stored into the json contained into the 'style' column. // is stored into the json contained into the 'style' column.
if (isset($style['only_avg'])) { if (isset($content['style']['only_avg'])) {
$only_avg = (bool) $style['only_avg']; $only_avg = (bool) $content['style']['only_avg'];
} }
$moduletype_name = modules_get_moduletype_name( $moduletype_name = modules_get_moduletype_name(

View File

@ -71,7 +71,7 @@
<div style='height: 10px'> <div style='height: 10px'>
<?php <?php
$version = '6.1dev'; $version = '6.1dev';
$build = '160817'; $build = '160818';
$banner = "v$version Build $build"; $banner = "v$version Build $build";
error_reporting(0); error_reporting(0);

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 6.1dev %define version 6.1dev
%define release 160817 %define release 160818
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 6.1dev %define version 6.1dev
%define release 160817 %define release 160818
%define httpd_name httpd %define httpd_name httpd
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name apache2 %define httpd_name apache2

View File

@ -66,7 +66,7 @@ INSERT INTO tconfig (token, value) VALUES ('graph_res','5');
INSERT INTO tconfig (token, value) VALUES ('step_compact','1'); INSERT INTO tconfig (token, value) VALUES ('step_compact','1');
INSERT INTO tconfig (token, value) VALUES ('db_scheme_first_version','6.0orc'); INSERT INTO tconfig (token, value) VALUES ('db_scheme_first_version','6.0orc');
INSERT INTO tconfig (token, value) VALUES('db_scheme_version','6.1dev'); INSERT INTO tconfig (token, value) VALUES('db_scheme_version','6.1dev');
INSERT INTO tconfig (token, value) VALUES('db_scheme_build','PD160817'); INSERT INTO tconfig (token, value) VALUES('db_scheme_build','PD160818');
INSERT INTO tconfig (token, value) VALUES ('show_unknown','0'); INSERT INTO tconfig (token, value) VALUES ('show_unknown','0');
INSERT INTO tconfig (token, value) VALUES ('show_lastalerts','1'); INSERT INTO tconfig (token, value) VALUES ('show_lastalerts','1');
INSERT INTO tconfig (token, value) VALUES ('style','pandora'); INSERT INTO tconfig (token, value) VALUES ('style','pandora');

View File

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 6.1dev-160817 Version: 6.1dev-160818
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="6.1dev-160817" pandora_version="6.1dev-160818"
package_cpan=0 package_cpan=0
package_pandora=1 package_pandora=1

View File

@ -43,7 +43,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "6.1dev"; my $pandora_version = "6.1dev";
my $pandora_build = "160817"; my $pandora_build = "160818";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash # Setup hash

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 6.1dev %define version 6.1dev
%define release 160817 %define release 160818
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 6.1dev %define version 6.1dev
%define release 160817 %define release 160818
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -9,7 +9,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="6.1dev" PI_VERSION="6.1dev"
PI_BUILD="160817" PI_BUILD="160818"
MODE=$1 MODE=$1
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then

View File

@ -33,7 +33,7 @@ use PandoraFMS::Tools;
use PandoraFMS::DB; use PandoraFMS::DB;
# version: define current version # version: define current version
my $version = "6.1dev PS160817"; my $version = "6.1dev PS160818";
# Pandora server configuration # Pandora server configuration
my %conf; my %conf;

View File

@ -35,7 +35,7 @@ use Encode::Locale;
Encode::Locale::decode_argv; Encode::Locale::decode_argv;
# version: define current version # version: define current version
my $version = "6.1dev PS160817"; my $version = "6.1dev PS160818";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);

View File

@ -8,17 +8,26 @@ from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re import unittest, time, re
class PAN2(PandoraWebDriverTestCase): class Bulk_operations(PandoraWebDriverTestCase):
test_name = u'PAN_2'
test_name = u'Bulk_operation'
test_description = u'Creation two agents and delete this agents using bulk operation' test_description = u'Creation two agents and delete this agents using bulk operation'
tickets_associated = [3831] tickets_associated = []
def test_pan2(self): def test_A_delete_agent_bulk_operations(self):
u"""
Creation two agents and delete this agents using bulk operation'
Ticket Associated = 3831
"""
driver = self.driver driver = self.driver
self.login() self.login()
detect_and_pass_all_wizards
create_agent(driver,"prueba masivas 1") create_agent(driver,"prueba masivas 1")
driver.find_element_by_css_selector("b").click() driver.find_element_by_css_selector("b").click()
@ -33,11 +42,9 @@ class PAN2(PandoraWebDriverTestCase):
Select(driver.find_element_by_id("id_agents")).select_by_visible_text("prueba masivas 1") Select(driver.find_element_by_id("id_agents")).select_by_visible_text("prueba masivas 1")
Select(driver.find_element_by_id("id_agents")).select_by_visible_text("prueba masivas 2") Select(driver.find_element_by_id("id_agents")).select_by_visible_text("prueba masivas 2")
driver.find_element_by_id("submit-go").click() driver.find_element_by_id("submit-go").click()
try:
self.assertRegexpMatches(self.close_alert_and_get_its_text(), r"^Are you sure[\s\S]$") self.assertRegexpMatches(self.close_alert_and_get_its_text(), r"^Are you sure[\s\S]$")
self.assertEqual(self.driver.find_element_by_xpath('//div[@id="main"]//td[contains(.,"Successfully deleted (2)")]').text,"Successfully deleted (2)") self.assertEqual(self.driver.find_element_by_xpath('//div[@id="main"]//td[contains(.,"Successfully deleted (2)")]').text,"Successfully deleted (2)")
except AssertionError as e:
self.verificationErrors.append(str(e))
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()

View File

@ -6,6 +6,7 @@ from include.reports_functions import create_report, delete_report
from include.user_functions import create_user from include.user_functions import create_user
from include.agent_functions import create_agent from include.agent_functions import create_agent
from include.module_functions import create_module from include.module_functions import create_module
from include.event_functions import *
from selenium import webdriver from selenium import webdriver
from selenium.webdriver.common.by import By from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.keys import Keys
@ -53,14 +54,8 @@ class Miscellaneous (PandoraWebDriverTestCase):
time.sleep(10) time.sleep(10)
#Search events of our agent #Search events of our agent
click_menu_element(driver,"View events")
driver.find_element_by_xpath('//a[contains(.,"Event control filter")]').click() search_events(driver,agent_name=u"次のライセンスに基づいていま",module_name=u"管理者ガイド")
driver.find_element_by_xpath('//a[contains(.,"Advanced options")]').click()
driver.find_element_by_id("text-text_agent").clear()
driver.find_element_by_id("text-text_agent").send_keys(u"次のライセンスに基づいていま")
driver.find_element_by_id("text-module_search").clear()
driver.find_element_by_id("text-module_search").send_keys(u"管理者ガイド")
driver.find_element_by_id("submit-update").click()
#Check that there are japanese characters present on the event #Check that there are japanese characters present on the event
element = driver.find_element_by_xpath(u'//a[contains(.,"Alert fired (Critical condition) assigned to (管理者ガイド)")]') element = driver.find_element_by_xpath(u'//a[contains(.,"Alert fired (Critical condition) assigned to (管理者ガイド)")]')

View File

@ -1,7 +1,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from include.common_classes_60 import PandoraWebDriverTestCase from include.common_classes_60 import PandoraWebDriverTestCase
from include.common_functions_60 import login, click_menu_element, detect_and_pass_all_wizards, logout, is_enterprise, gen_random_string from include.common_functions_60 import login, click_menu_element, detect_and_pass_all_wizards, logout, gen_random_string
from include.planned_downtime_functions import * from include.planned_downtime_functions import *
from include.alert_functions import *
from include.module_functions import *
from include.agent_functions import *
from include.event_functions import *
from selenium import webdriver from selenium import webdriver
from selenium.webdriver.common.by import By from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.keys import Keys
@ -9,7 +13,7 @@ from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException from selenium.common.exceptions import NoAlertPresentException
from selenium.webdriver.remote.webelement import WebElement from selenium.webdriver.remote.webelement import WebElement
import unittest, time, re import unittest, time, re, datetime
class PAN13(PandoraWebDriverTestCase): class PAN13(PandoraWebDriverTestCase):
@ -18,8 +22,7 @@ class PAN13(PandoraWebDriverTestCase):
test_description = u'Planed downtime test' test_description = u'Planed downtime test'
tickets_associated = [] tickets_associated = []
@is_enterprise def avoid_test_A_create_planned_downtime_Quiet(self):
def test_A_create_planned_downtime_Quiet(self):
u""" u"""
Create and search planned downtime quiet Create and search planned downtime quiet
@ -30,17 +33,16 @@ class PAN13(PandoraWebDriverTestCase):
planned_name = gen_random_string(6) planned_name = gen_random_string(6)
create_planned_downtime(driver,planned_name,"Applications","Quiet",description=planned_name) create_planned_downtime(driver,planned_name,"Applications","Quiet","Once",description=planned_name)
time.sleep(10) time.sleep(10)
search_planned_downtime(driver,planned_name) search_planned_downtime(driver,planned_name)
element = driver.find_element_by_xpath('//a[contains(.,"Running")]') element = driver.find_element_by_xpath('//img[@data-title="Running"]')
self.assertIsInstance(element,WebElement) self.assertIsInstance(element,WebElement)
@is_enterprise def avoid_test_B_create_planned_downtime_disabled_agents(self):
def test_B_create_planned_downtime_disabled_agents(self):
u""" u"""
Create and search planned downtime disabled agents Create and search planned downtime disabled agents
@ -49,17 +51,16 @@ class PAN13(PandoraWebDriverTestCase):
planned_name = gen_random_string(6) planned_name = gen_random_string(6)
create_planned_downtime(driver,planned_name,"Applications","Disabled Agents",description=planned_name) create_planned_downtime(driver,planned_name,"Applications","Disabled Agents","Once",description=planned_name)
time.sleep(10) time.sleep(10)
search_planned_downtime(driver,planned_name) search_planned_downtime(driver,planned_name)
element = driver.find_element_by_xpath('//a[contains(.,"Running")]') element = driver.find_element_by_xpath('//img[@data-title="Running"]')
self.assertIsInstance(element,WebElement) self.assertIsInstance(element,WebElement)
@is_enterprise def avoid_test_C_create_planned_downtime_disabled_only_alerts(self):
def test_C_create_planned_downtime_disabled_only_alerts(self):
u""" u"""
Create and search planned downtime disabled only alerts Create and search planned downtime disabled only alerts
@ -68,15 +69,97 @@ class PAN13(PandoraWebDriverTestCase):
planned_name = gen_random_string(6) planned_name = gen_random_string(6)
create_planned_downtime(driver,planned_name,"Applications","Disabled only Alerts",description=planned_name) create_planned_downtime(driver,planned_name,"Applications","Disabled only Alerts","Once",description=planned_name)
time.sleep(10) time.sleep(10)
search_planned_downtime(driver,planned_name) search_planned_downtime(driver,planned_name)
element = driver.find_element_by_xpath('//a[contains(.,"Running")]') element = driver.find_element_by_xpath('//img[@data-title="Running"]')
self.assertIsInstance(element,WebElement) self.assertIsInstance(element,WebElement)
def avoid_test_D_delete_planned_downtime(self):
driver=self.driver
planned_name = gen_random_string(6)
create_planned_downtime(driver,planned_name,"Applications","Quiet","Once",description=planned_name)
delete_planned_downtime(driver,planned_name)
def avoid_test_E_quiet_functionality(self):
driver=self.driver
planned_name = gen_random_string(6)
agent_name_A = gen_random_string(6)
agent_name_B = gen_random_string(6)
module_name_A_A = gen_random_string(6)
module_name_A_B = gen_random_string(6)
module_name_B_A = gen_random_string(6)
module_name_B_B = gen_random_string(6)
create_agent(driver,agent_name_A,ip="127.0.0.1",group="Applications")
create_agent(driver,agent_name_B,ip="127.0.0.1",group="Applications")
create_module('network_server',driver,agent_name=agent_name_A,module_name=module_name_A_A,component_group='Network Management',network_component='Host Alive')
create_module('network_server',driver,agent_name=agent_name_A,module_name=module_name_A_B,component_group='Network Management',network_component='Host Latency')
create_module('network_server',driver,agent_name=agent_name_B,module_name=module_name_B_A,component_group='Network Management',network_component='Host Alive')
create_module('network_server',driver,agent_name=agent_name_B,module_name=module_name_B_B,component_group='Network Management',network_component='Host Alive')
assign_alert_template_to_module(driver,agent_name_A,module_name_A_A,'Critical condition')
assign_alert_template_to_module(driver,agent_name_A,module_name_A_B,'Critical condition')
assign_alert_template_to_module(driver,agent_name_B,module_name_B_A,'Critical condition')
assign_alert_template_to_module(driver,agent_name_B,module_name_B_B,'Critical condition')
#Little hack to allow the planned downtime to be edited
fifteen_seconds_later = datetime.datetime.now() + datetime.timedelta(seconds=15)
fifteen_seconds_later_to_pandora = str(fifteen_seconds_later.hour)+":"+str(fifteen_seconds_later.minute)+":"+str(fifteen_seconds_later.second)
create_planned_downtime(driver,planned_name,"Applications","Quiet","Once",hour_from=fifteen_seconds_later_to_pandora,description=planned_name,agent_module_list=[(agent_name_A,[module_name_A_A]),(agent_name_B,[module_name_B_A])])
#We wait 10 seconds to the planned downtime to start. Since we do not specify a date, default dates are from now to one hour in the future.
time.sleep(40)
#Is the planned downtime running?
search_planned_downtime(driver,planned_name)
element = driver.find_element_by_xpath('//img[@data-title="Running"]')
self.assertIsInstance(element,WebElement)
force_alert_of_module(driver,agent_name_A,module_name_A_A,'Critical condition')
force_alert_of_module(driver,agent_name_A,module_name_A_B,'Critical condition')
force_alert_of_module(driver,agent_name_B,module_name_B_A,'Critical condition')
force_alert_of_module(driver,agent_name_B,module_name_B_B,'Critical condition')
search_events(driver,agent_name=agent_name_A,module_name=module_name_A_A)
event_who_should_not_be_present = driver.find_elements_by_xpath('//tbody/tr[td[3][contains(.,"Alert fired")] and td[4][contains(.,"'+agent_name_A+'")]]')
self.assertEqual(event_who_should_not_be_present,[])
search_events(driver,agent_name=agent_name_A,module_name=module_name_A_B)
event_who_should_be_present = driver.find_elements_by_xpath('//tbody/tr[td[3][contains(.,"Alert fired")] and td[4][contains(.,"'+agent_name_A+'")]]')
self.assertNotEqual(event_who_should_be_present,[])
search_events(driver,agent_name=agent_name_B,module_name=module_name_B_A)
event_who_should_not_be_present_b = driver.find_elements_by_xpath('//tbody/tr[td[3][contains(.,"Alert fired")] and td[4][contains(.,"'+agent_name_B+'")]]')
self.assertEqual(event_who_should_not_be_present_b,[])
search_events(driver,agent_name=agent_name_B,module_name=module_name_B_B)
event_who_should_be_present_b = driver.find_elements_by_xpath('//tbody/tr[td[3][contains(.,"Alert fired")] and td[4][contains(.,"'+agent_name_B+'")]]')
self.assertNotEqual(event_who_should_be_present_b,[])
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()

View File

@ -8,16 +8,21 @@ from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException from selenium.common.exceptions import NoAlertPresentException
from selenium.webdriver.remote.webelement import WebElement from selenium.webdriver.remote.webelement import WebElement
import unittest, time, re import unittest, time, re
class PAN7(PandoraWebDriverTestCase): class Users(PandoraWebDriverTestCase):
test_name = u'PAN_7' test_name = u'Users'
test_description = u'Modify home screen, and check that change is correct. Return this change' test_description = u'Users tests'
tickets_associated = [] tickets_associated = []
def test_pan7(self): def test_A_home_screen(self):
u"""
Modify home screen, and check that change is correct. Return this change
"""
driver = self.driver driver = self.driver
self.login() self.login()
detect_and_pass_all_wizards(driver) detect_and_pass_all_wizards(driver)
@ -27,17 +32,9 @@ class PAN7(PandoraWebDriverTestCase):
self.logout() self.logout()
self.login() self.login()
element = driver.find_element_by_xpath('//a[contains(.,"Event control filter")]')
self.assertIsInstance(element,WebElement)
try:
element = driver.find_element_by_xpath('//a[contains(.,"Event control filter")]')
self.assertIsInstance(element,WebElement)
except AssertionError as e:
self.verificationErrors.append(str(e))
except NoSuchElementException as e:
self.verificationErrors.append(str(e))
#Return this change #Return this change
activate_home_screen(driver,"Default") activate_home_screen(driver,"Default")

View File

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
from selenium import selenium
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait, Select
from selenium.webdriver.support import expected_conditions as EC
from module_functions import search_module
from common_functions_60 import *
import random, time
import string
def assign_alert_template_to_module (driver,agent_name,module_name,template_name):
search_module(driver,agent_name,module_name)
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Alerts"]').click()
Select(driver.find_element_by_id("id_agent_module")).select_by_visible_text(module_name)
Select(driver.find_element_by_id("template")).select_by_visible_text(template_name)
driver.find_element_by_id("submit-add").click()
def force_alert_of_module(driver,agent_name,module_name,template_name):
click_menu_element(driver,"Agent detail")
driver.find_element_by_id("text-search").clear()
driver.find_element_by_id("text-search").send_keys(agent_name)
driver.find_element_by_id("submit-srcbutton").click()
driver.find_element_by_css_selector("b").click()
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Alerts"]').click()
driver.find_element_by_xpath('//tr[td[3][contains(.,"'+module_name+'")] and td[4][contains(.,"'+template_name+'")]]/td[2]/a').click()
time.sleep(10)

View File

@ -62,6 +62,8 @@ class PandoraWebDriverTestCase(TestCase):
self.verificationErrors = [] self.verificationErrors = []
self.accept_next_alert = True self.accept_next_alert = True
#self.is_development = self.is_development #self.is_development = self.is_development
#TODO Print test name
print "Starting test"
super(PandoraWebDriverTestCase, self).setUp() super(PandoraWebDriverTestCase, self).setUp()
def is_element_present(self, how, what): def is_element_present(self, how, what):

View File

@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
from selenium import selenium
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait, Select
from selenium.webdriver.support import expected_conditions as EC
from common_functions_60 import *
import random, time
import string
def search_events(driver,agent_name=None,module_name=None):
click_menu_element(driver,"View events")
driver.find_element_by_xpath('//a[contains(.,"Event control filter")]').click()
driver.find_element_by_xpath('//a[contains(.,"Advanced options")]').click()
if agent_name != None:
driver.find_element_by_id("text-text_agent").clear()
driver.find_element_by_id("text-text_agent").send_keys(agent_name)
time.sleep(3)
driver.find_element_by_xpath('//a[@class="ui-corner-all"][contains(.,"'+agent_name+'")]').click() # In this line you click the drop-down box search
if module_name != None:
driver.find_element_by_id("text-module_search").clear()
driver.find_element_by_id("text-module_search").send_keys(module_name)
time.sleep(3)
driver.find_element_by_xpath('//a[@class="ui-corner-all"][contains(.,"'+module_name+'")]').click() # In this line you click the drop-down box search
driver.find_element_by_id("submit-update").click()

View File

@ -16,18 +16,18 @@ def create_module(module_type,*args,**kwargs):
elif module_type=='data_server': elif module_type=='data_server':
create_data_server_module(*args,**kwargs) create_data_server_module(*args,**kwargs)
def create_network_server_module(driver,agent_name=None,module_name=None,component_group=None,type=None,network_component=None,min_warning=None,max_warning=None,min_critical=None,max_critical=None,ip=None,tag_name=None,description=None): def create_network_server_module(driver,agent_name=None,module_name=None,component_group=None,type_of_module=None,network_component=None,min_warning=None,max_warning=None,min_critical=None,max_critical=None,ip=None,tag_name=None,description=None):
# component_group -> Example: Remote ICMP network agent (latency) # component_group -> Example: Remote ICMP network agent (latency)
# network_component -> Example: Host Alive # network_component -> Example: Host Alive
#The type variable is optional, but required if component_group and network_component variables are specified #The type_of_module variable is optional, but required if component_group and network_component variables are specified
if agent_name != None: if agent_name != None:
search_agent(driver,agent_name) search_agent(driver,agent_name)
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Manage"]').click() driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Manage"]').click()
driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Modules"]').click() driver.find_element_by_xpath('//ul[@class="mn"]/li/a/img[@data-title="Modules"]').click()
Select(driver.find_element_by_id("moduletype")).select_by_visible_text("Create a new network server module") Select(driver.find_element_by_id("moduletype")).select_by_visible_text("Create a new network server module")
driver.find_element_by_xpath('//*[@id="main"]/form/table/tbody/tr/td[5]/input').click() driver.find_element_by_xpath('//*[@id="main"]/form/table/tbody/tr/td[5]/input').click()
@ -65,7 +65,7 @@ def create_network_server_module(driver,agent_name=None,module_name=None,compone
else: else:
driver.find_element_by_id("text-name").clear() driver.find_element_by_id("text-name").clear()
driver.find_element_by_id("text-name").send_keys(module_name) driver.find_element_by_id("text-name").send_keys(module_name)
Select(driver.find_element_by_id("id_module_type")).select_by_visible_text(type) Select(driver.find_element_by_id("id_module_type")).select_by_visible_text(type_of_module)
if module_name != None: if module_name != None:
time.sleep(3) time.sleep(3)
@ -85,11 +85,11 @@ def create_network_server_module(driver,agent_name=None,module_name=None,compone
driver.find_element_by_id("submit-crtbutton").click() driver.find_element_by_id("submit-crtbutton").click()
def create_data_server_module(driver,module_name,agent_name=None,type=None,min_warning=None,max_warning=None,min_critical=None,max_critical=None,tag_name=None,description=None): def create_data_server_module(driver,module_name,agent_name=None,type_of_module=None,min_warning=None,max_warning=None,min_critical=None,max_critical=None,tag_name=None,description=None):
# type -> Example: Generic numeric # type_of_module -> Example: Generic numeric
# The type variable is Generic numeric by default # The type_of_module variable is Generic numeric by default
if agent_name != None: if agent_name != None:
search_agent(driver,agent_name) search_agent(driver,agent_name)
@ -104,9 +104,9 @@ def create_data_server_module(driver,module_name,agent_name=None,type=None,min_w
driver.find_element_by_id("text-name").clear() driver.find_element_by_id("text-name").clear()
driver.find_element_by_id("text-name").send_keys(module_name) driver.find_element_by_id("text-name").send_keys(module_name)
if type != None: if type_of_module != None:
Select(driver.find_element_by_id("id_module_type")).select_by_visible_text(type) Select(driver.find_element_by_id("id_module_type")).select_by_visible_text(type_of_module)
if min_warning != None: if min_warning != None:
@ -166,4 +166,6 @@ def search_module (driver,agent_name,module_name):
driver.find_element_by_id("text-search_string").send_keys(module_name) driver.find_element_by_id("text-search_string").send_keys(module_name)
driver.find_element_by_id("submit-filter").click() driver.find_element_by_id("submit-filter").click()

View File

@ -9,7 +9,7 @@ import random, time
import string import string
def create_planned_downtime(driver,name,group,type_planned,description=None,execution=None,date_from=None,date_to=None,hour_from=None,hour_to=None,periodicity_type=None,from_day=None,to_day=None,list_days=None,list_agent=None): def create_planned_downtime(driver,name,group,type_planned,execution,description=None,date_from=None,date_to=None,hour_from=None,hour_to=None,periodicity_type=None,from_day=None,to_day=None,list_days=None,agent_module_list=None):
#type_planned is: Disabled Agents, Quiet or Disabled only Alerts #type_planned is: Disabled Agents, Quiet or Disabled only Alerts
@ -22,7 +22,12 @@ def create_planned_downtime(driver,name,group,type_planned,description=None,exec
#Execution by default is Once, date_from and date_to is date it's today's date #Execution by default is Once, date_from and date_to is date it's today's date
#list_agent is a list of agent that aplicate this planned downtime #agent_module_list is a list of tuples: lista = [('agent_name_1',['module_name_1','module_name_2']),('agent_name_2',[])]
#CAREFUL! [] means 'Any' module
#Self checks
if (date_from is None and date_to is not None) or (date_from is not None and date_to is None):
raise Exception("If one date is provided, the other should be provided too")
click_menu_element(driver,"Scheduled downtime") click_menu_element(driver,"Scheduled downtime")
driver.find_element_by_id("submit-create").click() driver.find_element_by_id("submit-create").click()
@ -39,17 +44,21 @@ def create_planned_downtime(driver,name,group,type_planned,description=None,exec
driver.find_element_by_xpath('//option[contains(.,"'+type_planned+'")]').click() driver.find_element_by_xpath('//option[contains(.,"'+type_planned+'")]').click()
if execution == "Once": if execution == "Once":
driver.find_element_by_id("text-once_date_from").clear() if date_from is not None:
driver.find_element_by_id("text-once_date_from").send_keys(date_from) driver.find_element_by_id("text-once_date_from").clear()
driver.find_element_by_id("text-once_date_from").send_keys(date_from)
driver.find_element_by_id("text-once_date_to").clear()
driver.find_element_by_id("text-once_date_to").send_keys(date_to) if date_to is not None:
driver.find_element_by_id("text-once_date_to").clear()
driver.find_element_by_id("text-once_time_from").clear() driver.find_element_by_id("text-once_date_to").send_keys(date_to)
driver.find_element_by_id("text-once_time_from").send_keys(hour_from)
if hour_from is not None:
driver.find_element_by_id("text-once_time_to").clear() driver.find_element_by_id("text-once_time_from").clear()
driver.find_element_by_id("text-once_time_to").send_keys(hour_to) driver.find_element_by_id("text-once_time_from").send_keys(hour_from)
if hour_to is not None:
driver.find_element_by_id("text-once_time_to").clear()
driver.find_element_by_id("text-once_time_to").send_keys(hour_to)
if execution == "Periodically": if execution == "Periodically":
Select(driver.find_element_by_id("type_periodicity")).select_by_visible_text(periodicity_type) Select(driver.find_element_by_id("type_periodicity")).select_by_visible_text(periodicity_type)
@ -69,19 +78,25 @@ def create_planned_downtime(driver,name,group,type_planned,description=None,exec
driver.find_element_by_id("text-periodically_time_to").clear() driver.find_element_by_id("text-periodically_time_to").clear()
driver.find_element_by_id("text-periodically_time_to").send_keys(hour_to) driver.find_element_by_id("text-periodically_time_to").send_keys(hour_to)
driver.find_element_by_id("submit-crtbutton").click() driver.find_element_by_id("submit-crtbutton").click()
if list_agent != None: if agent_module_list is not None:
for agent in list_agent: for agent_name,module_name_list in agent_module_list:
Select(driver.find_element_by_id("id_agents")).select_by_visible_text(agent) Select(driver.find_element_by_id("id_agents")).select_by_visible_text(agent_name)
alert = driver.switch_to_alert() if type_planned == "Quiet":
alert.accept() #Quiet types allow to select modules
driver.find_element_by_id("submit-add_item").click() time.sleep(3)
if module_name_list is not []:
driver.find_element_by_id("submit-add_item").click() Select(driver.find_element_by_id("module")).deselect_by_visible_text('Any')
alert = driver.switch_to_alert() for module_name in module_name_list:
alert.accept() Select(driver.find_element_by_id("module")).select_by_visible_text(module_name)
driver.find_element_by_id("submit-add_item").click()
try:
alert = driver.switch_to_alert()
alert.accept()
except:
pass
def search_planned_downtime(driver,name,type_planned=None,date_from=None,date_to=None,show_past_downtimes=False): def search_planned_downtime(driver,name,type_planned=None,date_from=None,date_to=None,show_past_downtimes=False):
@ -118,8 +133,8 @@ def stop_downtime(driver,name):
def delete_planned_downtime(driver,name): def delete_planned_downtime(driver,name):
search_planned_downtime(driver,name) search_planned_downtime(driver,name)
if (u"Running" in driver.page_source): if (u"Not running" not in driver.page_source):
stop_downtime(driver,name) stop_downtime(driver,name)
search_planned_downtime(driver,name,show_past_downtimes=True) search_planned_downtime(driver,name,show_past_downtimes=True)
driver.find_element_by_xpath('//*[@id="delete_downtime"]/img').click() driver.find_element_by_xpath('//*[@id="delete_downtime"]/img').click()