Skip to content

Commit

Permalink
Merge branch 'task/#24158-Update_and_use_default_config_for_testing' …
Browse files Browse the repository at this point in the history
…into 'integration'

Resolve #24158 "Task/ update and use default config for testing"

See merge request elektrobit/base-os/elos!128
  • Loading branch information
gehwolf committed Aug 28, 2024
2 parents 245c2ef + ddd8c4d commit ba54c5d
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 119 deletions.
4 changes: 2 additions & 2 deletions ci/Dockerfile.elosd
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ WORKDIR /home/elos
COPY ./ /home/elos

RUN mkdir /etc/elos
COPY ./test/integration/service/config.json /etc/elos/elosd.json
COPY ./src/components/config/elosd.json /etc/elos/elosd.json
RUN chmod 644 /etc/elos/elosd.json

ENV SOURCES_URI=$SOURCES_URI
Expand All @@ -51,7 +51,7 @@ RUN cmake -B /tmp/elos/build . -DCMAKE_BUILD_TYPE=Release -G Ninja -DUNIT_TESTS=
RUN ninja -C /tmp/elos/build all
RUN sudo ninja -C /tmp/elos/build install

COPY ./test/integration/service/elosd.service /etc/init.d/elosd
COPY ./ci/elosd.service /etc/init.d/elosd
RUN chmod a+x /etc/init.d/elosd

RUN sudo ldconfig
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion cmake/project.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: MIT
set(ELOS_VERSION 0.62.6)
set(ELOS_VERSION 0.63.0)

# Attention: Aside from the version, as many things as possible in this file
# should be put into functions, as this solves potential issues with commands
Expand Down
19 changes: 11 additions & 8 deletions src/components/config/elosd.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"Interface": "127.0.0.1",
"EventBlacklist": ".event.messageCode 1000 LE",
"authorizedProcesses": [
".process.uid 0 EQ .process.gid 0 EQ .process.exec '/bin/elosc' STRCMP AND",
".process.uid 0 EQ .process.gid 0 EQ AND .process.exec '/bin/elosc' STRCMP AND",
".process.gid 200 EQ .process.exec '/bin/elosc' STRCMP AND",
".process.pid 1 EQ"
]
Expand All @@ -38,7 +38,7 @@
"Dummy": {
"File": "backend_dummy.so",
"Run": "always",
"Filters": [
"Filter": [
"1 1 EQ"
]
},
Expand All @@ -49,12 +49,15 @@
"JsonBackend": {
"File": "backend_json.so",
"Run": "always",
"Filters": [
"Filter": [
"1 1 EQ"
],
"Config": {
"StoragePath": "/tmp/elosd_%host%_%date%_%count%.log",
"Flags": []
"MaxSize": 60000,
"Flags": [
"O_SYNC"
]
}
},
"SQLBackend": {
Expand All @@ -71,7 +74,7 @@
"File": "backend_dlt_logger.so",
"Run": "always",
"Filter": [
".messageCode 1000 GE"
".e.messageCode 1000 GE"
],
"Config": {
"Connection": "/tmp/dlt",
Expand All @@ -98,9 +101,9 @@
"SyslogPath": "/dev/log",
"MappingRules": {
"MessageCodes": {
"4000": ".event.source.appName 'ssh' STRCMP",
"2000": ".event.source.appName 'crinit' STRCMP",
"1000": ".event.source.appName 'login' STRCMP"
"8004": ".event.source.appName 'sshd' STRCMP .e.payload r'authentication failure' REGEX AND",
"8005": ".event.source.appName 'sshd' STRCMP .e.payload r'Accepted password for' REGEX AND",
"1001": "1 1 EQ"
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/integration/libraries/ElosdLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ class ElosdLibrary(object):
with target elosd.
"""
host = "127.0.0.1"
port = 8080
port = 54321
socket = None

def elosd_connect(self, host, port):
"""Connect to a elosd target.
| host | ip string to connect to | Default=8080 |
| port | elosd port | Default=8080 |
| host | ip string to connect to | Default=54321 |
| port | elosd port | Default=54321 |
"""
self.host = host
self.port = port
Expand Down
4 changes: 2 additions & 2 deletions test/integration/resources/elosd-keywords.resource
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Library libraries/TemplateConfig.py
*** Variables ***
${ELOSD_PATH} ${ELOS_INSTALL_PREFIX}/elosd
${ELOSC_PATH} ${ELOS_INSTALL_PREFIX}/elosc
${ELOSD_PORT} 54321
${ELOSD_PORT} ${ELOSD_DEFAULT_PORT_FORWARD}
${ELOS_SERVICE_STOP_RC} -1


Expand All @@ -23,7 +23,7 @@ Connect To Elosd
[Documentation] connect to instance of elosd
Wait Till Elosd Is Listening On ${ELOSD_PORT}
${rc} Elosd Connect ${TARGET} ${ELOSD_PORT}
${rc} Elosd Connect 127.0.0.1 ${ELOSD_PORT}
Should Be Equal As Integers ${rc} 0

Disconnect From Elosd
Expand Down
3 changes: 3 additions & 0 deletions test/integration/resources/keywords.resource
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ Connect To Target And Log In
Open Connection ${TARGET} timeout=${TIMEOUT} port=${SSH_PORT}
Wait Until Keyword Succeeds ${RETRY_TIME} ${TIMEOUT}
... Login ${USERNAME} ${PASSWORD}
Create Local SSH Tunnel
... ${ELOSD_DEFAULT_PORT_FORWARD} 127.0.0.1
... ${ELOSD_DEFAULT_PORT_FORWARD} bind_address=127.0.0.1

Target IP Address Is Valid
[Documentation] Checks that TARGET_IP variable is set
Expand Down
1 change: 1 addition & 0 deletions test/integration/resources/robot_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
ELOS_STATUS_COMMAND = "service elosd status"
ELOSD_LOG = "/tmp/elosd.log"
ELOS_INSTALL_PREFIX = "/usr/local/bin"
ELOSD_DEFAULT_PORT_FORWARD = 54321

ELOS_DEFAULT_CONFIG_FILE = "/etc/elos/elosd.json"

Expand Down
82 changes: 0 additions & 82 deletions test/integration/service/config.json

This file was deleted.

2 changes: 0 additions & 2 deletions test/integration/service/elosd.conf

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ ${VALID_CLIENT_LOG} /tmp/elos_client_valid.log
... ".event.Source.appName 'hugo' LT"
... ".event.Source.appName hugo STRCMP"
... ".event.definitely.not.existing.field 'hugo' STRCMP"
@{MESSAGES} {"messageCode": 4,"payload":"testEventFiltering"}
... {"messageCode": 40,"payload":"testEventFiltering"}
... {"messageCode": 400,"payload":"testEventFiltering"}
${VALID_FILTER} ".event.messageCode 400 EQ"
@{MESSAGES} {"messageCode": 1004,"payload":"testEventFiltering"}
... {"messageCode": 1040,"payload":"testEventFiltering"}
... {"messageCode": 1400,"payload":"testEventFiltering"}
${VALID_FILTER} ".event.messageCode 1400 EQ"
@{PUBLISH_LOG} @{EMPTY}
${EVENT} testEventFiltering
${EVENT_FAILED} event subscription failed
Expand Down
8 changes: 4 additions & 4 deletions test/integration/tests/clients/elosc/find_event.robot
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Suite Teardown Close All Connections


*** Variables ***
${FILTERSTRING} ".event.messageCode 400 EQ"
@{MESSAGES} {"messageCode": 4,"payload":"testEventFiltering"}
... {"messageCode": 40,"payload":"testEventFiltering"}
... {"messageCode": 400,"payload":"testEventFiltering"}
${FILTERSTRING} ".event.messageCode 1400 EQ"
@{MESSAGES} {"messageCode": 1004,"payload":"testEventFiltering"}
... {"messageCode": 1040,"payload":"testEventFiltering"}
... {"messageCode": 1400,"payload":"testEventFiltering"}
${SEARCH_STRING} testEventFiltering
@{PUBLISH_LOG} @{EMPTY}

Expand Down
4 changes: 2 additions & 2 deletions test/integration/tests/clients/elosc/publish_and_poll.robot
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Create Message

Create Messages
[Documentation] Create multiple messages with message template
FOR ${i} IN RANGE 1 ${MESSAGE_COUNT}
FOR ${i} IN RANGE 1001 1001+${MESSAGE_COUNT}
${msg}= Create Message ${i}
Append To List ${MESSAGES} ${msg}
END
Expand Down Expand Up @@ -142,7 +142,7 @@ Generate Client Logs
${message_received}= Set Variable 0
WHILE ${message_received} == 0 limit=5 seconds
${client_output}= Execute Command cat ${log_files}
${ret}= Get Lines Containing String ${client_output} "messageCode":9
${ret}= Get Lines Containing String ${client_output} "appName":"publish_poll"
${message_received}= Get Length ${ret}
END
Append To List ${SUBSCRIBED_CLIENTS_LOG} ${client_output}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Suite Teardown Close All Connections
*** Variables ***
${ELOSD_VERSION} 1
${ELOSD_PUBLISH_CODE} 2
${ELOSD_VALID_MESSAGE} {"messageCode": 4,"payload":"testEventFiltering"}
${ELOSD_VALID_MESSAGE} {"messageCode": 1004,"payload":"testEventFiltering"}
${ELOSD_INVALID_MESSAGE} {"messageCode": 4"payload":"testEventFiltering"}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Suite Teardown Close All Connections
${ELOSD_VERSION} 1
${ELOSD_PUBLISH_CODE} 2
${ELOSD_QUERY_CODE} 4
${ELOSD_PUBLISH_MESSAGE} {"messageCode": 4,"payload":"message from tcp published"}
${ELOSD_QUERY} {"filter":".event.messageCode 4 EQ"}
${ELOSD_PUBLISH_MESSAGE} {"messageCode": 1004,"payload":"message from tcp published"}
${ELOSD_QUERY} {"filter":".event.messageCode 1004 EQ"}


*** Test Cases ***
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Test Template Check Given Find Event Filter With Error Expectation
${ELOSD_VERSION} 1
${ELOSD_PUBLISH_CODE} 2
${ELOSD_QUERY_CODE} 4
${ELOSD_PUBLISH_MESSAGE} {"messageCode": 4,"payload":"message from tcp published"}
${ELOSD_PUBLISH_MESSAGE} {"messageCode": 1004,"payload":"message from tcp published"}


*** Test Cases ***
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
*** Test Cases ***,${event_filter},${is_error_expected},[Documentation]
Check Filter Is Valid,"{""filter"":"".event.messageCode 4 EQ""}",NO,Test case to check if event filter is valid
Check Filter Is Valid,"{""filter"":"".event.messageCode 1004 EQ""}",NO,Test case to check if event filter is valid
Empty Filter Causes Error,{},YES,Test case to check if empty event filter throws an error
Invalid Filter Format Causes Error,{filter:.event.messageCode 4 EQ},YES,Invalid filter string format causes error.Filter should be json formatted
Check Filter With Multiple Conditions Is Valid,"{""filter"":"".event.messageCode 4 EQ .event.payload 'message from tcp published' STRCMP AND""}",NO,Test case to check if multiple filter strings are valid
Check Filter With Multiple Conditions Is Invalid,"{""filter"":"".event.messageCode 4 EQ & .event.payload 'message from tcp published' STRCMP""}",YES,Test case to check if multiple filter strings are invalid
Check Filter Invalid Comparison,"{""filter"":"".event.messageCode 4 STRCMP""}",YES,Test case to check if event filter format string comparison is invalid
Invalid Filter Format Causes Error,{filter:.event.messageCode 1004 EQ},YES,Invalid filter string format causes error.Filter should be json formatted
Check Filter With Multiple Conditions Is Valid,"{""filter"":"".event.messageCode 1004 EQ .event.payload 'message from tcp published' STRCMP AND""}",NO,Test case to check if multiple filter strings are valid
Check Filter With Multiple Conditions Is Invalid,"{""filter"":"".event.messageCode 1004 EQ & .event.payload 'message from tcp published' STRCMP""}",YES,Test case to check if multiple filter strings are invalid
Check Filter Invalid Comparison,"{""filter"":"".event.messageCode 1004 STRCMP""}",YES,Test case to check if event filter format string comparison is invalid

0 comments on commit ba54c5d

Please sign in to comment.