I am using Springboot 2.3.1.RELEASE and chaos monkey its working fine for latencyActive and exceptionsActive.
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>chaos-monkey-spring-boot</artifactId>
<version>2.2.0</version>
</dependency>
Following two assaults not working
Kill application
chaos.monkey.assaults.killApplicationActive=true
chaos.monkey.assaults.level=3
Memory
chaos.monkey.assaults.memoryActive=true
chaos.monkey.assaults.memoryMillisecondsHoldFilledMemory=90000
chaos.monkey.assaults.memoryMillisecondsWaitNextIncrease=1000
chaos.monkey.assaults.memoryFillIncrementFraction=90.15
chaos.monkey.assaults.memoryFillTargetFraction=90.25
App kill and memory kill attacks need the attribute runtimeAssaultCronExpression set to a valid cron expression like " * * * * * * ". By default it is set to "OFF"
See documentation: https://codecentric.github.io/chaos-monkey-spring-boot/2.2.0/#_appkiller_assault
To Kill an application manually follow the below step:
1) Create the assault by:
POST: https://{{server-address}}/{{app-name}}/actuator/chaosmonkey/assaults
{
"level": 1,
"deterministic": false,
"latencyActive": false,
"exceptionsActive": false,
"killApplicationActive": true,
"memoryActive": false,
"cpuActive": false }
2) Run the created assault by:
POST: https://{{server-address}}/{{app-name}}/actuator/chaosmonkey/assaults/runtime/attack
Use property value for "chaos.monkey.assaults.runtime.scope.assault.cron.expression" as cron expression like */1 * * * * ? or any valid cron expression, to enable chaos monkey runtime assaults on a schedule.
Use property value as OFF otherwise(also default value)
links:
https://codecentric.github.io/chaos-monkey-spring-boot/2.1.0/#configuration
https://www.programmersought.com/article/11861551911/
LatencyActive and ExceptionsActive assaults are low impact assault(Request type), whereas KillApp and Memory are high impact assaults(Runtime assault). So Request type assault can be triggered just by loading them whereas Runtime assault requires an additional step after loading them.
Trigger this Http endpoint and that should execute the assault:
/chaosmonkey/assaults/runtime/attack
Related
I programmatically write the logs from the function using such code:
import {Logging} from '#google-cloud/logging';
const logging = new Logging();
const log = logging.log('log-name');
const metadata = {
type: 'cloud_function',
labels: {
function_name: process.env.FUNCTION_NAME,
project: process.env.GCLOUD_PROJECT,
region: process.env.FUNCTION_REGION
},
};
log.write(
log.entry(metadata, "some message")
);
Later in Logs Explorer I get the log message where labels.region is us1 whereas standard logs that GCP adds, e.g. "Function execution started", contains us-central1 value.
Should not they be the same? Maybe I missed something or if it was done intentionally what is the reason behind it?
process.env.FUNCTION_REGION is supported only in Node 8 runtime. In newer runtimes it was deprecated. More info in documentation.
If your function requires one of the environment variables from an older runtime, you can set the variable when deploying your function.
I am going to create end to end(e2e) test using protractor with jasmine and angular 6. I have written some test cases almost 10 cases. That's all working fine, but always some cases become fails. And its failed because of jasmine timeout. I have configure timeout value like below. But I am not getting consistant result. sometimes a test cases is success but at next run it will goes to success or fail. I have searched on google but I have not found any useful solution.
I have defined some common properties for wait
waitForElement(element: ElementFinder){
browser.waitForAngularEnabled(false);
browser.wait(() => element.isPresent(), 100000, 'timeout: ');
}
waitForUrl(url: string){
browser.wait(() => protractor.ExpectedConditions.urlContains(url), 100000, 'timeout')
}
And protractor.conf.js file I have defined that
jasmineNodeOpts: {
showColors: true,
includeStackTrace: true,
defaultTimeoutInterval: 20000,
print: function () {
}
}
I am getting below error
- Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
- Failed: stale element reference: element is not attached to the page document
(Session info: chrome=76.0.3809.100)
(Driver info: chromedriver=76.0.3809.12 (220b19a666554bdcac56dff9ffd44c300842c933-refs/branch-heads/3809#{#83}),platform=Windows NT 10.0.17134 x86_64)
I have got the solution:
I have configured waiting timeout 100000 ms for individual element find where whole script timeout was 20000 ms. So I have follow below process:
Keep full spec timeout below than sum of all elements find timeouts. I have configured defaultTimeoutInterval at jasmineNodeOpts greater than sum of value for all test cases timeout. And then add a large value to allScriptsTimeout: 2000000 inside of export.config. Its resolved my problem.
NB: I gave this answer because I think it may help others who will face this kind of problem.
Not sure if this is purely a Spring Boot issue, purely a Groovy issue, or a problem arising from using Groovy to build a Spring Boot app. I have a Spring Boot background task that -- in production -- I want running once an hour:
#Component
class MyTask {
#Scheduled(cron = "${tasks.mytask.cron}")
void doSomething() {
// blah whatever
}
}
In my application.yml file I have:
logging:
config: 'logback.groovy'
server:
port: 9200
error:
whitelabel:
enabled: false
spring:
cache:
type: none
myapp:
detailsMode: ${detailsMode:Terse}
verification: 5
tasks:
mytask:
cron: '0 0/1 * 1/1 * ? *'
However for local development I want to be able to change the cron expression (for testing, etc.). When I go to compile this I get:
Expected '$tasks.mytask.cron' to be an inline constant of type java.lang.String in #org.springframework.scheduling.annotation.Scheduled
# line 31, column 23.
#Scheduled(cron = "${tasks.mytask.cron}")
Any ideas what I need to do to fix this? I need an externally-configurable value like tasks.mytask.cron that I can define in my app properties/YAML.
myapp:
detailsMode: ${detailsMode:Terse}
verification: 5
tasks:
mytask:
cron: '0 0/1 * 1/1 * ?'
or
#Scheduled(cron = '${myapp.tasks.mytask.cron}')
also notice that your cron format is incorrect
I do have an argument with my Spring Boot powered web application. I'm trying to override a #Scheduled cron expression from the command line, but spring responds with a java.lang.IllegalStateException.
Initialization of bean failed;
nested exception is java.lang.IllegalStateException:
Encountered invalid #Scheduled method 'work':
Cron expression must consist of 6 fields (found 1 in "0")
I have a Spring Component with a Scheduled Annotation:
#Scheduled(cron="${myapp.cron}")
public void work() {
...
}
There is an application.properties file like this:
myapp.cron=0 0 1 * * *
I'm bundling the application with maven to a jar file. The application runs on an ubuntu machine with Java 8 as an init task (/etc/init/myapp.conf).
description "My app"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
setuid <USER>
setgid <GROUP>
script
java -Xms2G -Xmx2G -jar /opt/myapp.jar \
--server.port=4014 \
--server.address=127.0.0.1
--logging.file=/opt/myapp.log \
--logging.level.root=INFO
end script
Until this point everything is fine. Adding the following line gives the above mention exception.
--myapp.cron=0 0 8 * * *
Any ideas? What's wrong?
Cheers,
Kai
Kai,
You're passing in the 0 0 8 * * * as command line parameter in order to get it in the Spring environment. However, your app only gets the first 0 as variable value, hence the exception about the required 6 parts. Surround the value with quotes instead:
--myapp.cron="0 0 8 * * *"
create a xyz.properties file under src/main/resouce folder.
cron.open.status.mgr.schedule=10 15 0 15 * ?
and do something like below
#Component
public class OpenStatusManagerScheduler {
#Scheduled(cron = "${open.status.mgr.schedule}")
public void scheduleStatusTaskWithCronExpression() {}
}
Supposed I scheduled a job with rufus-scheduler like below:
scheduler.cron '* * * * * UTC' do |job|
...
end
I can retrieve some useful info from 'job' variable. For example, next_time shows when the next run is scheduled at. I am wondering if a similar value is available for "current_time". Reason: for various reasons (threads, system load, etc) a job could be executed with a small amount of delay. I want to know the exact time the job is meant to have started. If I retrieve system time by Time.new, that will not be exact.
Is there a way? I tried awesome_print the job variable. It seems the value I am looking for is not available.
jruby-1.7.19 :017 > #<Rufus::Scheduler::CronJob:0x3951b84e #unscheduled_at=nil, #first_at=nil, #opts={}, #last_time=2016-07-28 01:35:00 +0800, #tags=[], #mean_work_time=0.0, #callable=#<Proc:0x2ee23f1d#(irb):14>, #last_at=nil, #count=1, #scheduled_at=2016-07-28 01:34:09 +0800, #handler=#<Proc:0x2ee23f1d#(irb):14>, #paused_at=nil, #local_mutex=#<Mutex:0x79da0f7>, #locals={}, #times=nil, #scheduler=#<Rufus::Scheduler:0x7dc7d255 #mutexes={}, #scheduler_lock=#<Rufus::Scheduler::NullLock:0x49c20af6>, #paused=false, #opts={}, #work_queue=#<Queue:0x625dc24e>, #jobs=#<Rufus::Scheduler::JobArray:0x797fc155 #mutex=#<Mutex:0x501b94b9>, #array=[#<Rufus::Scheduler::CronJob:0x3951b84e ...>]>, #trigger_lock=#<Rufus::Scheduler::NullLock:0x42c126c5>, #started_at=2016-07-28 01:33:36 +0800, #thread_key="rufus_scheduler_2068", #stderr=#<IO:fd 2>, #max_work_threads=28, #frequency=0.3, #thread=#<Thread:0x16d871c0 sleep>>, #cron_line=#<Rufus::Scheduler::CronLine:0x6156f1b0 #seconds=[0], #weekdays=nil, #hours=nil, #timezone="UTC", #days=nil, #minutes=nil, #original="* * * * * UTC", #months=nil, #monthdays=nil>, #last_work_time=0.0, #id="cron_1469640849.047_961656910", #original="* * * * * UTC", #next_time=2016-07-27 17:36:00 +0000>
Added a Job#previous_time
https://github.com/jmettraux/rufus-scheduler/commit/43f1016859a43ea7f138404c1e5d864048f24959
scheduler.every('10s') do |job|
puts "job scheduled for #{job.previous_time} triggered at #{Time.now}"
puts "next time will be around #{job.next_time}"
puts "."
end
A job's #next_time is supposed to hold the trigger time until the #post_trigger hook gets called.