in varietate concordia (meaning: united in diversity) - Ernesto Teodoro Moneta (Nobel Peace Prize Laureate)
Happy holidays dear friends. While last year was challenging for every one of us, one positive thing we see is that it reinforces the fact that unity is our strength. And that if we stay united, we can overcome any challenge, not matter how big or tiny it is.
Introduction:
A dollar can get you 10 GB of blob storage per month on azure. Just in case if you are not following earlier blogs in this series, I strongly encourage you to go through
Part 1 and
Part 2 to get the context of what we are trying to build. In this blog, we will start loading our test cases. For structural data we use SAP BTP HANA cloud and for saving our test payloads, we use azure blob storage. As with other blogs, we will discuss the step by step implementation steps. The code repository is
https://github.com/ravipativenu/integration-suite-extention . So let us get started.
Previous parts:
If you did not check the previous parts, i suggest to go through them to understand the story. Below are the links for them
Previous blogs |
Link |
Part3 – Integration suite extension – Payload storage in Azure blob storage |
Part3 |
Part2 – Integration suite extension – Persistence in HANA cloud |
Part2 |
Part1 – Integration suite extension – Introduction |
Part1 |
Part0.1 – Integration suite extension – Message Monitor Overview |
Part0.1 |
Part0.2 – Integration suite extension – Enhanced user defined message search |
Part0.2 |
Architecture Diagram:
STEP1: Create test case table
Create TESTCASES table on SAP HANA cloud for saving our test cases.
CREATE TABLE "INTEGRATION_SUITE"."TESTCASES" ("ID" bigint NOT NULL primary key GENERATED BY DEFAULT AS IDENTITY, Name NVARCHAR(100), Testcase NVARCHAR(100), Description NVARCHAR(100), Method NVARCHAR(10), Input NVARCHAR(200));
STEP2: Create a storage container in azure blob storage
The good thing about azure trial subscription is you do not need to spend the dollar on blob storage :). It is free. Create a storage container named “testcases” in azure blob storage as below.
STEP3: Implement api to upload test cases to backend
Implement api
/api/testing/testcases. A POST on this api uploads a test case to backend.
Create a struct for uploading the test case data
Method CreateTestCase creates test case in backend and uploads the payload data into azure blob storage.
Creating testcase in backend
Uploading test case payload to azure blob storage.
STEP4: Testing the api:
We can test api locally or by deploying to SAP BTP Kyma runtime. SAP BTP Kyma deployment steps are provided later in the blog.
Local Deployment API URL:
POST http://localhost:9090/api/testing/testcases
Kyma Deployment API URL:
POST https://integration-suite-extention.c-4b20a39.kyma.shoot.live.k8s-hana.ondemand.com/
Payload:
"Filedata" element in payload is the base64 encoded format of the payload.
{
"Name" : "Scenario1_SOAP_To_Northwind_OData_Service",
"Testcase" : "TestCase1",
"Description" : "TestCase1 Description",
"Filedata" : "PHNvYXBlbnY6RW52ZWxvcGUgeG1sbnM6c29hcGVudj0iaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvc29hcC9lbnZlbG9wZS8iIHhtbG5zOmN4Zj0iaHR0cDovL2N4Zi5jb21wb25lbnQuY2FtZWwuYXBhY2hlLm9yZy8iPgogICA8c29hcGVudjpIZWFkZXIvPgogICA8c29hcGVudjpCb2R5PgogICAgICA8Y3hmOmludm9rZT4KICAgICAgICAgICAgICA8b3JkZXJOdW1iZXI+MTAyNDg8L29yZGVyTnVtYmVyPgogICAgICA8L2N4ZjppbnZva2U+CiAgIDwvc29hcGVudjpCb2R5Pgo8L3NvYXBlbnY6RW52ZWxvcGU+Cg==",
"Filesize" : 5,
"Filename" : "Test_Case1_Payload.txt",
"Filetype" : "txt",
"Method" : "POST"
}
Test api using postman
Result:
Test case is created in the backend. Input field will have the link to the payload stored in azure blob storage
Actual payload is stored in azure blob storage
Payload data
STEP5: Implement api to get test cases from backend
The api will provide the test cases from backend. GetTestCases method implement this api.
STEP6: Testing the api
Test the api using postman
Local Deployment API URL:
GET http://localhost:9090/api/testing/testcases
Kyma Deployment API URL:
GET https://integration-suite-extention.c-4b20a39.kyma.shoot.live.k8s-hana.ondemand.com/api/testing/test...
STEP7: Implement api to get test case payload
Implement api to get test case payload from Azure blob storage. The api will get the payload data from azure blob storage, encode the payload with base64 encoding and send in response. Below methods implement this api
STEP8: Testing the api
Test the api to get the payload of a test case. Using the Input URL we saved while loading the test case (below), retrieve the payload information. Pass the input url path as "id" parameter to the api
Local:
GET http://localhost:9090/api/testing/payload?id=/Scenario1_SOAP_To_Northwind_OData_Service/TestCase1/Te...
Kyma Deployment API URL:
GET https://integration-suite-extention.c-4b20a39.kyma.shoot.live.k8s-hana.ondemand.com/api/testing/payl...
Result:
The api outputs a json with "data" element containing the base64 encoded payload data. We send base64 encoding of the payload data in api as in the next blog, the plan is to build an SAPUI5 app for maintaining our test cases. So the idea is SAPUI5 app will get the payload information from the api, decode it to display to the user.
STEP9: Deployment to Kyma – Kubernetes
Do docker build
docker build -t ravipativenu/integration-suite-extention:latest -f Dockerfile .
Do docker push
docker push ravipativenu/integration-suite-extention:latest
Deploy Kubernetes secret for accessing Azure blob storage
kubectl create secret generic azureblob --from-literal=AZUREBLOB_SECRET_ACCOUNTNAME='venublobstorage' --from-literal=AZUREBLOB_SECRET_MYACCOUNTKEY='key' --from-literal=AZUREBLOB_SECRET_MYACCOUNTURL='https://venublobstorage.blob.core.windows.net/'
azureblob secret created
Configure environment variables in deployment descriptor for azure blob storage access
Deploy to Kyma Kubernetes
kubectl replace --force -f deployment.yaml -n default
Summary:
In this blog, we built apis to load test cases to our extension application. We also built apis to retrieve testcases from backend. We use SAP HANA cloud to store out test cases and we use azure blob storage for storing our payload data. We deployed the application version to SAP BTP kyma runtime and finally tested all our apis. The repo is
https://github.com/ravipativenu/integration-suite-extention . In next blog we will build an SAPUI5 app to manage our test cases. we will use the apis we built here to fuel the SAPUI5 app. If you are interested, stay tuned for the next blog. Please feel free to provide your comments and feedback.
Wish you all a very happy and prosperous new Year...
🙂