Is there an idiomatic way of achieving this:
I need to PUT/POST a given entity. However, before actually putting it I need to do some changes on a more volatile system, and if that works I will go on.
So I will first ask if the PUT/POST is acceptable and then later actually do the PUT/POST.
I've thought of just using a "dry-run" query-parameter, but it doesn't feel like the right way.
Update: Trying to clarify my problem. The point is that the first PUT is just for verification of the entity.
Me System A Volatile System X
| Dry PUT | :
|-------------->| :
| | :
| 20x / 40x | :
|<--------------| :
| : :
| Upon PUT OK do some related work :
|----------------------------------->|
| : |
| Work completely |
|<-----------------------------------|
| :
|PUT (for real) :
|-------------->|
| |
| 20x |
|<--------------|
Logically I feel that this could perhaps be solved by a some kind of state property. If you are using JSON, you might for example consider adding a property like this:
{
"draft" : true
}
The first time you do the PUT request, you mark the item as draft. It stores the item but doesn't do anything else with it .
After your server accepted your request, you can then do your 'related work' elsewhere, and if that succeeded as well you can submit another PUT request to the same resource, this time setting draft to false.
Related
This question already has answers here:
powershell json conversion problem correct results only when saving to a variable
(1 answer)
Read multiple JSON files into an array of Powershell objects and filter out those with the same value for a property
(1 answer)
Closed 1 year ago.
I'm trying to solve a problem for a customer. I don't have access to the same software as they do. So, I've created this demonstration code.
What I would like to suggest is for them to consume JSON. But, what I found for ConvertFrom-Json on PowerShell 5.1 is that it is emitting a single array as output.
They want to use Where-Object. But, in my testing, that will return the whole array.
Normally, I would expect PowerShell to emit single objects. I'm not sure why I'm getting one object (the entire array).
I noticed if I shut down the pipeline (Example One) then I get the behavior I want.
I'm aware of where(). But, I want to take advantage of the customer's muscle memory--<# objects #> | Where-Object { <# test #> }--and use the pipeline.
This also seemed like it could be improved: | ForEach-Object { $_.ForEach({ $_ }) } |
Question
Is there a better way to emit individual objects without shutting down the pipeline?
> # Example One
> (& '.\Stack Overflow Demo 03.ps1' | ConvertTo-JSON | ConvertFrom-Json) | Select-Object -First 1
Id : ba7fab67-5cd7-401a-9c88-c4a2e88f6932
Name : Development
Description : Default development device group
ProductId : 556957b4-aa39-4e5a-aa4c-d3208c277f3c
OsFeedType : Retail
UpdatePolicy : Accept only system software updates. Don't accep
AllowCrashDumpsCollection : False
CurrentDeployment : None
> # Example Two
> & '.\Stack Overflow Demo 03.ps1' | ConvertTo-JSON | ConvertFrom-Json | Select-Object -First 1
Id : ba7fab67-5cd7-401a-9c88-c4a2e88f6932
Name : Development
Description : Default development device group
ProductId : 556957b4-aa39-4e5a-aa4c-d3208c277f3c
OsFeedType : Retail
UpdatePolicy : Accept only system software updates. Don't accep
AllowCrashDumpsCollection : False
CurrentDeployment : None
Id : 45acb705-a591-4e41-ba1e-4b3dd062e1ec
Name : Field Test
Description : FieldTest
ProductId : 556957b4-aa39-4e5a-aa4c-d3208c277f3c
OsFeedType : Retail
UpdatePolicy : Accept all updates from the Azure Sphere Securit
AllowCrashDumpsCollection : False
CurrentDeployment : d684d491-9229-484f-a2eb-fda0168f7e27
...
I'm doing some loadtesting of an API using a somewhat basic setup in JMeter.
The idea here is that the Thread group spawns a bunch of clients/threads and each of these clients has a bunch of loops which runs in parallel (using the Bzm - parallel controller).
Each loop represents some kind of action that a user can perform and each loop has a Uniform Timer Controller to adjust how often a given action is performed for each client.
One of the actions consists of two calls, first one (1) fetches som id's which are then extracted with a JSON extractor and modified a bit with a BeanShell Post Processor. The result from the post processor is then used as a param for the next call (2).
The issue I'm facing is that in my Summary report there is a lot more results from the first HTTP request (1) showing up than from the second one (2). I would expect them to always be called the same number of times.
My guess is that it all comes down to me lacking some basic understanding of flow and concurrency (and maybe timers) in JMeter, but I have been unable to figure it out, so I need help.
This is the setup, imagine there being multiple loops.
Thread group
+
|
+------ ---+ Parallel controller
| +
| |
| +-----------+ Loop
| +
| +----------+ Transaction
| | +
| | |
| | +---------+ Uniform random timer
| | +
| | |
| | |
| | +
| | (1) HTTP request
| | +
| | +---------+ JSON extractor
+ | | +
| | |
Summary Report | | +
| | BeanShell Post processor
| |
| |
| |
| +
|
| (2) HTTP request
|
|
|
Loop +----------------------------------+
|
|
Ok, so I figured it out. It all comes down to understanding the structure of the tests, diving in to the docs really helped as they are very detailed.
This is the relevant part:
Note that timers are processed before each sampler in the scope in
which they are found; if there are several timers in the same scope,
all the timers will be processed before each sampler. Timers are only
processed in conjunction with a sampler. A timer which is not in the
same scope as a sampler will not be processed at all. To apply a
timer to a single sampler, add the timer as a child element of the
sampler. The timer will be applied before the sampler is executed. To
apply a timer after a sampler, either add it to the next sampler, or
add it as the child of a Flow Control Action Sampler.
https://jmeter.apache.org/usermanual/component_reference.html#timers
Another extremely important thing to understand is that some building blocks (in relation to the tree structure) are hierarchical some are ordered and some are both. This is described in detail here https://jmeter.apache.org/usermanual/test_plan.html#scoping_rules
All in all my issue could be fixed by putting the Uniform random timer as a child of the first HTTP call (1) causing it to only affect that call, or by adding a Flow Control Action as a sibling after the second call (2) and adding the Uniform random timer as a child to that.
Incredibly new to Selenium IDE / Automating tests and currently I am trying to store part of a text, which is a variable to use in later in another web page.
I haven't actually tried much but have been reading quite a few threads but I'm just not grasping the concepts I guess
<tr align=center> <td><font size='+1' color='white'><b>Authorization Request - Confirmation Number: 219927</b> </font></td></tr>
In this example, I need to be able to store 219927 to use later on another site
The below has passed all of the tests but I seem to not be able to echo the output back on another site:
store | xpath=//b[contains(.,'Authorization Request - Confirmation Number: 135085')] | string
store | 1 | delimiter store | javascript{storedVars['string'].split('- ')[storedVars['delimiter']]} | test
store | 0 | delimiter1
store | javascript{storedVars['test'].split(',')[storedVars['delimiter1']]} | output
echo | ${output}
Much like in the example from this question I see many code snippets on the web using magic numbers when making ExtendedPropertyDefinition. Example:
Dim PR_DELETED_ON As New ExtendedPropertyDefinition(26255, MapiPropertyType.SystemTime)
Dim PR_SEARCH_KEY As New ExtendedPropertyDefinition(12299, MapiPropertyType.Binary)
I have sort of found a reference location for these on MSDN. I can look them up individually as supposed to one large table. Here is the one for PR_DELETED_ON like in the above example
+------------------------+---------------+
| Associated properties: | PR_SEARCH_KEY |
+------------------------+---------------+
| Identifier: | 0x300B |
+------------------------+---------------+
| Data type: | PT_BINARY |
+------------------------+---------------+
| Area: | ID properties |
+------------------------+---------------+
0x300b being 12299 in decimal
I hate magic numbers so I was looking for an enum for this in the EWS API. I wrote this snippet to (hopefully) show me all the enums exposed.
$obj = [Reflection.Assembly]::LoadFile("C:\Program Files (x86)\EWSManagedAPI\Microsoft.Exchange.WebServices.dll")
$obj.GetTypes() | Where-object{$_.isenum -and ($_.ispublic -or $_.isnestedpublic)} | ForEach-Object{
$props = #{Name = $_.FullName}
[enum]::GetValues($_) | ForEach-Object{
$props.Integer = [int64]$_
$props.Text = $_
[pscustomobject]$props
}
}
I didn't see anything in the output that matched what I was looking at above. Does anyone know if there is a preexisting enum for these properties? If not that is fine. I just assumed there would be something out there.
Not the end of the world but I couldn't find them myself. Might explain why code snippets keep referencing to them.
No there is nothing in the EWS Managed API for this and AFAIK there is no master list maintained by Microsoft. There are also different types of Properties eg Tagged and Named properties and to use an Extended property in EWS you need to first define and tell Exchange to either return or set that property so EWS doesn't allow you to enumerate all the Extended properties on a Item like MAPI. The closest list that I know of is the one from the EWSEditor which is pretty comprehensive https://ewseditor.codeplex.com/SourceControl/latest#EWSEditor/PropertyInformation/KnownExtendedPropertiesData.cs . The Mapi include files also have a good list eg https://github.com/openchange/openchange/blob/master/properties_enum.h (but these are only tagged properties).
Is it possible to use a DbFit variable in another fixture? For example, if I create a query in dbfit with a variable <<firstname as follows:
SELECT * FROM System.Columns Where ColumnName= 'FirstName' | <<firstname |
Is it possible to include a reference to that page in another suite of tests that use a column fixture or RestFixture and call the variable name to check against the database?
In the RestFixture, I'm checking a database column name against a node so can I do something like:
| GET | /resources/6 | | //${firstname} |
Where I'm checking if an xml node named FirstName exists in the database.
With fitSharp (.NET), it is. With Java, I'm not sure.
I was struggling with the same issue, imo it's hard to find any good documentation. I stumbled upon the answer skimming some arbitrary tests somewhere.
You can access the symbol in RESTFixture using %variablename%.
RestFixture
| GET | /resources/6 | | //%firstname% |