I'm reading uptimes of several applications on different systems. Currently, when the application is launched, it creates an ID with a pingTime, and a pingTimeAsString. Both are read and shown in html like this (page automatically refreshes every few minutes):
<p>
System ID: {{ stat.sysID }}
Uptime: {{ stat.pingTimeAsString | date : 'mediumTime'}}
</p>
Is there a way to compare this pingTime or pingTimeAsString that is written in a file to the current time + a certain amount of minutes (the duration of how long since the last time the application responded to a ping/sent an update)? That way I can change the listing to display a ONLINE/OFFLINE sort of status?
Update: How the query looks from reading the RESTService:
[{"pingTime":"\/Date(1405706983530-0400)\/","pingTimeAsString":"Jul 21 2014 2:09PM","sysID":"2"}]
You could use the moment.js library to make the task easier:
moment().diff("\/Date(1405706983530-0400)\/") // different from now in milliseconds
or if you want the result in other units:
moment().diff("\/Date(1405706983530-0400)\/", "minutes");
you can even get a human friendly text like:
moment([2010, 7, 21]).fromNow(); // 4 years ago
Hope this helps.
Related
I am running a Jmeter Test Plan with an HTTP Request, to test the performance of a web service.
In my test, I need a variable named REF to be changed in the body data of my HTTP Request.
REF can have 3000 values. So I have created a CSV file with all these 3000 values, a CSV Data Set Config, and a parameter in Jmeter named REF, and I use it in my HTTP Request like that :
<measure>
<measureRef id="${REF}"></measureRef>
<measureTime>${__time(yyyy-MM-dd'T'HH:mm:ss)}</measureTime>
<measureVal>
<value>${__Random(1,100,)}</value>
</measureVal>
</measure>
As you can see it in this XML, I use the functions time and Random of Jmeter to have different requests everytime I run the test plan.
I would like yo run the test plan automatically for all the 3000 values of REF. To do that, I tried to configure the thread group like this : Number of Threads = 3000 and Loop Control = 1.
The problem is that the test takes 3 minutes to be done. So I would like to know if there is another way to do. The thing is that I need the test to be done for all the differents 3000 values in my CSV, and I don't see another way to do. I tried to put another measure in my Body Data, like this :
<measure>
<measureRef id="${REF}"></measureRef>
<measureTime>${__time(yyyy-MM-dd'T'HH:mm:ss)}</measureTime>
<measureVal>
<value>${__Random(1,100,)}</value>
</measureVal>
</measure>
<measure>
<measureRef id="${REF}"></measureRef>
<measureTime>${__time(yyyy-MM-dd'T'HH:mm:ss)}</measureTime>
<measureVal>
<value>${__Random(1,100,)}</value>
</measureVal>
</measure>
But the value of REF that is used this the same in the two measures, and what I want is to have different values picked in the CSV.
I also tried to configure the Thread Group like this : Number of Threads = 1 and Loop Control = 3000. But it's not working, I have a lot of errors...
I want the test to be runned quickly because to test my web service, I'd like to inject the 3000 values every 1 minute (by using a Flow Control Action maybe). And if the test runs in 3 minutes, I would be too long, and all the values would not be tested...
Thank you for your help !
If you are using 2 data in 1 request then you can use max 1500 virtual users if you are not repeating your data.
If it is fine then add 2 columns in csv file like REF1 and REF2 and each column will have 1500 data. Then you can use ${REF1} and ${REF2} in your requests.
If it takes you 3 minutes to add 3000 values with 3000 users and you need this to be done in 1 minute I can think of 2 possible causes:
Your application cannot process the requests faster. You can try increasing number of threads i.e. to 9000 in the Thread Group and see whether it helps or not. If you still have this 3 minutes processing time - it's your application to blame
JMeter is not capable of sending requests fast enough.
First of all make sure to follow JMeter Best Practices
Then make sure to monitor the health of the machine where JMeter is running using i.e. JMeter PerfMon Plugin as JMeter must have enough headroom to operate
If a single machine cannot produce 3000 requests per minute - you will have to go for Distributed Testing
How do I convert seconds to HH.MM:SS via MediaWiki (plus Semantic Media Wiki)?
I tried and tried and just can't find a way.
The duration in seconds comes via filling out a template.
As I can't install more extensions to the Wiki the only ways are via SMW and parser functions.
Thank you very much in advance!
You should be able to do this with the time parser function:
{{#time: H.i.s | #123 }}
It't not strickly treating it as a time duration, but rather a time from the unix epoch, but if you don't go over 24 hours it doesn't really matter.
If you need to go higher, then you can build up a custom expression using the trunc operator, for example to get the number of hours:
{{#expr: trunc (123/60/60) }}
In our hyperion application, we have a explore button.
Here is its post:
web_submit_data("explorer", //FIXME: id vlaue parameter
"Action=https://{host_url}/raframework/browse/explorer",
"Method=POST",
"TargetFrame=",
"RecContentType=application/x-json",
"Referer=https://{host_url}/workspace/index.jsp?framed=true",
"Snapshot=t19.inf",
"Mode=HTML",
ITEMDATA,
"Name=class", "Value=com.hyperion.tools.cds.explorer.ExplorerView", ENDITEM,
"Name=id", "Value=EV1390418511260", ENDITEM, //"Name=id", "Value=EV1389926310921", ENDITEM,
LAST);
This EV1390418511260 is from
this._rstExplorerViewId = "EV" + (new Date()).getTime();
from the loaded module.js file I guess, which is Unix time stamp
I tried lr_save_timestamp("timestamp", LAST ); to correlate value of id with Unix time stamp. like Value=EV{timestamp}. The request is being posted but the response body has
Content-Length: 0
X-ORACLE-BPMUI-CSRF: false
I want to try
typedef long time_t;
time_t t;
and correlate something like Value=EV{time(&t)} but here it converts to url encode and takes ascii values of those special chars.
What should I do?
Why are you using C code to replace the functionality of built in capability to LoadRunner?
See web_save_timestamp_param() for the number of milliseconds since Jan 1, 1970.
web_save_timestamp_param("tStamp", LAST );
web_submit_data("explorer",
...
ITEMDATA,
"Name=class", "Value=com.hyperion.tools.cds.explorer.ExplorerView", ENDITEM,
"Name=id", "Value=EV{tStamp}", ENDITEM,
LAST);
if this is your first trip into the Hyperion universe I would heartily suggest you find the most experienced LoadRunner professional available anywhere in the nation to support your efforts. You do not need to be struggling with tool use while at the same time working in one of the more difficult environments for any performance testing tool. Assuming you get someone who has been succesful with Hyperion recently, no matter what your organization spends (even as high as $300 per hour or more) it will be money well spent versus struggling with both tool mechanics and testing of the environment
Question on agents: I specifically want to create a Periodic Task, but only want to run it once every day, say 1am, not every 30 minutes which is the default. In the OnInvoke, do I simply check for the hour, and run it only if current hour matches that desired hour.
But on the next OnInvoke call, it will try to run again in 30 minute, maybe when it's 1:31am.
So I guess I'd use a stored boolean in the app settings to mark as "already run for today" or similar, and then check against that value?
If you specifically want to run a custom action at 1 am, i'm not sure that a single boolean would be enough to make it work.
I guess that you plan to reset your boolean at 1:31 to prepare the execution of the next day, but what if your periodic task is also called at 1h51 (so called more than 2 times between 1am and 2am).
How could this happen? Well maybe this could happen if the device is reboot but i'm not quiet sure about it. In any case, storing the last execution datetime somewhere and comparing it to the current one can be a safer way to ensure that your action is only invoked once per day.
One question remains : Where to store your boolean or datetime (depending which one you'll pick)?
AppSetting does not seem to be a recommanded place according msdn :
Passing information between the foreground app and background agents
can be challenging because it is not possible to predict if the agent
and the app will run simultaneously. The following are recommended
patterns for this.
For Periodic and Resource-intensive Agents: Use LINQ 2 SQL or a file in isolated storage that is guarded with a Mutex. For
one-direction communication where the foreground app writes and the
agent only reads, we recommend using an isolated storage file with a
Mutex. We recommend that you do not use IsolatedStorageSettings to
communicate between processes because it is possible for the data to
become corrupt.
A simple file in isolated storage should get the job done.
If you're going by date (once per day) and it's valid that the task can run at 11pm on a day and 1am the next, then after the agent has run you could store the current date (forgetting about time). Then whenever the agent runs again in 30 minutes, check if the date the task last ran is the same as the current date.
protected override void OnInvoke(ScheduledTask task)
{
var lastRunDate = (DateTime)IsolatedStorageSettings.ApplicationSettings["LastRunDate"];
if(DateTime.Today.Subtract(lastRunDate).Days > 0)
{
// it's a greater date than when the task last ran
// DO STUFF!
// save the date - we only care about the date part
IsolatedStorageSettings.ApplicationSettings["LastRunDate"] = DateTime.Today;
IsolatedStorageSettings.ApplicationSettings.Save();
}
NotifyComplete();
}
I want to know if there is a name for a function/method/library that converts a given date object with time information into something like:
a few seconds ago
2 minutes ago
about an hour ago
10 hours ago
yesterday
on 12-May-2010
and so on. I don't know what to google for, but I'm guessing that someone must have done this before. I'm specifically looking for an implementation in python (preferably a Django filter) that works on a datetime, but any open source implementation in any language will do really, for inspiration.
Google for "Fuzzy Date Time"
I believe it is called "fuzzy timestamp" (also "timedelta")
ruby and python examples are available in this SO question
git has its own date.c utility source for this kind of refspec date specification.
A ref followed by the suffix # with a date specification enclosed in a brace pair (e.g. {yesterday}, {1 month 2 weeks 3 days 1 hour 1 second ago} or {1979-02-26 18:30:00}) to specify the value of the ref at a prior point in time.
I don't really know the name of the method used, but you can find a Javascript implementation of what you're describing at DateJS.