Skip to Content
Technical Articles
Author's profile photo Jamie Cawley

SAP Cloud Platform, Kyma runtime: Mock Applications

This blog will take a look at how to setup a mock application that can be used for developing and evaluating scenarios within the Kyma runtime.  If you do not already have a Kyma runtime provisioned see this blog.

The mocking applications can be found at

https://github.com/SAP-samples/xf-application-mocks

Within the repo you will find each of the mock applications and their deployment files within the respective folder.  The process outlined in the blog will be the same for each, but will focus on configuring the commerce mock.

Applying the Commerce Mocks Resources

Within the Kyma runtime, start by creating a new namespace named mocks by choosing Add new namespace, providing the Name mocks and choosing Create.

If using kubectl you can apply the deployments after setting your kubeconfig, available under Settings -> General Settings, by running the commands in the CLI

export KUBECONFIG=<path to dowloaded file>

kubectl apply -n mocks -f https://raw.githubusercontent.com/SAP-samples/xf-application-mocks/master/commerce-mock/deployment/k8s.yaml

kubectl apply -n mocks -f https://raw.githubusercontent.com/SAP-samples/xf-application-mocks/master/commerce-mock/deployment/kyma.yaml

otherwise download the two yaml files found in the folder /commerce-mock/deployment of the xf-application-mocks project either directly or by cloning the project.  Open the mocks namespace and choose the option Deploy new resource and apply the k8s.yaml and then the kyma.yaml.

Opening the Commerce Mock Application

The deployment of the mock application will take a few minutes to complete.  With this in mind, in the mocks namespace choose Configuration -> API Rules

Choose the commerce-mock api rule to open it and then choose the link for the Host value to open the mock application.  If an error is returned, wait a minute and try again.

Creating/Connecting a system

To pair the mock application with the Kyma runtime, open your global SAP Cloud Platform account and choose the menu option System Landscape -> Systems

Click on the button Register System, provide the name commerce-mock, set the type to SAP Commerce Cloud and choose the Register option.

Copy the Token value and close the window.

 

Navigate back to the mock application and click on the Connect button.  Paste the copied value in the token text area and then choose Connect

Next choose the Register All button to register the APIs and Events from the mock application.

Creating the Formation

Within your global SAP Cloud Platform account, choose the menu option System Landscape -> Formations. Click on the button Create Formation

Provide a Name, choose your Subaccount where the Kyma runtime is enabled, choose the commerce-mock system and finally choose Create.

 

Verifying the Setup

In the Kyma home workspace choose Integration -> Applications.  Within the list you should for the the mp-commerce-mock application.  After choosing the system you should now see a listing of the APIs and Events the mock is exposing.

Check out this blog to learn how to trigger a function with an event and call an API.

Assigned tags

      10 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Benny Schaich-Lebek
      Benny Schaich-Lebek

      I drop the K8s.yaml file and get a "Invalid file extension" message. Also when changing it to .yml.

      I guess it is the fancy drop widget instead of a plain file input.

       

      regards,

      Benny

      Author's profile photo Marco Dorn
      Marco Dorn

      Hello Benny Schaich-Lebek,

      Which browser are you using? I just tried it in my Kyma Runtime and it worked out fine with *.yaml.

      Did you go via CLI or did you clone the repository?

      Best regards,
      Marco.

      Author's profile photo Benny Schaich-Lebek
      Benny Schaich-Lebek

      I tried both, Firefox and chrome. Result:

       

       

      Regards,

      Benny

      Author's profile photo Marco Dorn
      Marco Dorn

      Hello Benny Schaich-Lebek,

      I could reproduce it on Windows. As this seems to be an issue with the console UI of Kyma Open Source, I reported it in the open source project https://github.com/kyma-project/console/issues/2023.

      Best regards,
      Marco

      Author's profile photo Benny Schaich-Lebek
      Benny Schaich-Lebek

      I never would have expected there is a difference in web frontends between Macs and Windows...-between browsers, yes. But OS!
      In that case I forgive the developers who did this as I already was pissed for such a stupid thing 😉

       

      regards,

      Benny

      Author's profile photo Kai Holert
      Kai Holert

      I had the same issue, renamed the files to .JSON and it worked...

      Chrome / Win10

      Author's profile photo Benny Schaich-Lebek
      Benny Schaich-Lebek

      So it accepted the JSON extension but was reading it in as YAML? Strange....

      Author's profile photo Kai Holert
      Kai Holert

      Yupp, worked like that...

      Author's profile photo Benny Schaich-Lebek
      Benny Schaich-Lebek

      First this:

      OK, now I tried kubectl. I downloaded the config file and added it int o my (windows) system with KUBECONFIG in a path. It seems kubectl is using it as I tried the path first and that did not work. But now I get this:

      kubectl apply -n mocks -f https://raw.githubusercontent.com/SAP-samples/xf-application-mocks/master/commerce-mock/deployment/k8s.yaml

      unable to recognize "https://raw.githubusercontent.com/SAP-samples/xf-application-mocks/master/commerce-mock/deployment/k8s.yaml": the server has asked for the client to provide credentials

      This answer was printed three times.

      Long story short: After logging in again AND downloading the ticket again it finally worked! Keep in mind the the kubeconfig.yml obviously changes ticket for every login (and as I continued next day this happened).

      Author's profile photo Marco Dorn
      Marco Dorn

      That is correct. The time to live of the generated kubeconfig file is 8 hours.