Assessment - Alpha Solutions

Sitecore Commerce powered by Dynamics AX – Continuous testing on transaction service using postman.

26.10.18

BY ROLAND VILLEMOES

Working with Microsoft Dynamics AX and Sitecore Commerce can sometimes be a challenge. Mostly because Dynamics AX installations often includes lots of customization and the way that configuration and setup is handled in AX Databases (online channel databases).

Dynamics AX push and pulls data and configuration through a number of “jobs”, and when that is done, it might break something. But what it breaks is not easy to identify.  The component/connector that ties Sitecore Commerce to Dynamics AX – the transaction service is where the potential errors will happen. It can be an Add-to-cart not working or all of a sudden or maybe some catalog configuration wrongly got pushed, or configuration or data around zip code etc. From my perspective – it’s never ever acceptable to just sit and wait for errors to occur. This must be a proactive procedure – we must do all we can to catch any errors before it hits the users.

POSTMAN
The transaction service is used from the Storefront through SOAP requests (through Pipelines etc.). Using postman, we can simulate any of those actions – bypassing the Storefront. We can also do a lot of scripting, testing and automation using postman.

NEWMAN
Using Newman, we can run postman collections from a command line. With this we have a simple setup to be able to continuously run tests to the transaction service and verifying that the most important actions works, e.g. Add-to-cart, Get Cart etc. So in case that some configuration changes in the online channel databases, or the RTS service is not responding – we can catch those error through over continuous testing.

HOW TO SET IT UP
First off, you need Node.js as Newman resides in a NPM registry (and on Github).

Following this guide will give you all needed to have you postman collections running from a command line.

A SPECIFIC SCENARIO
In my scenario, the Dynamics AX setup is for a retail business where each brick and mortar store have a web property. Each of these stores resides, in the Dynamics AX side in many online channel databases. I want my continuous testing to run a specific scenario for each of these stores repeatedly. To do this I have a CSV file with a store identifier  as well as an AX User Account ID to identify the users that performs each of the following step and simple tests:

GetShoppingCart
1. Check that no errors is returned
AddItems – add a specific product to the cart
1. Check that no errors is returned
2. Check that the product added is returned as part of the shopping cart returned
GetShoppingCart
1. Check that no errors is returned
2. Check that shopping cart is NOT empty
RemoveItems
1. Check that no errors is returned
2. Check that shopping cart is empty now
GetShoppingCart
1. Check that no errors is returned
2. Check that shopping cart is empty

Running the tests is very simple:

Open you Node.js Command prompt and navigate to the folder where you have you postman collection and your csv file. Use a command line like this:

newman run some_collection.json -d some_data.csv --bail

The -bail will stop the execution of the script in case an error occurs. There’s also a -n argument so you can ask newman to run your script n number of times.

The command line will look something like this (if you don’t put the –silent argument on it:

Nodejs-Newman-Running-Collection

In case the scripts fails, executing will stop due to the –bail argument and a result like the following will show:
Nodejs-Newman-Running-Collection-Bail-Test-Result
ALERTS AND MONITORING
There’s several options on how to get alerted. Since it's running postman it’s open on what you can do. You can send requests to slack or MS Teams. Pretty must everything is possible if you just need to do a get or post request to an end-point.

Another option is to use the monitoring offered by the postman team.

A FINAL WORD
If you’re looking for other hints and tools when working with a Sitecore Commerce and Dynamics Setup – take a look at another blog post on that here.

In case you find any of this useful and need more detail – please reach out to me or any of my colleges at Alpha Solutions.