Commit Graph

13850 Commits

Author SHA1 Message Date
armirveliaj
2a95c49d3b Add new options to trends configuration
- store_interval
 - ees_conns
 - ees_exporter_ids
2024-10-08 20:52:19 +02:00
armirveliaj
d2d161fcce Add coverage tests on engine 2024-10-05 20:33:33 +02:00
armirveliaj
9321888d3f Add new unit tests for TrendS 2024-10-03 17:43:46 +02:00
armirveliaj
37322e9c4c Add coverage test for trendscfg 2024-10-01 20:04:54 +02:00
armirveliaj
5b039c1d0b Add new trends config option: scheduled_ids 2024-10-01 20:04:54 +02:00
ionutboangiu
9b8ac3199b Revise EfSv1.ReplayEvents API + tests
- renamed parameter type: ArgsReplyFailedPosts -> ReplayEventsParams
- renamed param fields:
  - FailedRequestsInDir -> SourcePath
  - FailedRequestsOutDir -> FailedPath
  - TypeProvider -> Provider
- changed param fields types from *string to string
- used the SourcePath and FailedPath params directly instead of creating separate variables
- used filepath.WalkDir instead of reading the directory and looping over the entries
- used slices.ContainsFunc to check if the file belongs to any module (if 1+ is specified)
- used filepath.Join instead of path.Join
- used the path provided by WalkFunc instead of building the file paths ourselves
- made error returns more descriptive
- added logs for directories/files that are skipped
- paths that cannot be accessed are skipped after logging the error
2024-09-25 20:58:51 +02:00
ionutboangiu
f26a0c2d0b Reduce client connection attempts to test engine status
200 -> 16

Previously, considering the fibonacci back off strategy, if engine failed to
start it would have tried to attempt connections for 2.862799e+33 years.

Now, the amount of attempts is 16, equivalent to around 2 and a half seconds.
Should be more than enough, considering that usually 6-7 attempts are enough.
2024-09-25 20:58:51 +02:00
ionutboangiu
fe1a2a13bd Update bleve library to latest version 2024-09-25 20:58:51 +02:00
ionutboangiu
b5362f89ef Optimize and fix unstable tests
Revise backup loop tests to not rely on time.Sleep anymore and remove
unused fields from them.

Optimize some analyzers tests.
2024-09-25 20:58:51 +02:00
ionutboangiu
df3c98e842 Revise agents *uch unit test
- optimized it (2s -> 0.03s) by lowering the cfg cache TTL to 5ms
  instead of 1s, which was enough to get consistent results.
- increase margin of error by 1ms
- in case of failure, retrieve the expiry time and log it along the
current time. Makes troubleshooting easier in the future.
2024-09-25 20:58:51 +02:00
armirveliaj
3d7c5ed201 Add coverage tests on engine 2024-09-24 17:18:55 +02:00
gezimblliku
d20f1a50fd added ees_conns on stats 2024-09-24 10:41:18 +02:00
ionutboangiu
1b70de7957 Add badge for unit tests workflow 2024-09-23 20:28:26 +02:00
ionutboangiu
63c1358c3f Update behaviour of file readers using inotify
Ensure that files already existing in the source path are processed
before the reader starts listening for filesystem change events.
2024-09-23 20:28:26 +02:00
ionutboangiu
65e8128303 Implement ErSv1.RunReader api 2024-09-23 20:28:26 +02:00
ionutboangiu
cf9cc5dcfc Generate missing dispatcher methods 2024-09-23 20:28:26 +02:00
ionutboangiu
5e27106e48 Update main cgr-engine config sample 2024-09-23 20:28:26 +02:00
ionutboangiu
71b5efef40 Remove global err variable (general_tests)
Prevents compilation errors from tests moved to
flaky that use it.
2024-09-23 20:28:26 +02:00
ionutboangiu
d27e7aae20 Improve nats integration test
- made use of the test setup helpers.
- used t.Cleanup instead of defer.
- instead of waiting 50ms for the nats-server to start, used a helper
hook to attempt connections in fibonacci intervals. On success it
keeps a reference to the connection for later usage.
- handle error for stream delete function executed during cleanup.
- shorten time.Sleep durations when waiting for exports to finish.
- extract the cache itemID checking logic into a separate func
- retry failed requests in fibonacci intervals for up to 500ms
2024-09-23 20:28:26 +02:00
ionutboangiu
5cb7ce2e93 Rename fibNrAsDuration -> fibNr 2024-09-23 20:28:26 +02:00
ionutboangiu
e228dda013 Improve test setup helpers
- added hook support (executed after parsing config but before
starting engine)
- made db resets configurable
- merged config parsing helper with the main Setup function
- removed engineDelay parameter
- replaced t.Log with t.Error for engine process kill error
- improved option comments
2024-09-23 20:28:26 +02:00
ionutboangiu
9236c8a1e7 Add method on ERsCfg to retrieve reader by ID 2024-09-23 20:28:26 +02:00
ionutboangiu
e1adb674b8 Remove redundant dir parameter from processFile methods
Applies to both file readers and loader (for loader, the blank statement
was used anyway).

It's redundant because for file readers, the rdr.sourceDir value was
always passed as the parameter when it was already part of the method's
object.

Parameter had to also be removed from the WatchDir function and the
functions it depends on.
2024-09-23 20:28:26 +02:00
ionutboangiu
7998ed6a0f Extract common dir processing logic to a func
It will be reused for all file readers.
Rename rdrDir field to sourceDir.
2024-09-23 20:28:26 +02:00
ionutboangiu
da8c468c0c Remove unused parameters from fs connect func 2024-09-23 20:28:26 +02:00
ionutboangiu
a0ba8e352b FSAgent: ensure MaxReconnectInterval is being used
option was added previously but not made use of
2024-09-23 20:28:26 +02:00
ionutboangiu
6ed3c5592d Add reply_timeout field for FS event socket conns 2024-09-23 20:28:26 +02:00
ionutboangiu
87847f5028 Update xmldp sanity check test to check non-*req paths 2024-09-23 20:28:26 +02:00
ionutboangiu
449bc5c08a Add active_session_delimiter option for fs_agent
Used for 'show_channels' requests and responses.
2024-09-23 20:28:26 +02:00
gezimblliku
0f81b78321 updated trend profile && trends service implementation 2024-09-23 11:48:04 +02:00
ionutboangiu
682e2daf60 Move inconsistent rates dsp test to flaky 2024-09-20 11:24:37 +02:00
ionutboangiu
615a55e9b8 Update config it tests 2024-09-20 11:24:37 +02:00
ionutboangiu
edfe2b5ef7 Revise nats reader integration tests
They were failing after the ERs structure changes.

Added a commented helper program at the end of the test to
help generate credentials for testing nats JWT functionality
2024-09-20 11:24:37 +02:00
ionutboangiu
d801352cce slightly optimize TenantID constructor 2024-09-05 20:46:40 +02:00
ionutboangiu
bc89fe320e add tests for arith operations (AttributeS) 2024-09-05 20:46:40 +02:00
ionutboangiu
0063ef3822 Add support for mongodb+srv conn format
Option can be found in db opts under the name 'mongoConnScheme'.
2024-09-05 20:46:40 +02:00
ionutboangiu
81b97bb9af add reconnect logic to AMQP reader (#4160)
Implemented functionality that handles reconnecting to the amqp server
and reinitializing the amqp channel in case of errors and timeouts. This
is handled by a goroutine created in the client constructor (it also
handles the initial connect/init).

Reconnects and reinits will use a fibonacci backoff strategy, and the
attempt amount and max waiting interval can be adjusted by the
'reconnects' and 'max_reconnect_interval' config options.

Messages that fail processing are now dropped instead of being requeued,
preventing infinite processing loops. However, this means that the
messages are lost. Handling failed messages will need to be addressed
separately.

'concurrent_requests' will now set the prefetch count. Setting the
prefetch count using the Qos function was able to replace our old
approach that was using channels. Default value is 1024 which,
according to the rabbitmq docs, 'runs into the law of diminishing
returns'. The recommended value is between 100-300. Source:
https://www.rabbitmq.com/confirms.html#channel-qos-prefetch-throughput
2024-09-05 20:46:40 +02:00
ionutboangiu
1c73e42307 Revise ERs event exporting
Make use of the previously added ees_success_ids and ees_failed_ids
configuration fields.

Remove Processed opts and everything related to them since they should
not be used anymore.

Fixed test compilation errors caused by the change.
2024-09-05 20:46:40 +02:00
ionutboangiu
4135760e9d fix failing config integration tests 2024-09-05 20:46:40 +02:00
ionutboangiu
795fc18195 Add ees_conns field option for ERs section
Add ees_success_ids and ees_failed_ids fields in reader config. The
former will be used to set EeIDs when the event processing returns
no error, while the latter will be used otherwise (implementation
will follow).

Add config sanity checks for the added options.
2024-09-05 20:46:40 +02:00
ionutboangiu
dc53171ce2 Add reconnects and max_reconnect_interval config options for ers
They are separate for each configured reader.

Additional changes:
 - rearrange config_defaults fields for ers/ees;
 - add comment for RunDelay config option inside struct definition;
 - improve comments for amqp opts in config_defaults.
2024-09-05 20:46:40 +02:00
ionutboangiu
aa5069e16e Remove go type limits constants
They can be retrieved directly from the std math package.
Slightly optimize the Fib functions and improve comments.
2024-09-05 20:46:40 +02:00
ionutboangiu
e863c63db2 fix failing binc unmarshal test
now returns unexpected EOF instead of just EOF following
ugorji/go/codec library update (1.2.11->1.2.12)
2024-09-05 20:46:40 +02:00
ionutboangiu
c2ded003fa Implement additional retrieval methods for ordered map
Map() is used to return a shallow copy of the underlying map.
GetByIndex() is used to return the key-value pair at the specified index.
2024-09-05 20:46:40 +02:00
ionutboangiu
bd3e18754b Clone header before creating exporter HTTP request
Behind http.Header is just a map and it's not safe for concurrent use.
Before this change, a panic might have occurred when doing asynchronous
HTTP exports (applies to both *http_post and *http_json_map exporters).
Cloning the header before adding it to the HTTP request has fixed this
issue.

Slightly improved the test that found this data race.
2024-09-05 20:46:40 +02:00
ionutboangiu
1a66dd52dd chore: format go.mod
deleted all indirect dependencies and ran:

- go mod tidy
- go get -u ./...
- go mod tidy
2024-09-05 20:46:40 +02:00
ionutboangiu
c0d800d3d0 Add shebang for postgres scripts 2024-09-05 20:46:40 +02:00
ionutboangiu
3764594fcc revise logging .conf files 2024-09-05 20:46:40 +02:00
ionutboangiu
169b5500d3 Revise err handling for CSV storage constructor
NewFileCSVStorage() now returns an error besides the storage struct itself, which is
logged and returned instead of calling log.Fatal() which was causing the engine to
crash.

Fixed compilation errors by creating the CSVStorage separately and passing it as an
argument to the TpReader constructor.

Fixes #3962
2024-09-05 20:46:40 +02:00
ionutboangiu
bd691d8301 Adjust prefixes to skip when sanity checking xmlRootPath
Before everything starting with '~' was considered, but the check
should be done only with paths starting with '~*req'.
2024-09-05 20:46:40 +02:00