Convert code to increment by Minutes and Hours rather than 100 - actionscript-3

I am trying to convert this block of code to increment like time and minutes (0-60) instead of counting and changing when it hits 100. This is run from a button that adds 1, 5, or 10 to the score. The MC contains three child MC's of digits, each one with a text field that has 10 frames that changes it from 0-9. It works perfect as it is, but I want the 100th digit (or digit3) to change to 1 when the first two digits reach 60 instead of 99. I Can't figure out how I need to incorporate this into the code. Any help would be appreciated. I might even need to rewrite the whole thing.
var SPEED:int = 1;// how fast to count
var NUM_DIGITS:int = 3;// how many digits are there in the score
var _totalScore:int = 0;
var _displayScore:int = 0;
// add an amount to the score
function add(amount:int):void
{
_totalScore += amount;
addEventListener(Event.ENTER_FRAME, updateScoreDisplay);// start the display counting up
}
// this runs every frame to update the score
function updateScoreDisplay(e:Event):void
{
// increment the display score by the speed amount
_displayScore += SPEED;
// make sure the display score is not higher than the actual score
if (_displayScore > _totalScore)
{
_displayScore = _totalScore;
}
var scoreStr:String = String(_displayScore);// cast displayScore as a String
// add leading zeros
while (scoreStr.length < NUM_DIGITS)
{
scoreStr = "0" + scoreStr;
}
// loop through and update each digit
for (var i:int = 0; i < NUM_DIGITS; i++)
{
var num = int(scoreStr.charAt(i));
this["digit" + (i + 1)].gotoAndStop(num+1);
}
// set the digit mc to the right frame;
// if the display score is equal to the total score remove the enterframe event
if (_totalScore == _displayScore)
{
removeEventListener(Event.ENTER_FRAME, updateScoreDisplay);
}
}

Are you changing the actual calculated score? Or just the label that displays the score?
If you want to keep the calculated score as a normal number but only change the way you display it, use this:
var seconds:String = (_displayScore % 60).toString();
var minutes:String = Math.floor(_displayScore / 60).toString();
if(seconds.length == 1)
seconds = "0" + seconds;
var scoreStr:String = minutes + seconds;

I'd rather rewrite the above to something that fits your current requirements.
Here's an example:
Main.as
package {
import flash.display.Sprite;
import flash.events.Event;
[SWF(frameRate="24", backgroundColor="#FFFFFF", width="400", height="240")]
public class Main extends Sprite {
private static const STOP_AT_HOUR:uint = 2;
private static const STOP_AT_MINUTES:uint = 31;
public function Main() {
var tracker:Tracker = new Tracker();
startTracking(tracker, STOP_AT_HOUR, STOP_AT_MINUTES,
function onTrackingProgress(tracker:Tracker):void {
updateVisualElements(tracker);
});
}
private function startTracking(tracker:Tracker, stopAtHour:uint, stopAtMinutes:uint, onProgress:Function):void {
addEventListener(Event.ENTER_FRAME, function onEnterFrame(event:Event):void {
onProgress(tracker.increment());
if (tracker.hours == stopAtHour && tracker.minutes == stopAtMinutes) {
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
trace("Maximum bounds have been reached; tracking stopped.");
}
});
}
private function updateVisualElements(tracker:Tracker):void {
var hoursString: String = appendLeadingZero(tracker.hours);
var minutesString:String = appendLeadingZero(tracker.minutes);
trace("Tracked time: " + hoursString + ":" + minutesString);
try {
// update visual elements that display hour
this["digit0"].gotoAndPlay(uint(hoursString.charAt(0)) + 1);
this["digit1"].gotoAndPlay(uint(hoursString.charAt(1)) + 1);
// update visual elements that display minutes
this["digit2"].gotoAndPlay(uint(minutesString.charAt(0)) + 1);
this["digit3"].gotoAndPlay(uint(minutesString.charAt(1)) + 1);
} catch (error: Error) {
// does not work because there are no visual elements named "digit0", "digit1", "digit2", "digit3"
// in this example; the above code is purely demonstrative to show how such visual elements
// could be updated using the tracker information
}
}
private function appendLeadingZero(temporalValue:uint):String {
if (temporalValue >= 100) throw new ArgumentError("Implementation missing for values above 99");
return temporalValue < 10 ? String("0" + temporalValue) : String(temporalValue);
}
}
}
Tracker.as
package {
public class Tracker {
private var _hours:uint = 0;
private var _minutes:uint = 0;
private var minutesResetValue:uint;
public function Tracker(minutesResetValue:uint = 60) {
this.minutesResetValue = minutesResetValue;
}
public function increment():Tracker {
_minutes++;
if (_minutes == minutesResetValue) {
_minutes = 0;
_hours++;
}
return this;
}
public function get hours():uint {
return _hours;
}
public function get minutes():uint {
return _minutes;
}
}
}
Running the above code would output:
[trace] Tracked time: 00:01
[trace] Tracked time: 00:02
[trace] Tracked time: 00:03
[trace] Tracked time: 00:04
[trace] Tracked time: 00:05
[trace] Tracked time: 00:06
[trace] Tracked time: 00:07
[trace] Tracked time: 00:08
[trace] Tracked time: 00:09
[trace] Tracked time: 00:10
[trace] Tracked time: 00:11
[trace] Tracked time: 00:12
[trace] Tracked time: 00:13
[trace] Tracked time: 00:14
[trace] Tracked time: 00:15
[trace] Tracked time: 00:16
[trace] Tracked time: 00:17
[trace] Tracked time: 00:18
[trace] Tracked time: 00:19
[trace] Tracked time: 00:20
[trace] Tracked time: 00:21
[trace] Tracked time: 00:22
[trace] Tracked time: 00:23
[trace] Tracked time: 00:24
[trace] Tracked time: 00:25
[trace] Tracked time: 00:26
[trace] Tracked time: 00:27
[trace] Tracked time: 00:28
[trace] Tracked time: 00:29
[trace] Tracked time: 00:30
[trace] Tracked time: 00:31
[trace] Tracked time: 00:32
[trace] Tracked time: 00:33
[trace] Tracked time: 00:34
[trace] Tracked time: 00:35
[trace] Tracked time: 00:36
[trace] Tracked time: 00:37
[trace] Tracked time: 00:38
[trace] Tracked time: 00:39
[trace] Tracked time: 00:40
[trace] Tracked time: 00:41
[trace] Tracked time: 00:42
[trace] Tracked time: 00:43
[trace] Tracked time: 00:44
[trace] Tracked time: 00:45
[trace] Tracked time: 00:46
[trace] Tracked time: 00:47
[trace] Tracked time: 00:48
[trace] Tracked time: 00:49
[trace] Tracked time: 00:50
[trace] Tracked time: 00:51
[trace] Tracked time: 00:52
[trace] Tracked time: 00:53
[trace] Tracked time: 00:54
[trace] Tracked time: 00:55
[trace] Tracked time: 00:56
[trace] Tracked time: 00:57
[trace] Tracked time: 00:58
[trace] Tracked time: 00:59
[trace] Tracked time: 01:00
[trace] Tracked time: 01:01
[trace] Tracked time: 01:02
[trace] Tracked time: 01:03
[trace] Tracked time: 01:04
[trace] Tracked time: 01:05
[trace] Tracked time: 01:06
[trace] Tracked time: 01:07
[trace] Tracked time: 01:08
[trace] Tracked time: 01:09
[trace] Tracked time: 01:10
[trace] Tracked time: 01:11
[trace] Tracked time: 01:12
[trace] Tracked time: 01:13
[trace] Tracked time: 01:14
[trace] Tracked time: 01:15
[trace] Tracked time: 01:16
[trace] Tracked time: 01:17
[trace] Tracked time: 01:18
[trace] Tracked time: 01:19
[trace] Tracked time: 01:20
[trace] Tracked time: 01:21
[trace] Tracked time: 01:22
[trace] Tracked time: 01:23
[trace] Tracked time: 01:24
[trace] Tracked time: 01:25
[trace] Tracked time: 01:26
[trace] Tracked time: 01:27
[trace] Tracked time: 01:28
[trace] Tracked time: 01:29
[trace] Tracked time: 01:30
[trace] Tracked time: 01:31
[trace] Tracked time: 01:32
[trace] Tracked time: 01:33
[trace] Tracked time: 01:34
[trace] Tracked time: 01:35
[trace] Tracked time: 01:36
[trace] Tracked time: 01:37
[trace] Tracked time: 01:38
[trace] Tracked time: 01:39
[trace] Tracked time: 01:40
[trace] Tracked time: 01:41
[trace] Tracked time: 01:42
[trace] Tracked time: 01:43
[trace] Tracked time: 01:44
[trace] Tracked time: 01:45
[trace] Tracked time: 01:46
[trace] Tracked time: 01:47
[trace] Tracked time: 01:48
[trace] Tracked time: 01:49
[trace] Tracked time: 01:50
[trace] Tracked time: 01:51
[trace] Tracked time: 01:52
[trace] Tracked time: 01:53
[trace] Tracked time: 01:54
[trace] Tracked time: 01:55
[trace] Tracked time: 01:56
[trace] Tracked time: 01:57
[trace] Tracked time: 01:58
[trace] Tracked time: 01:59
[trace] Tracked time: 02:00
[trace] Tracked time: 02:01
[trace] Tracked time: 02:02
[trace] Tracked time: 02:03
[trace] Tracked time: 02:04
[trace] Tracked time: 02:05
[trace] Tracked time: 02:06
[trace] Tracked time: 02:07
[trace] Tracked time: 02:08
[trace] Tracked time: 02:09
[trace] Tracked time: 02:10
[trace] Tracked time: 02:11
[trace] Tracked time: 02:12
[trace] Tracked time: 02:13
[trace] Tracked time: 02:14
[trace] Tracked time: 02:15
[trace] Tracked time: 02:16
[trace] Tracked time: 02:17
[trace] Tracked time: 02:18
[trace] Tracked time: 02:19
[trace] Tracked time: 02:20
[trace] Tracked time: 02:21
[trace] Tracked time: 02:22
[trace] Tracked time: 02:23
[trace] Tracked time: 02:24
[trace] Tracked time: 02:25
[trace] Tracked time: 02:26
[trace] Tracked time: 02:27
[trace] Tracked time: 02:28
[trace] Tracked time: 02:29
[trace] Tracked time: 02:30
[trace] Tracked time: 02:31
[trace] Maximum bounds have been reached; tracking stopped.

Related

Karma fails to capture Chrome v93 and times-out/gives up

We have just encountered a number of build failures in our CI environment (TeamCity/Windows) following a recent auto-update of Google Chrome to version 93. These failures all look like this:
[14:02:41] : [Step 3/12] > OUR_APP_PACKAGE#0.0.0 ci-test C:\BuildAgent\work\7084fa910d4648a4\OUR_APP_PACKAGE
[14:02:41] : [Step 3/12] > ng test --watch=false --sourceMap=false
[14:02:41] : [Step 3/12]
[14:03:00] : [Step 3/12] 01 09 2021 14:02:59.394:INFO [karma]: Karma v3.0.0 server started at http://0.0.0.0:9876/
[14:03:00] : [Step 3/12] 01 09 2021 14:02:59.779:INFO [launcher]: Launching browser Chrome with unlimited concurrency
[14:03:00] : [Step 3/12] 01 09 2021 14:02:59.793:INFO [launcher]: Starting browser Chrome
[14:04:00] : [Step 3/12] 01 09 2021 14:04:00.752:WARN [launcher]: Chrome have not captured in 60000 ms, killing.
[14:04:00] : [Step 3/12] 01 09 2021 14:04:00.820:INFO [launcher]: Trying to start Chrome again (1/2).
[14:05:01] : [Step 3/12] 01 09 2021 14:05:01.422:WARN [launcher]: Chrome have not captured in 60000 ms, killing.
[14:05:01] : [Step 3/12] 01 09 2021 14:05:01.461:INFO [launcher]: Trying to start Chrome again (2/2).
[14:06:01] : [Step 3/12] 01 09 2021 14:06:01.837:WARN [launcher]: Chrome have not captured in 60000 ms, killing.
[14:06:01] : [Step 3/12] 01 09 2021 14:06:01.879:ERROR [launcher]: Chrome failed 2 times (timeout). Giving up.
[14:06:02]W: [Step 3/12] npm ERR! code ELIFECYCLE
[14:06:02]W: [Step 3/12] npm ERR! errno 1
[14:06:02]W: [Step 3/12] npm ERR! OUR_APP_PACKAGE#0.0.0 ci-test: `ng test --watch=false --sourceMap=false`
[14:06:02]W: [Step 3/12] npm ERR! Exit status 1
[14:06:02]W: [Step 3/12] npm ERR!
[14:06:02]W: [Step 3/12] npm ERR! Failed at the OUR_APP_PACKAGE#0.0.0 ci-test script.
[14:06:02]W: [Step 3/12] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[14:06:02]W: [Step 3/12]
[14:06:02]W: [Step 3/12] npm ERR! A complete log of this run can be found in:
[14:06:02]W: [Step 3/12] npm ERR! C:\Users\teamcity\AppData\Roaming\npm-cache\_logs\2021-09-01T13_06_02_086Z-debug.log
[14:06:02]W: [Step 3/12] Process exited with code 1
[14:05:46]E: [Step 3/12] Process exited with code 1 (Step: "npm run ci-test" (test Angular app) (Command Line))
We have ruled-out any changes to our codebase causing this error. Repeating a CI build of a commit which previously built successfully (on that same build agent, with the exact same build config) has also now failed.
Subsequently we noticed that all failures were on a single build agent, but on the following day another agent also began to fail. The common factor amongst the build agents which exhibited the failure was that they had auto-updated to Google Chrome v93.
Whether or not there is a true bug in Google Chrome aside, we noticed that we could work around this problem by using ChromeHeadless instead of regular Chrome in our Karma config file. We made the following one-line change in our Karma config karma.conf.js and everything is working once again. I've included the whole file but really only the browsers: line is relevant.
We had no particular reason to be using full Chrome instead of Chrome Headless so that workaround is suitable for us indefinitely.
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '#angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('#angular-devkit/build-angular/plugins/karma')
],
client:{
clearContext: false
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, 'coverage'), reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['ChromeHeadless'], // Previously this was 'Chrome'
singleRun: false
});
Actually we started to explore the same issue and the thing that helped was to start use of custom launcher with couple of flags.
Before our karma.conf.js contained the following settings:
module.exports = function (config) {
config.set({
...
browsers: ['Chrome'],
...
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
},
});
}
Now it contains the following changes and tests are started to run again:
module.exports = function (config) {
config.set({
...
browsers: ['ChromeNoSandbox'],
...
customLaunchers: {
ChromeNoSandbox: {
base: 'Chrome',
flags: [
'--no-sandbox',
]
}
},
});
}

How to write log message with trace command in tcl?

So I have these sample code:
package require logger
set logger [logger::init someservice]
proc second {} {}
proc first {} {second}
${logger}::trace on
${logger}::trace add first second
puts "monitored procesured are: [${logger}::trace status]"
first
${logger}::delete
I got the following result after running the code :
[Wed Mar 14 11:44:11 EDT 2018] [someservice] [trace] 'enter {proc ::first
level 1 script {} caller {} procargs {}}'
[Wed Mar 14 11:44:11 EDT 2018] [someservice] [trace] 'enter {proc ::second
level 2 script {} caller ::first procargs {}}'
[Wed Mar 14 11:44:11 EDT 2018] [someservice] [trace] 'leave {proc ::second
level 2 script {} caller ::first status ok result {}}'
[Wed Mar 14 11:44:11 EDT 2018] [someservice] [trace] 'leave {proc ::first
level 1 script {} caller {} status ok result {}}'
I am trying to figure out how to use logger to write the result to a text file by setting up a filehandler. I tried to put "${::filehandler}" in the middle of the code, but it only printed out "first" in the text file. How should I type the command to print out the working process in another log file?
Consult the logger documentation, especially the section on logproc:
proc log2file {lvl txt} {
# handle output to file handle
}
set log [::logger::init example]
${log}::logproc trace log2file

Google cloud compute engine freeze

Today I found out that my vm instance in the google cloud had an issue.
I could not connect via gcloud compute ssh. The only solution was to shut the vm down and restart it.
I guess I found the right log file where the error happened.
/var/log/daemon.log
Nov 23 17:39:01 globo-de systemd[1]: Started Clean php session files.
Nov 23 18:09:01 globo-de systemd[1]: Starting Clean php session files...
Nov 23 18:09:03 globo-de systemd[1]: Started Clean php session files.
Nov 23 18:39:01 globo-de systemd[1]: Starting Clean php session files...
Nov 23 18:39:04 globo-de systemd[1]: Started Clean php session files.
Nov 23 18:56:49 globo-de google-ip-forwarding: WARNING Exception running ['ip', 'route', 'ls', 'table', 'local', 'type', 'local', 'scope', 'host', 'dev', 'eth0', 'proto', '66']. [Errno 12] Cannot allocate memory.
Nov 23 18:57:43 globo-de google-accounts: ERROR Exception calling the response handler. [Errno 12] Cannot allocate memory.#012Traceback (most recent call last):#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/metadata_watcher.py", line 196, in WatchMetadata#012 handler(response)#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/accounts_daemon.py", line 259, in HandleAccounts#012 self.oslogin.UpdateOsLogin(enable=False)#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 79, in UpdateOsLogin#012 status = self._GetStatus()#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 60, in _GetStatus#012 retcode = self._RunOsLoginControl('status')#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 47, in _RunOsLoginControl#012 return subprocess.call([constants.OSLOGIN_CONTROL_SCRIPT, action])#012 File "/usr/lib/python2.7/subprocess.py", line 168, in call#012 return Popen(*popenargs, **kwargs).wait()#012 File "/usr/lib/python2.7/subprocess.py", line 390, in __init__#012 errread, errwrite)#012 File "/usr/lib/python2.7/subprocess.py", line 916, in _execute_child#012 self.pid = os.fork()#012OSError: [Errno 12] Cannot allocate memory
Nov 23 18:58:02 globo-de google-ip-forwarding: WARNING Exception running ['ip', 'route', 'ls', 'table', 'local', 'type', 'local', 'scope', 'host', 'dev', 'eth0', 'proto', '66']. [Errno 12] Cannot allocate memory.
Nov 23 18:59:35 globo-de google-ip-forwarding: WARNING Exception running ['ip', 'route', 'ls', 'table', 'local', 'type', 'local', 'scope', 'host', 'dev', 'eth0', 'proto', '66']. [Errno 12] Cannot allocate memory.
Nov 23 18:59:54 globo-de google-accounts: ERROR Exception calling the response handler. [Errno 12] Cannot allocate memory.#012Traceback (most recent call last):#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/metadata_watcher.py", line 196, in WatchMetadata#012 handler(response)#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/accounts_daemon.py", line 259, in HandleAccounts#012 self.oslogin.UpdateOsLogin(enable=False)#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 79, in UpdateOsLogin#012 status = self._GetStatus()#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 60, in _GetStatus#012 retcode = self._RunOsLoginControl('status')#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 47, in _RunOsLoginControl#012 return subprocess.call([constants.OSLOGIN_CONTROL_SCRIPT, action])#012 File "/usr/lib/python2.7/subprocess.py", line 168, in call#012 return Popen(*popenargs, **kwargs).wait()#012 File "/usr/lib/python2.7/subprocess.py", line 390, in __init__#012 errread, errwrite)#012 File "/usr/lib/python2.7/subprocess.py", line 916, in _execute_child#012 self.pid = os.fork()#012OSError: [Errno 12] Cannot allocate memory
Nov 23 19:03:53 globo-de google-ip-forwarding: WARNING Exception running ['ip', 'route', 'ls', 'table', 'local', 'type', 'local', 'scope', 'host', 'dev', 'eth0', 'proto', '66']. [Errno 12] Cannot allocate memory.
Nov 23 19:07:52 globo-de google-accounts: ERROR Exception calling the response handler. [Errno 12] Cannot allocate memory.#012Traceback (most recent call last):#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/metadata_watcher.py", line 196, in WatchMetadata#012 handler(response)#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/accounts_daemon.py", line 259, in HandleAccounts#012 self.oslogin.UpdateOsLogin(enable=False)#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 79, in UpdateOsLogin#012 status = self._GetStatus()#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 60, in _GetStatus#012 retcode = self._RunOsLoginControl('status')#012 File "/usr/lib/python2.7/dist-packages/google_compute_engine/accounts/oslogin_utils.py", line 47, in _RunOsLoginControl#012 return subprocess.call([constants.OSLOGIN_CONTROL_SCRIPT, action])#012 File "/usr/lib/python2.7/subprocess.py", line 168, in call#012 return Popen(*popenargs, **kwargs).wait()#012 File "/usr/lib/python2.7/subprocess.py", line 390, in __init__#012 errread, errwrite)#012 File "/usr/lib/python2.7/subprocess.py", line 916, in _execute_child#012 self.pid = os.fork()#012OSError: [Errno 12] Cannot allocate memory
Nov 23 19:09:37 globo-de google-ip-forwarding: WARNING Exception running ['ip', 'route', 'ls', 'table', 'local', 'type', 'local', 'scope', 'host', 'dev', 'eth0', 'proto', '66']. [Errno 12] Cannot allocate memory.
Nov 23 19:11:32 globo-de systemd[1]: phpsessionclean.service: Failed to fork: Cannot allocate memory
Nov 23 19:11:56 globo-de systemd[1]: phpsessionclean.service: Failed to run 'start' task: Cannot allocate memory
Nov 23 19:12:24 globo-de systemd[1]: Failed to start Clean php session files.
Nov 23 19:12:50 globo-de systemd[1]: phpsessionclean.service: Unit entered failed state.
Nov 23 19:13:37 globo-de systemd[1]: phpsessionclean.service: Failed with result 'resources'.
Nov 23 19:14:58 globo-de systemd[1]: apt-daily.service: Failed to fork: Cannot allocate memory
Nov 23 19:16:13 globo-de systemd[1]: apt-daily.service: Failed to run 'start' task: Cannot allocate memory
What can I do to prevent that from happening again?
I guess the problem was that the google-cloud-compute engine vm had no swap file. So I created one with the following commands I found on google.
sudo dd if=/dev/zero of=/var/swap bs=2048 count=524288
sudo chmod 600 /var/swap
sudo mkswap /var/swap
sudo swapon /var/swap
Then I added the following line to /etc/fstab to make it permanent.
/var/swap none swap sw 0 0
Another solution is to avoid swapping setting vm.swappiness to 0.
# sysctl -w vm.swappiness=0
However, it sounds me more like an OS image issue than google clouds.

artillery.io JSON value capture not working

Using Artillery.io 1.6.0-10, I call an api that returns a JSON and try to capture one of the values for later use in the flow, however the capture doesn't seem to be working. Here is the simplified code:
get_ddg.yml
config:
target: "https://api.duckduckgo.com"
phases:
- duration: 3
arrivalCount: 1
scenarios:
- name: "Get search"
flow:
- get:
url: "/?q=DuckDuckGo&format=json"
capture:
json: "$.Abstract"
as: "abstract"
- log: "Abstract: {{ $abstract }}"
When I run artillery the value is empty:
$ artillery run get_ddg.yml
Started phase 0, duration: 3s # 10:28:34(+0200) 2017-10-25
⠋ Abstract: <----- EMPTY! NO VALUE FOR $abstract
Report # 10:28:37(+0200) 2017-10-25
Scenarios launched: 1
Scenarios completed: 1
Requests completed: 1
Concurrent users: 1
RPS sent: 2.08
Request latency:
min: 311.9
max: 311.9
median: 311.9
p95: NaN
p99: NaN
Scenario duration:
min: 349.5
max: 349.5
median: 349.5
p95: NaN
p99: NaN
Codes:
200: 1
Any help is much appreciated.
Found the solution. The problem is how the variable is read after capture. The correct way to call the variable it is not using the '$':
- log: "Abstract: {{ abstract }}"

Unable to use JMockit with OpenJDK 1.7

While trying to use JMockit (1.21) with JUnit (4.8) test cases I ran into issue with OpenJDK (1.7). I'm using Eclipse. After searching on SO, I found the solution about adding '-javaagent:path/to/JMockit/jar' argument to JVM and putting JMockit dependency before JUnit in maven. But after adding that argument, my test won't run and instead I get following error. Did anyone have this issue and how did you solve it? It works if I use OracleJDK but I'm looking for solution where it runs with OpenJDK.
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000051cfbbe8, pid=9268, tid=2272
#
# JRE version: OpenJDK Runtime Environment (7.0) (build 1.7.0-45-asmurthy_2014_01_10_19_46-b00)
# Java VM: Dynamic Code Evolution 64-Bit Server VM (24.45-b06 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# V [jvm.dll+0x6bbe8]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
#
--------------- T H R E A D ---------------
Current thread (0x000000000270c000): VMThread [stack: 0x00000000074e0000,0x00000000075e0000] [id=2272]
siginfo: ExceptionCode=0xc0000005, reading address 0x0000000000000000
Registers:
RAX=0x0000000000000000, RBX=0x0000000000000000, RCX=0x0000000000000000, RDX=0x00000007fae04720
RSP=0x00000000075df190, RBP=0x00000000523a16d8, RSI=0x0000000002abe2b0, RDI=0x00000000523a16e0
R8 =0x0000000000000000, R9 =0x0000000000000100, R10=0x0000000000041999, R11=0x0000000008eab1f0
R12=0x000000000270c000, R13=0x00000007fb208040, R14=0x0000000000000001, R15=0x00000000000003d8
RIP=0x0000000051cfbbe8, EFLAGS=0x0000000000010206
Top of Stack: (sp=0x00000000075df190)
0x00000000075df190: 00000007fb208050 0000000002abe200
0x00000000075df1a0: 00000007fb208040 000000000270c000
0x00000000075df1b0: 00000000523a16e0 0000000051e0ecbc
0x00000000075df1c0: 0000000000000000 00000000523a16d8
0x00000000075df1d0: 0000000002abe2b0 000000000270c000
0x00000000075df1e0: 00000000521ea7b8 0000000052450100
0x00000000075df1f0: 0000000000000000 00000000521ea7a0
0x00000000075df200: 0000000000001000 00000000075df1e0
0x00000000075df210: 0000000000000100 0000000000000000
0x00000000075df220: 00000000073158d8 00000000000003d8
0x00000000075df230: 00000000073158d8 0000000002701ac0
0x00000000075df240: 00000000073154f0 0000000051e74dc7
0x00000000075df250: 00000000026c3de0 0000000000000001
0x00000000075df260: 0000000002abe2b0 0000000007315500
0x00000000075df270: 0000000007315500 00000000073154f0
0x00000000075df280: 0000000002701ac0 0000000051e74072
Instructions: (pc=0x0000000051cfbbe8)
0x0000000051cfbbc8: cc cc cc cc cc cc cc cc 48 89 5c 24 08 57 48 83
0x0000000051cfbbd8: ec 20 48 8b 05 17 20 69 00 48 8b 0d c0 e5 68 00
0x0000000051cfbbe8: 48 63 18 e8 60 c3 fa ff 33 ff 48 85 db 7e 37 66
0x0000000051cfbbf8: 0f 1f 84 00 00 00 00 00 48 8b 05 f1 1f 69 00 48
Register to memory mapping:
RAX=0x0000000000000000 is an unknown value
RBX=0x0000000000000000 is an unknown value
RCX=0x0000000000000000 is an unknown value
RDX=0x00000007fae04720 is an oop
{instance class}
- klass: {other class}
RSP=0x00000000075df190 is an unknown value
RBP=0x00000000523a16d8 is an unknown value
RSI=0x0000000002abe2b0 is pointing into the stack for thread: 0x00000000026c7000
RDI=0x00000000523a16e0 is an unknown value
R8 =0x0000000000000000 is an unknown value
R9 =0x0000000000000100 is an unknown value
R10=0x0000000000041999 is an unknown value
R11=0x0000000008eab1f0 is an unknown value
R12=0x000000000270c000 is an unknown value
R13=0x00000007fb208040 is an oop
{instance class}
- klass: {other class}
R14=0x0000000000000001 is an unknown value
R15=0x00000000000003d8 is an unknown value
Stack: [0x00000000074e0000,0x00000000075e0000], sp=0x00000000075df190, free space=1020k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [jvm.dll+0x6bbe8]
VM_Operation (0x0000000002abe2b0): RedefineClasses, mode: safepoint, requested by thread 0x00000000026c7000
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x000000000739c800 JavaThread "Attach Listener" daemon [_thread_blocked, id=6668, stack(0x0000000007c60000,0x0000000007d60000)]
0x000000000739b000 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=5620, stack(0x0000000007aa0000,0x0000000007ba0000)]
0x0000000007379800 JavaThread "Finalizer" daemon [_thread_blocked, id=9832, stack(0x00000000078c0000,0x00000000079c0000)]
0x0000000007370000 JavaThread "Reference Handler" daemon [_thread_blocked, id=7516, stack(0x0000000007680000,0x0000000007780000)]
0x00000000026c7000 JavaThread "main" [_thread_blocked, id=6580, stack(0x00000000029c0000,0x0000000002ac0000)]
Other Threads:
=>0x000000000270c000 VMThread [stack: 0x00000000074e0000,0x00000000075e0000] [id=2272]
VM state:at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: ([mutex/lock_event])
[0x00000000026c3e60] Threads_lock - owner thread: 0x000000000270c000
[0x00000000026c4360] Heap_lock - owner thread: 0x00000000026c7000
[0x00000000026c4b60] RedefineClasses_lock - owner thread: 0x00000000026c7000
Heap
def new generation total 118016K, used 21035K [0x000000067ae00000, 0x0000000682e00000, 0x00000006fae00000)
eden space 104960K, 20% used [0x000000067ae00000, 0x000000067c28af18, 0x0000000681480000)
from space 13056K, 0% used [0x0000000681480000, 0x0000000681480000, 0x0000000682140000)
to space 13056K, 0% used [0x0000000682140000, 0x0000000682140000, 0x0000000682e00000)
tenured generation total 262144K, used 0K [0x00000006fae00000, 0x000000070ae00000, 0x00000007fae00000)
the space 262144K, 0% used [0x00000006fae00000, 0x00000006fae00000, 0x00000006fae00200, 0x000000070ae00000)
compacting perm gen total 21248K, used 4129K [0x00000007fae00000, 0x00000007fc2c0000, 0x0000000800000000)
the space 21248K, 19% used [0x00000007fae00000, 0x00000007fb208478, 0x00000007fb208600, 0x00000007fc2c0000)
No shared spaces configured.
Card table byte_map: [0x0000000005e60000,0x0000000006a90000] byte_map_base: 0x0000000002a89000
Polling page: 0x0000000000150000
Code Cache [0x0000000002da0000, 0x0000000003010000, 0x0000000005da0000)
total_blobs=187 nmethods=0 adapters=156 free_code_cache=48761Kb largest_free_block=49932032
Compilation events (0 events):
No events
GC Heap History (0 events):
No events
Deoptimization events (0 events):
No events
Internal exceptions (10 events):
Event: 1.210 Thread 0x00000000026c7000 Threw 0x000000067c036fa0 at C:\openjdk\jdk7u\hotspot\src\share\vm\interpreter\interpreterRuntime.cpp:347
Event: 1.211 Thread 0x00000000026c7000 Threw 0x000000067c03ae78 at C:\openjdk\jdk7u\hotspot\src\share\vm\prims\jvm.cpp:1244
Event: 1.212 Thread 0x00000000026c7000 Threw 0x000000067c045f10 at C:\openjdk\jdk7u\hotspot\src\share\vm\prims\jvm.cpp:1244
Event: 1.213 Thread 0x00000000026c7000 Threw 0x000000067c057398 at C:\openjdk\jdk7u\hotspot\src\share\vm\prims\jvm.cpp:1244
Event: 1.214 Thread 0x00000000026c7000 Threw 0x000000067c066510 at C:\openjdk\jdk7u\hotspot\src\share\vm\prims\jvm.cpp:1244
Event: 1.215 Thread 0x00000000026c7000 Threw 0x000000067c072ac0 at C:\openjdk\jdk7u\hotspot\src\share\vm\prims\jvm.cpp:1244
Event: 1.216 Thread 0x00000000026c7000 Threw 0x000000067c084678 at C:\openjdk\jdk7u\hotspot\src\share\vm\prims\jvm.cpp:1244
Event: 1.217 Thread 0x00000000026c7000 Threw 0x000000067c08c7b0 at C:\openjdk\jdk7u\hotspot\src\share\vm\prims\jvm.cpp:1244
Event: 1.218 Thread 0x00000000026c7000 Threw 0x000000067c0934a8 at C:\openjdk\jdk7u\hotspot\src\share\vm\prims\jvm.cpp:1244
Event: 1.218 Thread 0x00000000026c7000 Threw 0x000000067c09cac8 at C:\openjdk\jdk7u\hotspot\src\share\vm\prims\jvm.cpp:1244
Events (10 events):
Event: 1.215 loading class 0x0000000008956520 done
Event: 1.216 loading class 0x0000000008959de0
Event: 1.216 loading class 0x0000000008959de0 done
Event: 1.217 loading class 0x0000000008ea91d0
Event: 1.217 loading class 0x0000000008ea91d0 done
Event: 1.218 loading class 0x0000000008d643e0
Event: 1.218 loading class 0x0000000008d643e0 done
Event: 1.218 loading class 0x0000000008958d20
Event: 1.218 loading class 0x0000000008958d20 done
Event: 1.219 Executing VM operation: RedefineClasses
Dynamic libraries:
0x000000013f7c0000 - 0x000000013f7f1000 S:\OpenJDK\bin\javaw.exe
0x0000000076ef0000 - 0x0000000077099000 C:\WINDOWS\SYSTEM32\ntdll.dll
0x0000000076cb0000 - 0x0000000076dcf000 C:\WINDOWS\system32\kernel32.dll
0x000007fefcde0000 - 0x000007fefce4b000 C:\WINDOWS\system32\KERNELBASE.dll
0x0000000074990000 - 0x0000000074a19000 C:\WINDOWS\System32\SYSFER.DLL
0x000007feff0f0000 - 0x000007feff1cb000 C:\WINDOWS\system32\ADVAPI32.dll
0x000007fefed40000 - 0x000007fefeddf000 C:\WINDOWS\system32\msvcrt.dll
0x000007fefe660000 - 0x000007fefe67f000 C:\WINDOWS\SYSTEM32\sechost.dll
0x000007fefefc0000 - 0x000007feff0ed000 C:\WINDOWS\system32\RPCRT4.dll
0x0000000076df0000 - 0x0000000076eea000 C:\WINDOWS\system32\USER32.dll
0x000007fefe270000 - 0x000007fefe2d7000 C:\WINDOWS\system32\GDI32.dll
0x000007fefe360000 - 0x000007fefe36e000 C:\WINDOWS\system32\LPK.dll
0x000007fefe370000 - 0x000007fefe43a000 C:\WINDOWS\system32\USP10.dll
0x000007fefb460000 - 0x000007fefb654000 C:\WINDOWS\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.18837_none_fa3b1e3d17594757\COMCTL32.dll
0x000007fefee30000 - 0x000007fefeea1000 C:\WINDOWS\system32\SHLWAPI.dll
0x000007fefe630000 - 0x000007fefe65e000 C:\WINDOWS\system32\IMM32.DLL
0x000007fefeeb0000 - 0x000007fefefb9000 C:\WINDOWS\system32\MSCTF.dll
0x0000000052420000 - 0x00000000524f2000 S:\OpenJDK\jre\bin\msvcr100.dll
0x0000000051c90000 - 0x000000005241e000 S:\OpenJDK\jre\bin\server\jvm.dll
0x000007fef82b0000 - 0x000007fef82b9000 C:\WINDOWS\system32\WSOCK32.dll
0x000007fefede0000 - 0x000007fefee2d000 C:\WINDOWS\system32\WS2_32.dll
0x000007feff1d0000 - 0x000007feff1d8000 C:\WINDOWS\system32\NSI.dll
0x000007fefaca0000 - 0x000007fefacdb000 C:\WINDOWS\system32\WINMM.dll
0x00000000770c0000 - 0x00000000770c7000 C:\WINDOWS\system32\PSAPI.DLL
0x000007feece20000 - 0x000007feece2f000 S:\OpenJDK\jre\bin\verify.dll
0x000007fee0320000 - 0x000007fee0348000 S:\OpenJDK\jre\bin\java.dll
0x000007fee6ee0000 - 0x000007fee6f03000 S:\OpenJDK\jre\bin\instrument.dll
0x000007fee06e0000 - 0x000007fee06f5000 S:\OpenJDK\jre\bin\zip.dll
0x000007fef1f90000 - 0x000007fef20b5000 C:\WINDOWS\system32\dbghelp.dll
VM Arguments:
jvm_args: -javaagent:S:\.m2\org\jmockit\jmockit\1.21\jmockit-1.21.jar -Dfile.encoding=ISO-8859-1
java_command: org.eclipse.jdt.internal.junit.runner.RemoteTestRunner -version 3 -port 61294 -testLoaderClass org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader -loaderpluginname org.eclipse.jdt.junit4.runtime -classNames com.examples.JMockitTest
java_command: org.eclipse.jdt.internal.junit.runner.RemoteTestRunner -version 3 -port 61294 -testLoaderClass org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader -loaderpluginname org.eclipse.jdt.junit4.runtime -classNames com.examples.JMockitTest
Launcher Type: SUN_STANDARD
Environment Variables:
JRE_HOME=C:\Program Files (x86)\IBM\RationalSDLC\Common\Java5.0\jre
PATH=C:\Python27\;C:\Python27\Scripts;C:\Program Files (x86)\IBM\RationalSDLC\Clearquest\cqcli\bin;C:\PERL51001\Perl\site\bin;C:\PERL51001\Perl\bin;C:\Program Files (x86)\RSA SecurID Token Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files (x86)\Microsoft Application Virtualization Client;C:\Program Files (x86)\java\jre6\bin\;C:\Perl64\bin;C:\Program Files (x86)\Perforce;C:\Program Files (x86)\IBM\RationalSDLC\ClearCase\bin;C:\Program Files (x86)\IBM\RationalSDLC\common;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\TortoiseGit\bin;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\nodejs\
Thanks