Test Automation of Azure Function with Postman through FlexDeploy

Objective

We have a Java based Azure Function Application. We want to execute test cases once the application is deployed to Azure Function App.

We have newman collection test cases created against the Java app. We do have an environment file as well which contains relevant info for testing.

The Build job already creates an archive which can be deployed to Azure Function using deploy Functions plugin operation (https://flexagon.atlassian.net/wiki/spaces/FD60/pages/10037461003/deployFunctions).

Target test machine setup

  • First step is to configure the machine where the test cases will be executed. It can be the same machine where the deployment workflow ran or can be a totally different machine.

  • There could always be scenario where we are deploying the artifact to one server however the testing software/instance is present in another machine.

  • As a prerequisite, we must install the software(newman) for the testing. As from below mentioned details we can find we need to install nodejs and newman on the target system where we want to execute the test cases. In case nodejs and newman are not in PATH variable by default that path should be added as part of Test Instance property.

Installation command

sudo yum install –y nodejs

sudo npm install -g newman

  • We can verify if the software got installed properly and respective locations. We did the installation of software's on a new machine teplt02.

FlexDeploy test instance configuration

  • We configure the machine as an endpoint under FlexDeploy topology.

  • We navigate to Topology and create a new Test Instance. We provide Node js and Newman path as shown below while configuring.

  • We add the configured server(teplt02) as endpoint.

  • We are done with setup activity.

TEST AUTOMATION Project configuration

  • Lets first evaluate what needs to be configure to enable the testing based on newman test cases. First navigate to TEST AUTOMATION tab under Project and click on GET STARTED.

  • It will open a blank page with no UI but few suggestions. Apparently, it may look like this is a complex approach since manual intervention is required. However, on the contrary its super easy to use.

  • As we can see as soon as type something it would suggest potential property/parameter details. We first add a testName.

  • Next to make the project understand what kind of test cases to be executed, type workflow and while selecting the name choose the desired test case type. Any testing software with FlexDeploy plugin support can be selected from drop down.

  • In our case as soon as we select Postman-runCollection , all relevant properties will appear automatically as shown below.

  • All property details with purpose and explanation can be check from plugin operation guide in confluence.

https://flexagon.atlassian.net/wiki/spaces/FD60/pages/9856626313/ExecuteCollection

  • For now we just keep the FDPMN_POSTMAN_COLLECTION_FILE and FDPMN_POSTMAN_ENVIRONMENT_FILE property with relevant details. Instead of providing exact path we can add Collection_file details in wild card format as well.

Configure Test Instance under TEST AUTOMATION section

  • We have to add the TEST_INSTANCE property as well. This is generic for all test cases. We provided the Test instance name which we have already configured in previous step.

  • Test instance is where the test collection will run. In case not provided it will try to execute on deployed target group endpoint.

Execute testing

  • We navigate to the Project execution tab and select TEST button after deployment.

  • This will ask for Environment and Target Group details. Which we provide and initiate the testing.

  • Next when we execute the Test action after deployment , we can find the action completed successfully, yet no test collection file found hence all test cases are skipped.

  • This happened because we have to either provide the test cases as absolute url or the test case files should be present under artifact objects.

  • We update our Build workflow to upload the Collection & Environment file as part of Artifacts.

  • Now on execution, we can check the logs to find the collection file is found successfully.

  • From SUMMARY tab we can find two test cases successfully executed.

  • We can find detailed result under TEST RESULTS tab.

https://flexagon.atlassian.net/wiki/spaces/FD65/pages/10125807976 - Must read for more detailed options/explanations.

https://bitbucket.org/indrayan/javaazurefunction/src/test/Test/TestCases/

 

The following macros are not currently supported in the footer:
  • style