Skip to content

Commit

Permalink
Merge pull request #1 from trento-project/sapsystems
Browse files Browse the repository at this point in the history
Add to the images the ability to mock sapsystems
  • Loading branch information
dottorblaster authored Jul 2, 2024
2 parents 969adfe + b0835c5 commit e6b7b3e
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 2 deletions.
8 changes: 6 additions & 2 deletions hana_node01/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
FROM golang as agent-builder

RUN git clone https://github.com/trento-project/agent.git
ADD https://github.com/trento-project/agent.git agent
RUN cd agent && make build

FROM registry.suse.com/bci/bci-base
RUN zypper -n in catatonit
COPY --from=agent-builder /go/agent/trento-agent /usr/bin/trento-agent
COPY --from=ghcr.io/dottorblaster/soappatrol:latest /bin/soappatrol /usr/bin/soappatrol
COPY --from=ghcr.io/trento-project/fakemall:latest /bin/fakemall /usr/bin/fakemall
COPY . /

ENTRYPOINT ["/usr/bin/trento-agent", "start"]
RUN useradd -ms /bin/bash mckadm

ENTRYPOINT ["catatonit", "--", "/init.sh"]
107 changes: 107 additions & 0 deletions hana_node01/etc/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ output = """
1 hana02 clear
"""

[[commands]]
matches = "sappfpar SAPSYSTEMNAME SAPGLOBALHOST SAPFQDN SAPDBHOST dbs/hdb/dbname dbs/hdb/schema rdisp/msp/msserv rdisp/msserv_internal name=MCK"
output = """
0 hana01 clear
1 hana02 clear
"""

[[commands]]
matches = "crm_mon -X --inactive"
output = """
Expand Down Expand Up @@ -428,3 +435,103 @@ output = """
</status>
</cib>
"""

[[commands]]
matches = "python /usr/sap/MCK/MCK00/exe/python_support/systemReplicationStatus.py --sapcontrol=1"
output = """
SAPCONTROL-OK: <begin>
service/hana_node01/30001/SHIPPED_LOG_POSITION_TIME=2021-06-12 12:43:13.059197
service/hana_node01/30001/LAST_LOG_POSITION_TIME=2021-06-12 12:43:13.059197
service/hana_node01/30001/SHIPPED_FULL_REPLICA_DURATION=4060418
service/hana_node01/30001/SHIPPED_LAST_DELTA_REPLICA_START_TIME=-
service/hana_node01/30001/SHIPPED_FULL_REPLICA_SIZE=1913069568
service/hana_node01/30001/SITE_ID=1
service/hana_node01/30001/LAST_LOG_POSITION=37624000
service/hana_node01/30001/SECONDARY_ACTIVE_STATUS=YES
service/hana_node01/30001/LAST_SAVEPOINT_LOG_POSITION=37624081
service/hana_node01/30001/FULL_SYNC=DISABLED
service/hana_node01/30001/OPERATION_MODE=logreplay
service/hana_node01/30001/SHIPPED_LAST_FULL_REPLICA_START_TIME=2021-06-11 08:43:29.183940
service/hana_node01/30001/LAST_SAVEPOINT_VERSION=510
service/hana_node01/30001/LAST_SAVEPOINT_START_TIME=2021-06-12 12:45:11.401787
service/hana_node01/30001/SERVICE_NAME=nameserver
service/hana_node01/30001/PORT=30001
service/hana_node01/30001/SHIPPED_DELTA_REPLICA_COUNT=0
service/hana_node01/30001/LAST_RESET_TIME=2021-06-11 08:43:19.530050
service/hana_node01/30001/SECONDARY_FAILOVER_COUNT=0
service/hana_node01/30001/SHIPPED_FULL_REPLICA_COUNT=1
service/hana_node01/30001/SHIPPED_LOG_BUFFERS_DURATION=139833248
service/hana_node01/30001/REPLICATION_STATUS_DETAILS=
service/hana_node01/30001/SHIPPED_DELTA_REPLICA_SIZE=0
service/hana_node01/30001/SHIPPED_LOG_POSITION=37624000
service/hana_node01/30001/SHIPPED_DELTA_REPLICA_DURATION=0
service/hana_node01/30001/RESET_COUNT=0
service/hana_node01/30001/SHIPPED_LAST_DELTA_REPLICA_SIZE=0
service/hana_node01/30001/SHIPPED_LAST_DELTA_REPLICA_END_TIME=-
service/hana_node01/30001/SITE_NAME=Site1
service/hana_node01/30001/SECONDARY_SITE_NAME=Site2
service/hana_node01/30001/REPLAYED_LOG_POSITION_TIME=2021-06-12 12:43:13.059197
service/hana_node01/30001/SHIPPED_LAST_FULL_REPLICA_END_TIME=2021-06-11 08:43:33.244358
service/hana_node01/30001/CREATION_TIME=2021-06-11 08:43:19.530050
site/2/SITE_NAME=Site2
site/2/SOURCE_SITE_ID=1
site/2/REPLICATION_MODE=SYNC
site/2/REPLICATION_STATUS=ERROR
overall_replication_status=ERROR
site/1/REPLICATION_MODE=PRIMARY
site/1/SITE_NAME=Site1
local_site_id=1
SAPCONTROL-OK: <end>
"""

[[commands]]
matches = "python /usr/sap/MCK/MCK00/exe/python_support/landscapeHostConfiguration.py --sapcontrol=1"
output = """
SAPCONTROL-OK: <begin>
hostActualRoles=worker
removeStatus=
nameServerConfigRole=master 1
failoverStatus=
hostConfigRoles=worker
failoverActualGroup=default
storageConfigPartition=1
host=hana_node01
indexServerConfigRole=worker
failoverConfigGroup=default
storageActualPartition=1
indexServerActualRole=master
nameServerActualRole=master
hostActive=yes
workerActualGroups=default
workerConfigGroups=default
hostStatus=ok
storagePartition=1
SAPCONTROL-OK: <end>
"""

[[commands]]
matches = "/usr/sap/MCK/MCK00/exe/hdbnsutil -sr_state -sapcontrol=1"
output = """
SAPCONTROL-OK: <begin>
online=true
mode=primary
operation mode=primary
site id=1
site name=Site1
isSource=true
isConsumer=false
hasConsumers=true
isTakeoverActive=false
isPrimarySuspended=false
mapping/hana_node01=Site2/hana02
mapping/hana_node01=Site1/hana_node01
siteTier/Site1=1
siteTier/Site2=2
siteReplicationMode/Site1=primary
siteReplicationMode/Site2=sync
siteOperationMode/Site1=primary
siteOperationMode/Site2=logreplay
siteMapping/Site1=Site2
SAPCONTROL-OK: <end>
done.
"""
67 changes: 67 additions & 0 deletions hana_node01/etc/soappatrol.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
[[request]]
action = "''"
tagname = "GetInstanceProperties"
response = """
<GetInstancePropertiesResponse xmlns="urn:SAPControl">
<properties>
<item>
<property>INSTANCE_NAME</property>
<propertytype>string</propertytype>
<value>MCK00</value>
</item>
<item>
<property>SAPLOCALHOST</property>
<propertytype>string</propertytype>
<value>hana_node01</value>
</item>
<item>
<property>SAPSYSTEM</property>
<propertytype>string</propertytype>
<value>00</value>
</item>
<item>
<property>SAPSYSTEMNAME</property>
<propertytype>string</propertytype>
<value>MCK</value>
</item>
</properties>
</GetInstancePropertiesResponse>
"""

[[request]]
action = "''"
tagname = "GetProcessList"
response = """
<GetProcessListResponse xmlns="urn:SAPControl">
<process>
<item>
<name>MockProcess</name>
<description>Mock process</description>
<dispstatus>SAPControl-GREEN</dispstatus>
<textstatus>ok</textstatus>
<starttime>12:00</starttime>
<endtime>12:01</endtime>
<pid>123</pid>
</item>
</process>
</GetProcessListResponse>
"""

[[request]]
action = "''"
tagname = "GetSystemInstanceList"
response = """
<GetSystemInstanceListResponse xmlns="urn:SAPControl">
<instance>
<item>
<hostname>hana_node01</hostname>
<instanceNr>00</instanceNr>
<httpPort>80</httpPort>
<httpsPort>443</httpsPort>
<startPriority>high</startPriority>
<features>HDB</features>
<dispstatus>SAPControl-GREEN</dispstatus>
</item>
</instance>
</GetSystemInstanceListResponse>
"""
15 changes: 15 additions & 0 deletions hana_node01/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -m

# Start the first process
/usr/bin/soappatrol /tmp/.sapstream50013 /etc/soappatrol.toml &

# Start the second process
/usr/bin/trento-agent start &

# Wait for any process to exit
wait -n

# Exit with status of process that exited first
exit $?
2 changes: 2 additions & 0 deletions hana_node01/usr/bin/python
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
fakemall exec /etc/config.toml "python $*"
2 changes: 2 additions & 0 deletions hana_node01/usr/bin/sappfpar
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
fakemall exec /etc/config.toml "sappfpar $*"
2 changes: 2 additions & 0 deletions hana_node01/usr/sap/MCK/MCK00/exe/hdbnsutil
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
fakemall exec /etc/config.toml "/usr/sap/MCK/MCK00/exe/hdbnsutil $*"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
id = systemId
4 changes: 4 additions & 0 deletions hana_node01/usr/sap/MCK/SYS/global/hdb/mdc/databases.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# DATABASE:CONTAINER:USER:GROUP:USERID:GROUPID:HOST:SQLPORT:ACTIVE
PRD::::::hana_node01:30015:yes

MCK::::::hana_node01:30044:yes

0 comments on commit e6b7b3e

Please sign in to comment.