osmith has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/41422?usp=email )

 (

2 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted 
one.
 )Change subject: hss: add initial testenv_pyhss.cfg
......................................................................

hss: add initial testenv_pyhss.cfg

Related: OS#6862
Change-Id: I224eb4aa5fec3dc97f6fa956a4a86f206c8b12b7
---
M _testenv/data/podman/Dockerfile
M hss/HSS_Tests.ttcn
A hss/pyhss/HSS_Tests.cfg
A hss/pyhss/config.yaml
A hss/pyhss/redis.conf
A hss/pyhss/run_in_venv.sh
A hss/pyhss/setup_db.sh
R hss/testenv_open5gs.cfg
A hss/testenv_pyhss.cfg
9 files changed, 299 insertions(+), 7 deletions(-)

Approvals:
  fixeria: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified




diff --git a/_testenv/data/podman/Dockerfile b/_testenv/data/podman/Dockerfile
index 9044f1f..a755b05 100644
--- a/_testenv/data/podman/Dockerfile
+++ b/_testenv/data/podman/Dockerfile
@@ -83,6 +83,7 @@
                python3-requests \
                python3-venv \
                qemu-system-x86 \
+               redis \
                rsync \
                source-highlight \
                sqlite3 \
diff --git a/hss/HSS_Tests.ttcn b/hss/HSS_Tests.ttcn
index 1838619..1ebb673 100644
--- a/hss/HSS_Tests.ttcn
+++ b/hss/HSS_Tests.ttcn
@@ -12,6 +12,11 @@

 import from Prometheus_Checker all;

+type enumerated HSS_Impl {
+       HSS_IMPL_OPEN5GS,
+       HSS_IMPL_PYHSS
+};
+
 type record of hexstring SubscriberConfigs;

 modulepar {
@@ -30,6 +35,8 @@
                '001010000000000'H,
                '001010000000001'H
        };
+
+       HSS_Impl mp_hss_impl := HSS_IMPL_OPEN5GS;
 }

 /* main component, we typically have one per testcase */
@@ -222,11 +229,18 @@

 /* create a session, expect it to succeed */
 private function f_TC_ulr_ula() runs on Cli_Session_CT {
-       var PrometheusExpects expects := valueof({
-               ts_PrometheusExpect("s6a_rx_ulr", COUNTER, min := 1, max := 1),
-               ts_PrometheusExpect("s6a_tx_ula", COUNTER, min := 1, max := 1)
-       });
-       var PrometheusMetrics prom_snapshot := 
f_prometheus_snapshot(f_prometheus_keys_from_expect(expects));
+       var PrometheusExpects expects;
+       var PrometheusMetrics prom_snapshot;
+
+       /* pyhss_metric doesn't have these keys and its prometheus output can
+        * currently not be parsed by osmo-ttcn3-hacks */
+       if (mp_hss_impl == HSS_IMPL_OPEN5GS) {
+               expects := valueof({
+                       ts_PrometheusExpect("s6a_rx_ulr", COUNTER, min := 1, 
max := 1),
+                       ts_PrometheusExpect("s6a_tx_ula", COUNTER, min := 1, 
max := 1)
+               });
+               prom_snapshot := 
f_prometheus_snapshot(f_prometheus_keys_from_expect(expects));
+       }

        var template (present) AVP_list sub_data := superset(
                tr_AVP_3GPP_SubscriberStatus(SERVICE_GRANTED),
@@ -240,7 +254,9 @@
        );
        f_dia_ulr_ula(sub_data);

-       f_prometheus_expect_from_snapshot(expects, wait_converge := true, 
snapshot := prom_snapshot);
+       if (mp_hss_impl == HSS_IMPL_OPEN5GS) {
+               f_prometheus_expect_from_snapshot(expects, wait_converge := 
true, snapshot := prom_snapshot);
+       }
        setverdict(pass);
 }
 testcase TC_ulr_ula() runs on MTC_CT {
@@ -288,7 +304,14 @@

 control {
        execute( TC_ulr_ula() );
-       execute( TC_ulr_ula_subscr_op_det_barring_7() );
+
+       if (mp_hss_impl == HSS_IMPL_OPEN5GS) {
+               /* Disabled for PyHSS: currently unclear how a subscriber would
+                * be set to barred in the PyHSS database / if this is possible
+                * at all. See also hss/create_test_subscribers.sh and
+                * pyhss/setup_db.sh. */
+               execute( TC_ulr_ula_subscr_op_det_barring_7() );
+       }
 }


diff --git a/hss/pyhss/HSS_Tests.cfg b/hss/pyhss/HSS_Tests.cfg
new file mode 100644
index 0000000..c25df56
--- /dev/null
+++ b/hss/pyhss/HSS_Tests.cfg
@@ -0,0 +1,25 @@
+[ORDERED_INCLUDE]
+# Common configuration, shared between test suites
+"../Common.cfg"
+# testsuite specific configuration, not expected to change
+"./HSS_Tests.default"
+
+# Local configuration below
+
+[LOGGING]
+
+[TESTPORT_PARAMETERS]
+
+[MODULE_PARAMETERS]
+mp_hss_impl := HSS_IMPL_PYHSS
+mp_hss_hostname := "127.0.0.201"
+mp_hss_port := 3868
+mp_hss_prometheus_hostname := "127.0.0.1"
+mp_hss_prometheus_port := 9191
+mp_diam_local_hostname := "127.0.0.202"
+mp_diam_local_port := 3868
+
+[MAIN_CONTROLLER]
+
+[EXECUTE]
+HSS_Tests.control
diff --git a/hss/pyhss/config.yaml b/hss/pyhss/config.yaml
new file mode 100644
index 0000000..3114820
--- /dev/null
+++ b/hss/pyhss/config.yaml
@@ -0,0 +1,177 @@
+hss:
+  transport: "SCTP"
+  bind_ip: ["127.0.0.201"]
+  bind_port: 3868
+  OriginHost: "hss01"
+  OriginRealm: "epc.mnc001.mcc001.3gppnetwork.org"
+  ProductName: "pyHSS"
+  site_name: "TTCN3"
+  MCC: "001"
+  MNC: "01"
+  SLh_enabled: False
+  #IMSI of Test Subscriber for Unit Checks (Optional)
+  test_sub_imsi: '001021234567890'
+
+  #The maximum time to wait, in seconds, before disconnecting a client when no 
data is received.
+  client_socket_timeout: 120
+
+  #The maximum time to wait, in seconds, before disconnecting a client when no 
data is received.
+  client_socket_timeout: 300
+
+  #The maximum time to wait, in seconds, before discarding a diameter request.
+  diameter_request_timeout: 3
+
+  # Whether to send a DWR to connected peers.
+  send_dwr: False
+
+  # How often to send a DWR to connected peers if enabled, in seconds.
+  send_dwr_interval: 5
+
+  #The amount of time, in seconds, before purging a disconnected client from 
the Active Diameter Peers key in redis.
+  active_diameter_peers_timeout: 10
+
+  #Prevent updates from being performed without a valid 'Provisioning-Key' in 
the header
+  lock_provisioning: False
+
+  #Provisioning Key for this HSS, alias for an API key. Required to be present 
in the header of requests to this HSS' api, if lock_provisioning is True.
+  provisioning_key: "changeThisKeyInProduction"
+
+  #If enabled sends CLRs to old MME when new MME attaches active sub
+  CancelLocationRequest_Enabled: False
+
+  #Workaround for some MMEs to force an Insert Subscriber Data request to be 
sent immediately after ULA
+  Insert_Subscriber_Data_Force: False
+
+  #Default Initial Filter Criteria for IMS Subscribers
+  #Jinja Formatted Template, see the example for variables passed to it.
+  Default_iFC: 'default_ifc.xml'
+
+  #Default Sh User Data
+  Default_Sh_UserData: 'default_sh_user_data.xml'
+
+  #Whether to use an external socket service
+  use_external_socket_service: False
+
+  #The Redis key used to store active diameter peers
+  diameter_peer_key: diameterPeers
+
+  # Send requests via a DRA (if connected) when a given peer can't be found
+  use_dra_fallback: False
+
+  # How long an emergency subscriber entry will last for in the table before 
expiring, in minutes.
+  emergency_subscriber_expiry: 3600
+
+  # Whether to send a Delete Subscriber Data Request to the Old MME on an 
Update Location Request.
+  send_dsr_on_mme_change: False
+
+  # Static Identifier for the subscriber context with the Delete Subscriber 
Data Request.
+  dsr_external_identifier: "example"
+
+  # Whether to ignore Purge UE Requests - leaving the subscriber state with 
the last served mme instead of null.
+  ignore_purge_ue_request: False
+
+  #S-CSCF Pool
+  scscf_pool:
+    - 'scscf.ims.mnc001.mcc001.3gppnetwork.org'
+
+  roaming:
+    outbound:
+      # Whether or not to a subscriber to connect to an undefined network when 
outbound roaming.
+      allow_undefined_networks: True
+
+  # SCTP Socket Parameters
+  sctp:
+    rtoMax: 5000
+    rtoMin: 500
+    rtoInitial: 1000
+
+  gsup:
+    bind_ip: "127.0.0.1"
+    bind_port: 4222
+
+api:
+  page_size: 200
+  # Whether or not to return key-based data when querying the AUC. Disable in 
production systems.
+  enable_insecure_auc: False
+
+benchmarking:
+  # Whether to enable benchmark logging
+  enabled: True
+  # How often to report, in seconds. Not all benchmarking supports interval 
reporting.
+  reporting_interval: 3600
+
+eir:
+  imsi_imei_logging: True    #Store current IMEI / IMSI pair in backend
+  no_match_response: 2       #Greylist
+  store_offnet_imsi: False  # Whether or not to store an IMEI / IMSI pair that 
doesn't exist in the AUC
+  simSwapNotification: False # If the IMEI for a stored IMSI/IMEI combo 
changes, notify the webhook endpoint
+  # Define an optional TAC csv file path
+  #tac_database_csv: '/etc/pyhss/tac_database.csv'
+
+logging:
+  level: DEBUG
+  logfiles:
+    hss_logging_file: /dev/stdout
+  sqlalchemy_sql_echo: False
+  sqlalchemy_pool_recycle: 15
+  sqlalchemy_pool_size: 30
+  sqlalchemy_max_overflow: 0
+
+## Database Parameters
+database:
+  db_type: sqlite
+  server: 127.0.0.1
+  username: dbeaver
+  password: password
+  database: pyhss.db
+  readCacheEnabled: True
+  readCacheInterval: 60
+
+## External Webhook Notifications
+webhooks:
+  enabled: False
+  endpoints:
+    - 'http://127.0.0.1:8181'
+
+### Notifications to OCS on Credit Control Requests
+ocs:
+  enabled: False
+  endpoints:
+    - 'http://127.0.0.1:8282'
+
+## Geographic Redundancy Parameters
+geored:
+  enabled: False
+  sync_actions: ['HSS', 'IMS', 'PCRF', 'EIR']    #What event actions should be 
synced
+  endpoints:                         #List of PyHSS API Endpoints to update
+    - 'http://hss01.mnc001.mcc001.3gppnetwork.org:8080'
+    - 'http://hss02.mnc001.mcc001.3gppnetwork.org:8080'
+
+#Redis is required to run PyHSS. An instance running on a local network is 
recommended for production.
+redis:
+  # Which connection type to attempt. Valid options are: tcp, unix, sentinel
+  # tcp - Connection via a standard TCP socket to a given host and port.
+  # unix - Connect to redis via a unix socket, provided by unixSocketPath.
+  # sentinel - Connect to one or more redis sentinel hosts.
+  connectionType: "tcp"
+  unixSocketPath: '/var/run/redis/redis-server.sock'
+  host: localhost
+  port: 6379
+  sentinel:
+    masterName: exampleMaster
+    hosts:
+      - exampleSentinel.mnc001.mcc001.3gppnetwork.org:
+        port: 6379
+        password: ''
+
+influxdb:
+  enabled: False
+  host: "127.0.0.1"
+  port: 8086
+  username: exampleUser
+  password: examplePassword
+  database: example
+
+snmp:
+  port: 1161
+  listen_address: 127.0.0.1
diff --git a/hss/pyhss/redis.conf b/hss/pyhss/redis.conf
new file mode 100644
index 0000000..85ee91d
--- /dev/null
+++ b/hss/pyhss/redis.conf
@@ -0,0 +1,2 @@
+bind 127.0.0.1
+protected-mode yes
diff --git a/hss/pyhss/run_in_venv.sh b/hss/pyhss/run_in_venv.sh
new file mode 100755
index 0000000..a145a7d
--- /dev/null
+++ b/hss/pyhss/run_in_venv.sh
@@ -0,0 +1,12 @@
+#!/bin/sh -e
+export PYHSS_CONFIG=config.yaml
+
+if [ "$TESTENV_INSTALL_DIR" = "/" ]; then
+       # Installed via debian package
+       . /opt/venvs/pyhss/bin/activate
+else
+       # Built with osmo-dev
+       . "$TESTENV_INSTALL_DIR"/venv/bin/activate
+fi
+
+"$@"
diff --git a/hss/pyhss/setup_db.sh b/hss/pyhss/setup_db.sh
new file mode 100755
index 0000000..aa31d76
--- /dev/null
+++ b/hss/pyhss/setup_db.sh
@@ -0,0 +1,15 @@
+#!/bin/sh -ex
+wait_for_port.py -p 8080
+
+pyhss_api_helper.py \
+       add_default_apn
+
+# Create a test subscriber with IMSI=001010000000000
+pyhss_api_helper.py \
+       add_subscr \
+       --imsi 001010000000000 \
+       --msisdn 100 \
+       --auc-id 1 \
+       --algo 0 \
+       --ki 3c6e0b8a9c15224a8228b9a98ca1531d \
+       --opc 762a2206fe0b4151ace403c86a11e479
diff --git a/hss/testenv.cfg b/hss/testenv_open5gs.cfg
similarity index 100%
rename from hss/testenv.cfg
rename to hss/testenv_open5gs.cfg
diff --git a/hss/testenv_pyhss.cfg b/hss/testenv_pyhss.cfg
new file mode 100644
index 0000000..d0ef90c
--- /dev/null
+++ b/hss/testenv_pyhss.cfg
@@ -0,0 +1,37 @@
+[testsuite]
+titan_min=11.1.0
+program=HSS_Tests
+config=HSS_Tests.cfg
+copy=pyhss/HSS_Tests.cfg
+
+[redis]
+program=redis-server ./redis.conf
+make=no
+package=no
+copy=pyhss/redis.conf
+
+[pyhss_hss]
+program=./run_in_venv.sh pyhss_hss
+make=pyhss
+package=pyhss
+copy=pyhss/config.yaml pyhss/run_in_venv.sh
+
+[pyhss_diameter]
+program=cd ../pyhss_hss && ./run_in_venv.sh pyhss_diameter
+setup=./run_in_venv.sh wait_for_port.py -p 3868 -H 127.0.0.201 -P sctp
+make=pyhss
+package=pyhss
+copy=pyhss/run_in_venv.sh
+
+[pyhss_api]
+program=cd ../pyhss_hss && ./run_in_venv.sh pyhss_api
+setup=./setup_db.sh
+make=pyhss
+package=pyhss
+copy=pyhss/setup_db.sh
+
+[pyhss_metric]
+program=cd ../pyhss_hss && ./run_in_venv.sh pyhss_metric
+setup=wait_for_port.py -p 9191
+make=pyhss
+package=pyhss

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/41422?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I224eb4aa5fec3dc97f6fa956a4a86f206c8b12b7
Gerrit-Change-Number: 41422
Gerrit-PatchSet: 4
Gerrit-Owner: osmith <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>

Reply via email to