forked from arkime/arkime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi-multies.t
105 lines (81 loc) · 5.36 KB
/
api-multies.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
use Test::More tests => 37;
use Cwd;
use URI::Escape;
use MolochTest;
use JSON;
use Data::Dumper;
use Test::Differences;
use strict;
my $json;
$json = mesGet("/");
is ($json->{tagline}, "You Know, for Search", "ES tagline");
ok (!exists $json->{status} || $json->{status} == 200, "ES no status or 200 status");
$json = mesGet("/_template/MULTIPREFIX_sessions3_template?filter_path=**._meta");
cmp_ok($json->{MULTIPREFIX_sessions3_template}->{mappings}->{_meta}->{molochDbVersion}, '>=', 50, "dstats version is at least 50");
#_stats
$json = mesGet("/MULTIPREFIX_stats/_stats");
is ($json->{cluster}, "test", "Correct cluster status");
is (exists $json->{indices}->{MULTIPREFIX_stats_v30}, 1, "Correct stats/_stats index");
$json = mesGet("/MULTIPREFIX_files/_stats");
cmp_ok($json->{indices}->{MULTIPREFIX_files_v30}->{total}->{docs}->{count}, '>=', 60, "files count is at least 60");
$json = mesGet("/MULTIPREFIX_sequence/_stats");
cmp_ok($json->{indices}->{MULTIPREFIX_sequence_v30}->{total}->{docs}->{count}, '>=', 1, "sequence count is at least 1");
$json = mesGet("/MULTIPREFIX_dstats/_stats");
cmp_ok($json->{indices}->{MULTIPREFIX_dstats_v30}->{total}->{docs}->{count}, '>=', 1, "dstats count is at least 1");
# _count
$json = mesPost("/MULTIPREFIX_users/_count?ignore_unavailable=true", "");
is ($json->{count}, 0, "Correct count number of users");
$json = mesPost("/MULTIPREFIX_sessions2-*,MULTIPREFIX_sessions3-*/_count?ignore_unavailable=true", "");
cmp_ok ($json->{count}, '>=', 80, "Correct count number of sessions");
$json = mesPost("/MULTIPREFIX_stats*/_count?ignore_unavailable=true", "");
cmp_ok ($json->{count}, '>=', 1, "Correct count number of stats");
$json = mesPost("/MULTIPREFIX_files*/_count?ignore_unavailable=true", "");
cmp_ok ($json->{count}, '>=', 60, "Correct count number of files");
# _cluster
$json = mesGet("/_cluster/health");
is ($json->{number_of_data_nodes}, 2, "Correct _cluster/health number of nodes");
is ($json->{cluster_name}, "COMBINED", "Correct _cluster/health name");
# _cluster/settings
$json = mesGet("/_cluster/settings");
eq_or_diff($json, from_json('{"persistent": {}, "transient": {}}'));
# _cluster/_doc/details
$json = mesGet("/_cluster/_doc/details");
is ($json->{available}->[0], "test", "Correct available ES cluster");
is ($json->{available}->[1], "test2", "Correct acvilable ES cluster");
is ($json->{active}->[0], "test", "Correct active ES cluster");
is ($json->{active}->[1], "test2", "Correct active ES cluster");
is (scalar @{$json->{inactive}}, 0, "Correct number of ES cluster name");
# _node
$json = mesGet("/_nodes/stats?fs=1");
is ($json->{cluster}, "test", "Correct _node status");
$json = mesGet("/_nodes/stats?jvm=1&process=1&fs=1&search=1&os=1");
is ($json->{cluster}, "test", "Correct _node status");
# aliases
$json = mesGet("/MULTIPREFIX_sessions2-*,MULTIPREFIX_sessions3-*/_alias");
is (exists $json->{"MULTIPREFIX_sessions2-050330"} || exists $json->{"MULTIPREFIX_sessions3-050330"}, 1, "Correct session alias");
is (exists $json->{"MULTIPREFIX_sessions2-140113"} || exists $json->{"MULTIPREFIX_sessions3-140113"}, 1, "Correct session alias");
# _search
$json = mesGet("/MULTIPREFIX_stats/_search?rest_total_hits_as_int=true");
cmp_ok($json->{hits}->{total}, '>=', 1, "stats/search count is at least 1");
is ($json->{hits}->{hits}->[0]->{_index}, "MULTIPREFIX_stats_v30", "Correct stats index name");
$json = mesPost("/MULTIPREFIX_stats/_search?rest_total_hits_as_int=true", "{}");
cmp_ok($json->{hits}->{total}, '>=', 1, "stats/search count is at least 1");
is ($json->{hits}->{hits}->[0]->{_index}, "MULTIPREFIX_stats_v30", "Correct stats index name");
$json = mesPost("/MULTIPREFIX_fields/_search?rest_total_hits_as_int=true", "{\"size\":1000}");
cmp_ok($json->{hits}->{total}, '>=', 190, "fields count is at least 190");
cmp_ok($json->{hits}->{total}, '<', 400, "fields count is less then 400");
is ($json->{hits}->{hits}->[0]->{_index}, "MULTIPREFIX_fields_v30", "Correct fields index name");
$json = mesGet("/MULTIPREFIX_sessions3-141015/_search?preference=primary_first&ignore_unavailable=true&rest_total_hits_as_int=true");
if ($json->{hits}->{total} == 0) {
$json = mesGet("/MULTIPREFIX_sessions2-141015/_search?preference=primary_first&ignore_unavailable=true&rest_total_hits_as_int=true");
is ($json->{hits}->{hits}->[0]->{_index}, "MULTIPREFIX_sessions2-141015", "Correct sessions index name");
} else {
is ($json->{hits}->{hits}->[0]->{_index}, "MULTIPREFIX_sessions3-141015", "Correct sessions index name");
}
cmp_ok($json->{hits}->{total}, '>=', 6, "sessions count is at least 6");
$json = mesPost("/MULTIPREFIX_sessions3-141015/_search?preference=primary_first&ignore_unavailable=true&rest_total_hits_as_int=true", '{"size":20000}');
is ($json->{hits}->{hits}->[0]->{_index}, "MULTIPREFIX_sessions3-141015", "Correct sessions index name");
cmp_ok($json->{hits}->{total}, '>=', 6, "sessions count is at least 6");
$json = mesPost("/MULTIPREFIX_sessions3-141015/_search?preference=primary_first&ignore_unavailable=true&rest_total_hits_as_int=true", '{"from": 100, "size":20000}');
is (scalar @{$json->{hits}->{hits}}, 0);
cmp_ok($json->{hits}->{total}, '>=', 6, "sessions count is at least 6");