POSTMAN - Newman Run Iteration Json File on Specific Endpoint - json

I have a postman collection that contains some endpoint. Something like this
my-collection
|- Get All Users
|- Get User
|- Delete User
I also have some newman scenario/iteration json files (1. get-all-users.json, 2. get-user.json, 3. delete-user.json).
How do i run single scenario/iteration json file to specific endpoint on my-collection?
Lets say get-all-users.json run for Get All Users endpoint only, instead of run for all endpoints.

By 'single endpoint', you mean running a single sub-folder for 1 iteration, say, 'Get All Users'. Right?
If so, you can export your my-collection as a JSON on your system (No need to individually export the sub-folders to get-all-users.json, get-user.json, delete-user.json).
You can use --folder option (See here for reference). Just give the folder name you want to run, i.e., "Get All Users"
So, your newman command should be (your environment json and global json being "env.json" and "global.json" respectively) :
newman run "<my_collection_path>/my-collection.json" --folder "Get All Users" -e "<env_path>/env.json" -g "<global_path>/global.json"
This way you should be able to run a requests in a single sub-folder at a time.

Related

differences between get_directory_client and get_subdirectory_client for azure file share

Azure file share Python SDKs have two similar methods get_directory_client and get_subdirectory_client. It seems both are interacting with directories. But do we need two methods to perform the same task?
get_directory_client is to get the root directory, and get_subdirectory_client is to get the subdirectories of the current directory.
As you can see from the document, you must get the ShareClient object first. At this time, you can only call get_directory_client to get the root directory, and then you will get the ShareDirectoryClient object. At this time, if you want to get the subdirectory , You can only call the get_subdirectory_client method.
You can also refer to the description of the file share client to understand the difference:
==========================update======================
connection_string = "<your-connection-string>"
service = ShareServiceClient.from_connection_string(conn_str=connection_string)
share = service.get_share_client("<your-file-share-name>")
my_files = []
for item in share.list_directories_and_files():
my_files.append(item)
if item["is_directory"]:
for item2 in share.get_directory_client(item["name"]).list_directories_and_files():
my_files.append(item)
for item3 in share.get_directory_client(item["name"]).get_subdirectory_client(item2["name"]).list_directories_and_files():
my_files.append(item3)
else:
my_files.append(item)
print(my_files)
You can refer to this official documentation.
Honestly, I find it a bit confusing having to deal with two different methods to do "the same thing". I prefer to instantiate the directory client via the from_connection_string method.
For more information on how to list files from a FileShare, take a look at the following post: "Azure File Share - Recursive Directory Search like os.walk". The approach I reported allows to list files recursively, walking through the directories.

Azure key Vault value integration inside a JSON of an application

I have Mesosphere DC/OS installed on Azure cluster, running tomcat apps as services, those services are configured using JSON files holding the ports and passwords of the apps. My Manager wants to use Azure Key Vault to store the passwords and secrets of the apps, i created the vault and stored in it the secrets i need.
This is a part of my JSON values which i need to replace:
(i cut only the fields with the values i want to replace from the Vault)
"APP_ACCESS_SERVICE_PASSWORD": "AppPW",
"CASSANDRA_DB_PASSWORD": "App_uat_PW",
"UAMS_ORACLE_PASSWORD": "App_uat_PW",
"PUBLISH_DB_PASSWORD": "ogw",
"App-PUBLISH_DB_PASSWORD": "App_uat1",
"EMP_DB_PASSWORD": "App_uat1",
How can i replace the passwords in my JSON with the values in the key vault ? i mean putting a URL to the password instead of the password is not an option, any Idea how can i input the values in the key vault into the JSON instead of the static values ?
From Azure documentation i see that i can access the values using URL, for example:
https://Contoso-Vault2.vault.azure.net/secrets/ExamplePassword
but using URL instead of the value is not an option. (it won't work)
I assume you have a pipeline but here's how you could do it.
First create your secrets in your desired key vault. I have created an app using Python and the Azure sdk which lets you create multiple secrets in a key vault very easily - https://github.com/TechyTish/AzurePy/blob/main/create-azure-secrets-README.md
lets say your secrets are stored as (secretName: secretValue):
appAccessService: 1234
cassandraDB: hello567
...
etc
#filename: example.json
"APP_ACCESS_SERVICE_PASSWORD": "{#appAccessServicePW#}",
"CASSANDRA_DB_PASSWORD": "{#cassandraDB#}",
"UAMS_ORACLE_PASSWORD": "{#uamsOraclePW#}",
"PUBLISH_DB_PASSWORD": "{#publishDBPW#}",
"App-PUBLISH_DB_PASSWORD": "{#appPublishPW#}",
"EMP_DB_PASSWORD": "{#empDBPW#}",
Create a YAML pipeline which will have 2 tasks:
Extract keyvault secrets
Replace the .json key values with the secrets
#filename: azure-pipeline.yml
# Azure Key Vault
# Download Azure Key Vault secrets
- task: AzureKeyVault#2
inputs:
connectedServiceName: # Azure subscription - you will need to create an service connection in the repo which has access policies to the keyvault
keyVaultName: # Name of existing key vault
secretsFilter: '*' # Downloads all secrets for the key vault
runAsPreJob: true # Runs before the job starts
Underneath the previous task add another one.
This looks for any key value with the {# pre-fix and #} suffix in the .json file and the variables (below) after this task will replace the value in the .json file with the value of the secrets you assigned it.
#filename: azure-pipeline.yml
- task: qetza.replacetokens.replacetokens-task.replacetokens#3
inputs:
targetFiles: "$(Pipeline.Workspace)/codepath/jsonFileName.json"
encoding: "auto"
writeBOM: true
verbosity: "detailed"
actionOnMissing: "warn"
keepToken: false
tokenPrefix: "{#"
tokenSuffix: "#}"
displayName: Perform variable substitution in json file
- script: echo "$(<folderName/example.json)" #open json file in the terminal to show the changes
#.json value: point to secret name
variables:
appAccessServicePW: $(appAccessService)
cassandraDB: $(cassandraDB)
#....
#etc
Run the pipeline (tick the box for debugging) and your output of .json file should be:
#filename: appsettings.json
"APP_ACCESS_SERVICE_PASSWORD": "1234",
"CASSANDRA_DB_PASSWORD": "hello567"
#....
#etc
This way the only time your secrets are revealed is when the pipeline is run on whichever host agent (virtual machine) you use.

How can I get microphone dB level in a script?

I would like to get microphone input level in spark ar script for an AR filter I'm developing.
It looks like this existed at this link at some point but the page is empty now: https://sparkar.facebook.com/ar-studio/learn/documentation/tutorials-and-samples/audio-analyzer-and-energy-meter/
I tried to create a bit crusher patch and connect its output to a value patch and pass that to script but spark ar shows an error: "Please check the patch graph and try again"
Also I have no idea what type that would be so I can't read it on the script.

JMeter: How to insert server name/IP dynamically in HTTP Request

I have created JMeter script that need to be used for different environments like Staging, Production, etc. I want to dynamically change the IP address.
Can someone let me know how can I proceed with this?
Remove all the IP, port, protocol details from the HTTP Sampler.
Add HTTP Request Defaults under test plan - in which you can update IP, Port & Protocol details. So, just changing it one place will do for entire test.
As you need to change it dynamically, use property file/properties. for example.. (these names can be anything)
host.ip=10.11.12.13
host.port=443
host.protocol=https
You can pass the properties via command line argument to the test.
jmeter -n -t /path/to/test.jmx -l /path/to/result.jtl -Jhost.ip=10.111.12.13 -Jhost.port=443 -Jhost.protocol=https -Jtest.duration=300
J - defines a local JMeter property.
In the test, access these values using ${__P(host.ip)},${__P(host.port)}..etc
If you have a lot of properties, You can have a look at the Property File Reader. I have been using this for a while & I love it.
Advantage is - even in the GUI mode, it will work great.
http://www.testautomationguru.com/jmeter-property-file-reader-a-custom-config-element/
If you use the Property File Reader & pass the property file name itself dynamically, then use
jmeter -n -t /path/to/test.jmx -l /path/to/result.jtl -Jproperty.file.path=/path/to/file.properties
Then access it using ${__P(property.file.path)} in the File Path.

How to maintain sessionid across different thread groups

I'm doing API testing using JSON.
My Jmeter's TestPlan looks like below:
Test Plan
Thread Group 1 (run once)
- Login
Thread Group 2 (I will run this multiple times)
- Do some opeartion
Thread Group 3 (run once)
- Logout
I want to pass sessionid from Thread Group 1 to Thread Group 2 and 3.
To extract sessionId use Regular Expression Extractor
you can use following code to pass a value to another thread group using beanshell postprocessor listener element in Jmeter
Beanshell code to save variable
import org.apache.jmeter.util.JMeterUtils;
JMeterUtils.setProperty("propname", "value");
Beanshell code to retrieve variable from another thread group
import org.apache.jmeter.util.JMeterUtils;
vars.put("localvariable", JMeterUtils.getProperty("propname"));
var testVar=vars.get("localvariable");
log.info("# NEXT THREAD GROUP value="+testVar);
Code using Jmeter's getprperty(),setproperty() API to pass the values. Also you can use JMeter Plugins has Inter-Thread Communication.
hope this will help. :)
How to use Beanshell guide contains an example of sharing cookies between different thread groups, scroll down to Advanced Examples section.
If you "session" assumes cookie-based session you'll need to do the following:
Add HTTP Cookie Manager to the Test Plan (or each thread group if you prefer)
Tell the Cookie Manager to save cookies as variables by setting CookieManager.save.cookies property to true in jmeter.properties file which lives under /bin folder of your JMeter installation or passing it as command-line argument as follows
jmeter -JCookieManager.save.cookies=true -n ... -t ... -l ...
Another approach is to have only one Thread Group instead of three and add CookieManager to your Thread Group. Have a Loop Controller to run the operation multiple times.
Your test can be structured as:
Test Plan
Thread Group
- Cookie Manager
- Login
- Loop Controller (run this multiple times)
- Do some operation
- Logout