mirror of
https://github.com/ntop/ntopng.git
synced 2026-07-12 17:31:13 +00:00
- Add python/tests/test_ntopng_sdk.py with 86 unit tests covering:
- Ntopng: constructor (auth_token / user+pass), request/post_request wrappers,
all getter methods, debug flag, URL building
- Interface: all data, alert, flow, L7/L4 and host methods
- Host: get_host_data, get_l7_stats, get_dscp_stats (both directions), VLAN handling
- Historical: all alert family delegates, timeseries, flows, conversations
- Fix bug in historical.py get_host_top_protocols(): self.ifid (int) was
concatenated with strings without str() conversion, causing TypeError at runtime
- Add scripts/lua/modules/timeseries/tests/ts_common_test.lua with 11 test cases:
- upsampleSerie: no-op when target <= source length, empty serie
- calculateMinMax: basic, single element, NaN-skipping
- calculateStatistics: counter (total*step), gauge+keep_total, gauge no-total, NaN-skipping
- ninetififthPercentile: single element, all-NaN
- Register ts_common_test in the Lua test runner (run.lua)
Agent-Logs-Url: https://github.com/ntop/ntopng/sessions/32da23c3-306c-4100-9bbe-64b91191653b
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: lucaderi <4493366+lucaderi@users.noreply.github.com>
66 lines
1.3 KiB
Lua
66 lines
1.3 KiB
Lua
--
|
|
-- (C) 2021 - ntop.org
|
|
--
|
|
|
|
local dirs = ntop.getDirs()
|
|
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
|
|
require("lua_utils")
|
|
package.path = dirs.installdir .. "/scripts/lua/modules/timeseries/drivers/?.lua;" .. package.path
|
|
package.path = dirs.installdir .. "/scripts/lua/modules/timeseries/tests/?.lua;" .. package.path
|
|
|
|
-- ##############################################
|
|
|
|
local tests = {
|
|
require("utils_test"),
|
|
require("rrd_paths_test"),
|
|
require("ts_common_test"),
|
|
}
|
|
|
|
-- ##############################################
|
|
|
|
local test = {}
|
|
|
|
function test:new(name)
|
|
local obj = {
|
|
name = name,
|
|
}
|
|
|
|
setmetatable(obj, self)
|
|
self.__index = self
|
|
|
|
return obj
|
|
end
|
|
|
|
function test:success()
|
|
print(self.name .. " OK<br>")
|
|
return true
|
|
end
|
|
|
|
function test:fail(message)
|
|
print(self.name .. " FAILED: ".. message .."<br>")
|
|
return false
|
|
end
|
|
|
|
function test:assertion_failed(assertion)
|
|
print(self.name .. " ASSERTION FAILED: ".. assertion .."<br>")
|
|
return false
|
|
end
|
|
|
|
local tester = {
|
|
new_test = function(name)
|
|
return test:new(name)
|
|
end,
|
|
|
|
run_test = function(name, fn)
|
|
local test = test:new(name)
|
|
return fn(test)
|
|
end
|
|
}
|
|
|
|
-- ##############################################
|
|
|
|
sendHTTPContentTypeHeader('text/html')
|
|
|
|
for _, test in ipairs(tests) do
|
|
test.run(tester)
|
|
end
|