<commit_before>#!/usr/bin/env perl
#########################################################
## CronTab Tests
## We submit a job that is set to run 4 times every 2
## minutes. We keep track of various information about the
## job so that we know the following:
##	1) The jobs are submitted with the proper preptime
##	2) The jobs are only running every 2 minutes
##	3) The JobRunCount properly reflects how many times we ran
## 	4) The job runs when it was suppose to
##
## When a job finishes but gets rescheduled, we will get
## an eviction notice. If the job ever goes on hold,
## then something went wrong and the test fails
#########################################################
use CondorTest;
use POSIX;

##
## Universe
## 
my $universe = ($ARGV[0] ? $ARGV[0] : "vanilla");

##
## Test Information
##
$testname = "CronTab Testing - $universe";
$base_name = 'job_core_crontab';
$base_cmd = $base_name.".cmd";

##
## Counter for the number of times our job ran
##
my $run_ctr = 0;

##
## The MAX number of times our job should run
##
my $max_run_ctr = 2;

##
## The sleep time of the job
##
my $SLEEP_TIME = 20;

##
## The preptime that the job gets to be sent over to the starter
##
my $PREP_TIME = 90;

##
## When a job begins execution, the schedd should have calculated
## the time that the job should actually start running over on the
## Starter
##
my $DEFERRAL_TIME;
my $LAST_DEFERRAL_TIME;

##
## This is the difference in seconds that one job should be scheduled
## for after the previous. If this fails then we know something
## is possibly with the 
## CronMinute = */3
##
my $DEFERRAL_DIFFERENCE = 180; # seconds

##
## submitted
## A nice message to let us know our job was submitted
##
$submitted = sub {
	%info = @_;
	$cluster = $info{"cluster"};
	$job = $info{"job"};
	
	print "Good - Job $cluster.$job was submitted!\n";
};	

##
## executed
## The job has begun to execute over on the starter
## We keep a counter to know how many times that it started
##
$executed = sub {
	%info = @_;
	$cluster = $info{"cluster"};
	$job = $info{"job"};
	
	##
	## When a job with a Cron schedule begins execution it will
	## have a DeferralTime in its job ad. We need to get it out and save
	## it here because by the time we get the eviction notice the schedd
	## might have overwritten it
	##
	my @result;
	my $q_cmd = "condor_q $cluster.$job -format %d DeferralTime";
	if ( ! CondorTest::runCondorTool($q_cmd, \@result, 3) ) {
		print "ERROR: Unable to get DeferralTime due to Condor Tool Failure<$q_cmd>\n";
	    exit(1);
	}
	$DEFERRAL_TIME = "@result";	
	##
	## We're screwed if we can't get out the time
	##
	if ( $DEFERRAL_TIME < 0 || !$DEFERRAL_TIME ) {
		print "Bad - Unable to get DeferralTime for Job $cluster.$job!\n";
		exit(1);
	}
	
	
	##
	## Make sure that we haven't run more then we were suppose to
	##
	if ( ++$run_ctr > $max_run_ctr ) {
		print "Bad - Job $cluster.$job has been executed $run_ctr times!\n";
		exit(1);
	##
	## It's good that we ran, so print a message 
	##
	} else {
		##
		## I'm a stickler for nice messages
		##
		my $suffix = "th";
		if ( $run_ctr == 1 ) {
			$suffix = "st";
		} elsif ( $run_ctr == 2 ) {
			$suffix = "nd";
		} elsif ( $run_ctr == 3 ) {
			$suffix = "rd";
		}
		print "Good - Job $cluster.$job began execution for the ".
			  "$run_ctr$suffix time.\n";<commit_msg>remove the test job on error<commit_after>#!/usr/bin/env perl
#########################################################
## CronTab Tests
## We submit a job that is set to run 4 times every 2
## minutes. We keep track of various information about the
## job so that we know the following:
##	1) The jobs are submitted with the proper preptime
##	2) The jobs are only running every 2 minutes
##	3) The JobRunCount properly reflects how many times we ran
## 	4) The job runs when it was suppose to
##
## When a job finishes but gets rescheduled, we will get
## an eviction notice. If the job ever goes on hold,
## then something went wrong and the test fails
#########################################################
use CondorTest;
use POSIX;

##
## Universe
## 
my $universe = ($ARGV[0] ? $ARGV[0] : "vanilla");

##
## Test Information
##
$testname = "CronTab Testing - $universe";
$base_name = 'job_core_crontab';
$base_cmd = $base_name.".cmd";

##
## Counter for the number of times our job ran
##
my $run_ctr = 0;

##
## The MAX number of times our job should run
##
my $max_run_ctr = 2;

##
## The sleep time of the job
##
my $SLEEP_TIME = 20;

##
## The preptime that the job gets to be sent over to the starter
##
my $PREP_TIME = 90;

##
## When a job begins execution, the schedd should have calculated
## the time that the job should actually start running over on the
## Starter
##
my $DEFERRAL_TIME;
my $LAST_DEFERRAL_TIME;

##
## This is the difference in seconds that one job should be scheduled
## for after the previous. If this fails then we know something
## is possibly with the 
## CronMinute = */3
##
my $DEFERRAL_DIFFERENCE = 180; # seconds

##
## submitted
## A nice message to let us know our job was submitted
##
$submitted = sub {
	%info = @_;
	$cluster = $info{"cluster"};
	$job = $info{"job"};
	
	print "Good - Job $cluster.$job was submitted!\n";
};	

##
## executed
## The job has begun to execute over on the starter
## We keep a counter to know how many times that it started
##
$executed = sub {
	%info = @_;
	$cluster = $info{"cluster"};
	$job = $info{"job"};
	
	##
	## When a job with a Cron schedule begins execution it will
	## have a DeferralTime in its job ad. We need to get it out and save
	## it here because by the time we get the eviction notice the schedd
	## might have overwritten it
	##
	my @result;
	my $q_cmd = "condor_q $cluster.$job -format %d DeferralTime";
	if ( ! CondorTest::runCondorTool($q_cmd, \@result, 3) ) {
		print "ERROR: Unable to get DeferralTime due to Condor Tool Failure<$q_cmd>\n";
	    exit(1);
	}
	$DEFERRAL_TIME = "@result";	
	##
	## We're screwed if we can't get out the time
	##
	if ( $DEFERRAL_TIME < 0 || !$DEFERRAL_TIME ) {
		print "Bad - Unable to get DeferralTime for Job $cluster.$job!\n";
		exit(1);
	}
	
	
	##
	## Make sure that we haven't run more then we were suppose to
	##
	if ( ++$run_ctr > $max_run_ctr ) {
		print "Bad - Job $cluster.$job has been executed $run_ctr times!\n";
		my @result;
		CondorTest::runCondorTool("condor_rm $cluster.$job", \@result, 3);
		exit(1);
	##
	## It's good that we ran, so print a message 
	##
	} else {
		##
		## I'm a stickler for nice messages
		##
		my $suffix = "th";
		if ( $run_ctr == 1 ) {
			$suffix = "st";
		} elsif ( $run_ctr == 2 ) {
			$suffix = "nd";
		} elsif ( $run_ctr == 3 ) {
			$suffix = "rd";
		}
		print "Good - Job $cluster.$job began execution for the ".
			  "$run_ctr$suffix time.\n";
{'fraction_non_alphanumeric': 0.1608991422656019, 'fraction_numerical': 0.00813368825791186, 'mean_word_length': 3.677040110650069, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4135506', 'n_tokens_mistral': 2395, 'n_tokens_neox': 2251, 'n_words': 898}