Skip to content

Commit

Permalink
.......... [DEV-2159] made integration tests more stable by using sep…
Browse files Browse the repository at this point in the history
…arate file for checking access time
  • Loading branch information
arimdjonokszabbix committed Nov 2, 2022
2 parents bf4c2e5 + 4b1e3d2 commit 3c201d8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 31 deletions.
37 changes: 21 additions & 16 deletions ui/tests/integration/testAgentItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class testAgentItems extends CIntegrationTest {
const TEST_FILE_BASE_NAME = 'test_file';
const TEST_LINK_BASE_NAME = 'test_link';
const TEST_FILE_NAME = '/tmp/'.self::TEST_FILE_BASE_NAME;
const TEST_FILE_NAME_ACCESS = '/tmp/'.self::TEST_FILE_BASE_NAME.'_access_test';
const TEST_LINK_NAME = '/tmp/'.self::TEST_LINK_BASE_NAME;
const TEST_LINK_NAME2 = '/tmp/'.self::TEST_LINK_BASE_NAME.'2';
const TEST_DIR_NAME = '/tmp/dir';
Expand Down Expand Up @@ -196,52 +197,52 @@ class testAgentItems extends CIntegrationTest {
'result' => 'b73a96d498012c84fc2ffa1df3c4461689cb90456ee300654723205c26ec4988'
],
[
'key' => 'vfs.file.get['.self::TEST_FILE_NAME.']',
'key' => 'vfs.file.get['.self::TEST_FILE_NAME_ACCESS.']',
'type' => ITEM_TYPE_ZABBIX,
'component' => self::COMPONENT_AGENT,
'valueType' => ITEM_VALUE_TYPE_TEXT,
'json' => JSON_COMPARE_LEFT,
'fields_exec' => ['permissions', 'user', 'group', 'uid', 'gid', 'access', 'change'],
'result' => [
'type' => 'file',
'permissions' => 'stat -c %04a '.self::TEST_FILE_NAME,
'user' => 'stat -c %U '.self::TEST_FILE_NAME,
'group' => 'stat -c %G '.self::TEST_FILE_NAME,
'uid' => 'stat -c %u '.self::TEST_FILE_NAME,
'gid' => 'stat -c %g '.self::TEST_FILE_NAME,
'permissions' => 'stat -c %04a '.self::TEST_FILE_NAME_ACCESS,
'user' => 'stat -c %U '.self::TEST_FILE_NAME_ACCESS,
'group' => 'stat -c %G '.self::TEST_FILE_NAME_ACCESS,
'uid' => 'stat -c %u '.self::TEST_FILE_NAME_ACCESS,
'gid' => 'stat -c %g '.self::TEST_FILE_NAME_ACCESS,
'size' => 27,
'time' => [
'modify' => '2021-03-29T14:59:09+0300'
],
'timestamp' => [
'access' => 'stat -c %X '.self::TEST_FILE_NAME,
'access' => 'stat -c %X '.self::TEST_FILE_NAME_ACCESS,
'modify' => self::TEST_MOD_TIMESTAMP,
'change' => 'stat -c %Z '.self::TEST_FILE_NAME
'change' => 'stat -c %Z '.self::TEST_FILE_NAME_ACCESS
]
]
],
[
'key' => 'vfs.file.get['.self::TEST_FILE_NAME.']',
'key' => 'vfs.file.get['.self::TEST_FILE_NAME_ACCESS.']',
'type' => ITEM_TYPE_ZABBIX,
'component' => self::COMPONENT_AGENT2,
'valueType' => ITEM_VALUE_TYPE_TEXT,
'json' => JSON_COMPARE_LEFT,
'fields_exec' => ['permissions', 'user', 'group', 'uid', 'gid', 'access', 'change'],
'result' => [
'type' => 'file',
'permissions' => 'stat -c %04a '.self::TEST_FILE_NAME,
'user' => 'stat -c %U '.self::TEST_FILE_NAME,
'group' => 'stat -c %G '.self::TEST_FILE_NAME,
'uid' => 'stat -c %u '.self::TEST_FILE_NAME,
'gid' => 'stat -c %g '.self::TEST_FILE_NAME,
'permissions' => 'stat -c %04a '.self::TEST_FILE_NAME_ACCESS,
'user' => 'stat -c %U '.self::TEST_FILE_NAME_ACCESS,
'group' => 'stat -c %G '.self::TEST_FILE_NAME_ACCESS,
'uid' => 'stat -c %u '.self::TEST_FILE_NAME_ACCESS,
'gid' => 'stat -c %g '.self::TEST_FILE_NAME_ACCESS,
'size' => 27,
'time' => [
'modify' => '2021-03-29T14:59:09+03:00'
],
'timestamp' => [
'access' => 'stat -c %X '.self::TEST_FILE_NAME,
'access' => 'stat -c %X '.self::TEST_FILE_NAME_ACCESS,
'modify' => self::TEST_MOD_TIMESTAMP,
'change' => 'stat -c %Z '.self::TEST_FILE_NAME
'change' => 'stat -c %Z '.self::TEST_FILE_NAME_ACCESS
]
]
],
Expand Down Expand Up @@ -708,6 +709,8 @@ public function prepareData() {
// Write test file
$this->assertTrue(@file_put_contents(self::TEST_FILE_NAME, "1st line\n2nd line\n3rd line\n") !== false);
$this->assertTrue(@touch(self::TEST_FILE_NAME, self::TEST_MOD_TIMESTAMP));
$this->assertTrue(@file_put_contents(self::TEST_FILE_NAME_ACCESS, "1st line\n2nd line\n3rd line\n") !== false);
$this->assertTrue(@touch(self::TEST_FILE_NAME_ACCESS, self::TEST_MOD_TIMESTAMP));
$this->assertTrue(@file_put_contents(self::TEST_DIR_FILE_NAME, "1st line\n2nd line\n3rd line\n") !== false);
$this->assertTrue(@touch(self::TEST_DIR_FILE_NAME, self::TEST_MOD_TIMESTAMP));

Expand All @@ -727,6 +730,8 @@ public function prepareData() {

$this->assertTrue(@touch(self::TEST_DIR_DIR1_NAME, self::TEST_MOD_TIMESTAMP));

$this->assertTrue(@exec('touch -h -a -m -t 202103291459.09 '.self::TEST_FILE_NAME_ACCESS) !== false);

return true;
}

Expand Down
30 changes: 15 additions & 15 deletions ui/tests/integration/testGoAgentDataCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,31 +220,31 @@ class testGoAgentDataCollection extends CIntegrationTest {
'key' => 'system.cpu.util[,,avg1]',
'type' => ITEM_TYPE_ZABBIX,
'valueType' => ITEM_VALUE_TYPE_FLOAT,
'threshold' => 0.5
'threshold' => 0.9
],
[
'key' => 'system.cpu.load[,avg1]',
'type' => ITEM_TYPE_ZABBIX,
'valueType' => ITEM_VALUE_TYPE_FLOAT,
'threshold' => 0.5
'threshold' => 0.9
],
[
'key' => 'vfs.dev.read[,operations]',
'type' => ITEM_TYPE_ZABBIX,
'valueType' => ITEM_VALUE_TYPE_UINT64,
'threshold' => 10
'threshold' => 1000
],
[
'key' => 'vfs.dev.write[,operations]',
'type' => ITEM_TYPE_ZABBIX,
'valueType' => ITEM_VALUE_TYPE_UINT64,
'threshold' => 100
'threshold' => 10000
],
[
'key' => 'proc.cpu.util[,,,,avg1]',
'type' => ITEM_TYPE_ZABBIX,
'valueType' => ITEM_VALUE_TYPE_FLOAT,
'threshold' => 10.0,
'threshold' => 90.0,
'compareType' => self::COMPARE_AVERAGE
],
[
Expand All @@ -258,68 +258,68 @@ class testGoAgentDataCollection extends CIntegrationTest {
'key' => 'system.swap.out[,pages]',
'type' => ITEM_TYPE_ZABBIX,
'valueType' => ITEM_VALUE_TYPE_UINT64,
'threshold' => 100,
'threshold' => 10000,
'compareType' => self::COMPARE_AVERAGE
],
[
'key' => 'proc.mem[zabbix_server,zabbix,avg]',
'type' => ITEM_TYPE_ZABBIX,
'valueType' => ITEM_VALUE_TYPE_FLOAT,
'threshold' => 100.0
'threshold' => 10000.0
],
[
'key' => 'web.page.perf[http://localhost]',
'type' => ITEM_TYPE_ZABBIX,
'valueType' => ITEM_VALUE_TYPE_FLOAT,
'threshold' => 1.0,
'threshold' => 100.0,
'compareType' => self::COMPARE_AVERAGE
],
[
'key' => 'net.tcp.service.perf[ssh]',
'type' => ITEM_TYPE_ZABBIX,
'valueType' => ITEM_VALUE_TYPE_FLOAT,
'threshold' => 0.05
'threshold' => 5.00
],
[
'key' => 'net.udp.service.perf[ntp]',
'type' => ITEM_TYPE_ZABBIX,
'valueType' => ITEM_VALUE_TYPE_FLOAT,
'threshold' => 0.05
'threshold' => 5.00
],
[
'key' => 'system.swap.size[,total]',
'type' => ITEM_TYPE_ZABBIX,
'valueType' => ITEM_VALUE_TYPE_UINT64,
'threshold' => 100,
'threshold' => 10000,
'compareType' => self::COMPARE_AVERAGE
],
[
'key' => 'vfs.fs.inode[/,pfree]',
'type' => ITEM_TYPE_ZABBIX,
'valueType' => ITEM_VALUE_TYPE_FLOAT,
'threshold' => 0.1,
'threshold' => 0.9,
'compareType' => self::COMPARE_AVERAGE
],
[
'key' => 'vfs.fs.size[/tmp,free]',
'type' => ITEM_TYPE_ZABBIX,
'valueType' => ITEM_VALUE_TYPE_UINT64,
'threshold' => 10000000,
'threshold' => 100000000,
'compareType' => self::COMPARE_AVERAGE
],
[
'key' => 'vm.memory.size[free]',
'type' => ITEM_TYPE_ZABBIX,
'valueType' => ITEM_VALUE_TYPE_UINT64,
'threshold' => 10000000,
'threshold' => 100000000,
'compareType' => self::COMPARE_AVERAGE
],
[// Should be treated as a special case, since this metric returns JSON object.
// Maybe, it should e pulled to separate test suite. At this point we just compare it as string.
'key' => 'zabbix.stats[127.0.0.1,'.PHPUNIT_PORT_PREFIX.self::SERVER_PORT_SUFFIX.']',
'type' => ITEM_TYPE_ZABBIX,
'valueType' => ITEM_VALUE_TYPE_TEXT,
'threshold' => 50
'threshold' => 500
]
];

Expand Down

0 comments on commit 3c201d8

Please sign in to comment.