EMR/boto - How to get cluster id and step id using boto? - boto

There are some describe_* functions in boto.emr need step_id. But the document does not describe very clearly how to obtain the step_id after submitting steps.
How can I get these step_ids after run_jobflow or add_steps?

The job-id (cluster id) can be found on the boto.emr.emrobject.JobFlow via the jobflowid method:
(Pdb) job().jobflowid returns: u'j-BZC0X65JLLEA'
for the step id for a given step, you can use the list_steps method on the connection, for example:
(Pdb) conn().list_steps('j-BZC0X65JLLEA').steps[-1].id returns: u's-1A1ASN2W23Y1L'
Calling steps will give you a list of boto.emr.emrobject.StepSummary objects, you can iterate over those and pluck out what you need.

Related

Get number of the current step

For troubleshooting purposes, I would like to obtain the URL to the current step of GitHub Actions logs.
The URL seems fairly easy to calculate:
url="https://github.com/$GITHUB_REPOSITORY/runs/$GITHUB_RUN_ID?check_suite_focus=true#step:$step_number:1"
What's missing is getting the number of the current step - I don't see it listed on https://docs.github.com/en/actions/learn-github-actions/contexts or https://docs.github.com/en/actions/learn-github-actions/environment-variables. Hard-coding the number is not ideal as adding/removing steps before this one will result in wrong/misleading URLs.
Is there perhaps some way to get the current step number that I've overlooked?
Alternatively, the step can have an id. However, it doesn't seem like there's a way to link to a step's log section by its id, is there?
Is there perhaps some way to get the current step number that I've overlooked?
Here is one (very) ugly way:
Give all steps an id. This causes them to be added to the steps object.
Obtain the length of the steps object with jq:
step_nr=$(echo '${{ toJson(steps) }}' | jq length)
Add 2, to get the 1-based step number. (+1 to convert 0-based numbering of length of steps so far to 1-based numbering used by the URL hash parser, and +1 for the "Set up job" step that runs automatically.)
Alternatively, the step can have an id. However, it doesn't seem like there's a way to link to a step's log section by its id, is there?
Looking at the JS code which handles the hash part of the URL, there is:
const e = window.location.hash.match(/^#step:(\d+):(\d+)$/) || [];
So, "no" apparently, at least not via the same mechanism as for indicating the step ID by number.

consider 2 request in a thread group, How to execute the 1request for one time and remaining request as per the thread count

Assume 2 requests in a thread group. Thread count is 100
Http sampler A, Http sampler b
I have extracted a set of values using JSON extractor and stored in a variable
I used the extracted values in request sampler b (added controller for each extracted values)
when I try to execute this script both the request ran for 100times
So I have added once the only controller for the 1st request. Even though both the request ran for 100times
I want to execute Request A for one time and request B for 100times. How can we achieve this?
As per documentation JMeter Variables are local to the thread (virtual user) so if you use variables from HTTP Sampler A in HTTP Sampler B you need to execute HTTP Sampler A once per user which gives you 100 executions.
If you're looking for a way to execute HTTP Sampler A only once, no matter how many threads you have:
Add setUp Thread Group to your Test Plan and keep threads/loops count as 1
Put your HTTP Sampler A under that setUp Thread Group
Save each value from JSON Extractor into a JMeter Property using __setProperty() function
In your main Thread Group use __P() function to access the values extracted in the setUp Thread Group

GoogleDrive API - how to get folder hierarchy from file in python

I using the following code to get all the files in my drive
files_list = service_v3.files().list(corpora='drive',
supportsAllDrives=True,
includeItemsFromAllDrives=True,
driveId=drive['id'],
spaces='drive',
fields='*').execute()
Now in each file I have a parent:
files_list[0]['parents']
How can I get data about this parent?
I've tried to use
service_v2.parents().list(fileId='xxx')
but it does not return much data.
You need to implement three steps:
List all files of interest - as you are already doing with files_list = service_v3.files().list
Loop through the list results or pick a certain file (as you are doing with files_list[0]) and retrieve its parents (as you are doing), e.g. parent = files_list[0].get('parents')
Use the method service_v3.files().get(fileId=parents[0], fields="*").execute() to retrieve the information about the parent by its Id
I recommend you to use the Try It API of the list and get methods in order to get a better understanding of the results those methods give you.
Also, please note that service_v2.parents().list(fileId='xxx') is using the old version of the Drive API (v2), and in any case - if you want to retrieve a file with a specified ID, the correct method to do it is getopposed to list.

Assert json parameter value in second response with respect to same first request

App is related to an f&b business, I have following scenarios (api calls):
Create Order - on creating an order of any food item (let it be X), inventory of which is updated at back-end (this value is under test, let it be P1)
Get Inventory - (this call will fetch me the updated value of inventory of ordered item (X) i.e. inventory value, P1)
Cancel Order - this will cancel the order, i created in my first call, and hence P1 should be rolled back.
Get Inventory - Again i will hit this call to get the value, so as to verify that the inventory value of P1 has been updated properly.
In API call, (2) I extract P1 value using jp#gc Json Extractor and same I did for same call (4).
Now as per my expectations, value obtained in both these extractors should be equal as order has been cancelled now.
To assert these values, I am using JSON Assertion , either I am making use of wrong assertion or lacking a big amount of information here.
May be there is something like I can save the value first in some variable, and then assert.
Image of my test suite:
You can add JSR223 Assertion with checking different variables e.g. a and b:
if (!vars.get("a").equals(vars.get("b"))) {
AssertionResult.setFailureMessage("message");
AssertionResult.setFailure(true);
}
The script can check various aspects of the SampleResult. If an error is detected, the script should use AssertionResult.setFailureMessage("message") and AssertionResult.setFailure(true)

jmeter to issue http request based on response

I'm using Jmeter for my API testing using various http requests and various samplers to validate them. Now, I'm writing test for another http request. In this test,the steps are:
Issue a http request. Handle response.
using xpath xtractor, I'm extracting the response and storing URL in another variable(store_url).
If variable has a URL, repeat step-1.
This loops has to be repeated until no value is stored in (store_URL).
There is not definite number, how many time the loop has to be repeated. It is based on store_url is empty or not.
How can I achieve this in jmeter? I know step-1 and step-2. But I'm looking how to repeat step-1 and step-2. Please help me.
set a jmeter variable loopCount to 1 for init value,
move your step 1 and 2 into a loop controller,
set to loop count to ${loopCount}
in your step 2,
increase loopCount if store_url is found after you finish xpath xtractor
Put your points 1 and 2 under While Controller
Use ${__javaScript(vars.get("store_URL") != null)} as While Controller's Condition
In condition __javaScript() function is used to check store_URL variable value.
if store_URL variable is set (has any value) - everything under the While Controller will start over
if store_URL variable becomes null - the look will break
vars - is a shorthand to JMeterVariables class instance, it provides read/write access to all JMeter Variables
See Using JMeter Functions article for more detailed information on __javaScript and other useful functions