Add Intial Smoke Tests 74/15274/4 master
authorashishj1729 <jain.ashish@samsung.com>
Sun, 16 Nov 2025 18:48:49 +0000 (00:18 +0530)
committerAshish Jain <jain.ashish@samsung.com>
Fri, 21 Nov 2025 06:10:00 +0000 (06:10 +0000)
The following tasks are done:
1. Adding Intial Smoke Test to register a data-extraction job and
   retrieve job-status.
2. Updating Github-Workflow to run smoke-tests.

Issue-Id: AIMLFW-314

Change-Id: I10713cd616e7c95dc900bcfe08381c853b572b20
Signed-off-by: ashishj1729 <jain.ashish@samsung.com>
.github/workflows/gerrit-verify.yaml
.gitignore [new file with mode: 0644]
component-testing/local-testing/run_test.sh [new file with mode: 0644]
component-testing/tests/requirements.txt [new file with mode: 0644]
component-testing/tests/test_component.py [new file with mode: 0644]
tox.ini

index ea40b97..f3f9d44 100644 (file)
@@ -172,6 +172,24 @@ jobs:
 
       - name: list data-extraction pod
         run: kubectl get pods -n traininghost
+
+      - name: run regression test
+        run: |
+          cd $GITHUB_WORKSPACE
+          pip install -r component-testing/tests/requirements.txt
+
+          kubectl port-forward svc/data-extraction -n traininghost  32001:32000 & PF_PID=$!
+          sleep 1
+          python3 -m pytest component-testing/tests --maxfail=1 --disable-warnings -q --html=pytest_report.html
+
+          # Stop port-forwarding
+          kill $PF_PID
+      
+      - name: Upload Test Report
+        uses: actions/upload-artifact@v4
+        with:
+          name: pytest-report
+          path: pytest_report.html
     
 
   vote:
diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..9145383
--- /dev/null
@@ -0,0 +1,3 @@
+__pycache__/
+pytest_report.html
+assets
\ No newline at end of file
diff --git a/component-testing/local-testing/run_test.sh b/component-testing/local-testing/run_test.sh
new file mode 100644 (file)
index 0000000..28b7dee
--- /dev/null
@@ -0,0 +1,26 @@
+# ==================================================================================
+#
+#       Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved.
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#          http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+# ==================================================================================
+
+
+# Since, Kind cluster runs in a docker container, therefore it is required to port-forward the svc to connect
+kubectl port-forward svc/data-extraction -n traininghost  32001:32000 & PF_PID=$!
+sleep 1
+python3 -m pytest ../tests/ --maxfail=1 --disable-warnings -q --html=pytest_report.html
+
+# Stop port-forwarding
+kill $PF_PID
\ No newline at end of file
diff --git a/component-testing/tests/requirements.txt b/component-testing/tests/requirements.txt
new file mode 100644 (file)
index 0000000..f107333
--- /dev/null
@@ -0,0 +1,20 @@
+# ==================================================================================
+#
+#       Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved.
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#          http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+# ==================================================================================
+requests
+pytest
+pytest-html
\ No newline at end of file
diff --git a/component-testing/tests/test_component.py b/component-testing/tests/test_component.py
new file mode 100644 (file)
index 0000000..de01959
--- /dev/null
@@ -0,0 +1,63 @@
+import requests
+import pytest
+
+BASE_URL = "http://localhost:32001"
+
+def get_base_job_payload():
+    return {
+        "source": {
+            "InfluxSource": {
+            "query": "from(bucket:\"UEData\") |> range(start: 0, stop: now()) |> filter(fn: (r) => r._measurement == \"liveCell\") |> pivot(rowKey:[\"_time\"], columnKey: [\"_field\"], valueColumn: \"_value\")"
+            }
+        },
+        "transform": [
+            {
+            "operation": "SQLTransform",
+            "FeatureList": "pdcpBytesDl,pdcpBytesUl",
+            "SQLFilter": "nrCellIdentity = '\''c1/B13'\''"
+            }
+        ],
+        "sink": {
+            "CassandraSink": {
+                "CollectionName": "base1_52"
+            }
+        },
+        "trainingjob_id": "52",
+        "influxdb_info": {
+            "host": "mock-influxdb.traininghost",
+            "port": "8080",
+            "bucket": "UEData",
+            "token": "xxx",
+            "db_org": "primary",
+            "source_name": ""
+        }
+    }
+    
+def submit_data_extraction_job(trainingjob_id):
+    '''
+        Helper function to submit data-extraction joband returns the task_id
+    '''
+    url = f"{BASE_URL}/feature-groups"
+    payload = get_base_job_payload()
+    payload["sink"]["CassandraSink"]["CollectionName"] = f"base1_{trainingjob_id}"
+    payload["trainingjob_id"] = trainingjob_id
+    r = requests.post(url=url, json=payload)
+    assert r.status_code == 200, f"Job Submission didn't returned 200 but returned {r.status_code}"
+    task_id = r.json().get("featurepath")
+    return task_id
+
+
+def test_data_extraction_job_submission_and_status_retrieval():
+    '''
+        The following test verifies that a data-extraction job can be successfully submitted and that its task status is retrievable via the corresponding API.
+    '''
+    # Submit the Data-extraction job
+    trainingjob_id = "100" 
+    task_id = submit_data_extraction_job(trainingjob_id)
+    
+    # Check job Status
+    task_status_url = f"{BASE_URL}/task-status/{task_id}"
+    r = requests.get(url=task_status_url)
+    response_dict = r.json()
+    assert r.status_code == 200, f"Task Retrieval didn't returned 200, but returned {r.status_code}"
+    assert response_dict.get("trainingjob_id") == trainingjob_id, "Trainingjob_id submitted and retrieved doesn't match"
\ No newline at end of file
diff --git a/tox.ini b/tox.ini
index 1a191e5..bce04fa 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -47,7 +47,7 @@ setenv = cd = {toxinidir}/tests
 commands =  
   #pip3 install -e {toxinidir} 
 
-  pytest --cov-report term-missing --cov-report xml --cov-report html --cov-fail-under=30 --junitxml=/tmp/tests.xml --cov={toxinidir}/dataextraction/
+  pytest --cov-report term-missing --cov-report xml --cov-report html --cov-fail-under=30 --junitxml=/tmp/tests.xml --cov={toxinidir}/dataextraction/ --ignore={toxinidir}/component-testing
   coverage xml -i
 
 # Docs