foreman-tasks 0.14.4 → 0.14.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f8451837ba0e15aae21f3bf127323a6b068ebfd160e2b66e703cbff3eb33313
4
- data.tar.gz: e0aa650d6b258b8fc7c379055716c8bda2588b6e621f71e43c00cfc99de860ef
3
+ metadata.gz: f651b03116f8e483229e92bad65056ad96c2e1922850d0dd93f5a347d0f34f46
4
+ data.tar.gz: 8f1fa49ba1dcd42f2c4508e2dd4d12a981a7fdd5c6233f48d76770276d47ad55
5
5
  SHA512:
6
- metadata.gz: 6e14391d65b6c1bea3c60ab6f487a47a24e452eca949672900943abe37add259eb484675f26caef1cf3e627cd5668d97b95caa809d75a64562531cc1a88bd42d
7
- data.tar.gz: b35ee50b3ac877d780e145f61892ac9545684bac290c09de2a6a97fbf5bf854e77e3492fe0b14730b235afd8715fde193dd8eead3f3fcf55265778570b2a3919
6
+ metadata.gz: 93904ebc7747a5aa2e49862c243b7330eb1d804fe4d5c58fc87da036e052c8c3cd088bbcf7d25d4d12b41118d0398f0ab2d923c846369368af1b8602e89b079a
7
+ data.tar.gz: 83eac16d2413eb0aab6e2a14eb618ff570e4aada7aa9b1c3f80ddded23cd53303ca77c9b569b9af7638782445d5b59fed490df9d0c31e451c53f78d7eda34373
@@ -83,6 +83,9 @@ module ForemanTasks
83
83
 
84
84
  def next_occurrence_time(time = Time.zone.now)
85
85
  @parser ||= CronParser.new(cron_line, Time.zone)
86
+ # @parser.next(start_time) is not inclusive of the start_time hence stepping back one run to include checking start_time for the first run.
87
+ before_next = @parser.next(@parser.last(time))
88
+ return before_next if before_next >= time && tasks.count == 0
86
89
  @parser.next(time)
87
90
  end
88
91
 
@@ -31,10 +31,10 @@ add_files /var/log/foreman/dynflow_executor*.output*
31
31
  # Foreman Tasks fast export (Postgresql only; for HTML version use foreman-rake foreman_tasks:export_tasks)
32
32
 
33
33
  if [ "$FOREMAN_DB_ADAPTER" == "postgresql" ]; then
34
- export_csv "select dynflow_execution_plans.* from foreman_tasks_tasks join dynflow_execution_plans on (foreman_tasks_tasks.external_id = dynflow_execution_plans.uuid) where foreman_tasks_tasks.started_at > 'now'::timestamp - '${DYNFLOW_EXPORT_MONTHS:-6} months'::interval" "$DIR/dynflow_execution_plans.csv"
35
- export_csv "select dynflow_actions.* from foreman_tasks_tasks join dynflow_actions on (foreman_tasks_tasks.external_id = dynflow_actions.execution_plan_uuid) where foreman_tasks_tasks.started_at > 'now'::timestamp - '${DYNFLOW_EXPORT_MONTHS:-6} months'::interval" "$DIR/dynflow_actions.csv"
36
- export_csv "select dynflow_steps.* from foreman_tasks_tasks join dynflow_steps on (foreman_tasks_tasks.external_id = dynflow_steps.execution_plan_uuid) where foreman_tasks_tasks.started_at > 'now'::timestamp - '${DYNFLOW_EXPORT_MONTHS:-6} months'::interval" "$DIR/dynflow_steps.csv"
34
+ export_csv "select dynflow_execution_plans.* from foreman_tasks_tasks join dynflow_execution_plans on (foreman_tasks_tasks.external_id = dynflow_execution_plans.uuid) where foreman_tasks_tasks.started_at > 'now'::timestamp - '${DYNFLOW_EXPORT_MONTHS:-1} months'::interval limit ${DYNFLOW_EXPORT_LIMIT:-100000}" "$DIR/dynflow_execution_plans.csv"
35
+ export_csv "select dynflow_actions.* from foreman_tasks_tasks join dynflow_actions on (foreman_tasks_tasks.external_id = dynflow_actions.execution_plan_uuid) where foreman_tasks_tasks.started_at > 'now'::timestamp - '${DYNFLOW_EXPORT_MONTHS:-1} months'::interval limit ${DYNFLOW_EXPORT_LIMIT:-100000}" "$DIR/dynflow_actions.csv"
36
+ export_csv "select dynflow_steps.* from foreman_tasks_tasks join dynflow_steps on (foreman_tasks_tasks.external_id = dynflow_steps.execution_plan_uuid) where foreman_tasks_tasks.started_at > 'now'::timestamp - '${DYNFLOW_EXPORT_MONTHS:-1} months'::interval limit ${DYNFLOW_EXPORT_LIMIT:-100000}" "$DIR/dynflow_steps.csv"
37
37
  export_csv "select * from dynflow_schema_info" "$DIR/dynflow_schema_info.csv"
38
- export_csv "select * from foreman_tasks_tasks" "$DIR/foreman_tasks_tasks.csv"
38
+ export_csv "select * from foreman_tasks_tasks limit ${DYNFLOW_EXPORT_LIMIT:-100000}" "$DIR/foreman_tasks_tasks.csv"
39
39
  fi
40
40
 
@@ -1,3 +1,3 @@
1
1
  module ForemanTasks
2
- VERSION = '0.14.4'.freeze
2
+ VERSION = '0.14.5'.freeze
3
3
  end
@@ -7,13 +7,13 @@ module Support
7
7
 
8
8
  def initialize
9
9
  @log = Hash.new { |h, k| h[k] = [] }
10
- @task_triggered = Concurrent.future
10
+ @task_triggered = defined?(Concurrent::Promises) ? Concurrent::Promises.resolvable_future : Concurrent.future
11
11
  @uuid = SecureRandom.uuid
12
12
  end
13
13
 
14
14
  def trigger_task(*args)
15
15
  @log[:trigger_task] << args
16
- @task_triggered.success(true)
16
+ defined?(Concurrent::Promises) ? @task_triggered.fulfill(true) : @task_triggered.success(true)
17
17
  { 'task_id' => @uuid }
18
18
  end
19
19
 
@@ -25,9 +25,9 @@ class RecurringLogicsTest < ActiveSupport::TestCase
25
25
  minute = 0
26
26
  reference_time = Time.utc(year, month, day, hour, minute)
27
27
  parser = ForemanTasks::RecurringLogic.new_from_cronline('* * * * *')
28
- parser.next_occurrence_time(reference_time).must_equal Time.utc(year, month, day, hour, minute + 1)
28
+ parser.next_occurrence_time(reference_time).must_equal Time.utc(year, month, day, hour, minute)
29
29
  parser = ForemanTasks::RecurringLogic.new_from_cronline('*/2 * * * *')
30
- parser.next_occurrence_time(reference_time).must_equal Time.utc(year, month, day, hour, minute + 2)
30
+ parser.next_occurrence_time(reference_time).must_equal Time.utc(year, month, day, hour, minute)
31
31
  parser = ForemanTasks::RecurringLogic.new_from_cronline('*/2 18,19 * * *')
32
32
  parser.next_occurrence_time(reference_time).must_equal Time.utc(year, month, day, 18)
33
33
  parser = ForemanTasks::RecurringLogic.new_from_cronline('*/2 18,19 10 * *')
@@ -75,7 +75,7 @@ class RecurringLogicsTest < ActiveSupport::TestCase
75
75
  parser = ForemanTasks::RecurringLogic.new_from_cronline('* * * * *')
76
76
  parser.stubs(:id).returns(1)
77
77
  reference_time = Time.utc(2015, 9, 29, 15)
78
- expected_hash = { :start_at => reference_time + 60, :start_before => nil, :recurring_logic_id => parser.id, :frozen => false }
78
+ expected_hash = { :start_at => reference_time, :start_before => nil, :recurring_logic_id => parser.id, :frozen => false }
79
79
  parser.generate_delay_options(reference_time).must_equal expected_hash
80
80
  parser.generate_delay_options(reference_time, 'start_before' => reference_time + 3600)
81
81
  .must_equal expected_hash.merge(:start_before => reference_time + 3600)
@@ -90,15 +90,21 @@ class RecurringLogicsTest < ActiveSupport::TestCase
90
90
 
91
91
  it 'can start at' do
92
92
  recurring_logic = ForemanTasks::RecurringLogic.new_from_cronline('* * * * *')
93
-
94
- future_time = Time.zone.now + 1.week
93
+ future_time = (Time.zone.now + 1.week).change(:sec => 0)
95
94
  recurring_logic.start_after(::Support::DummyRecurringDynflowAction, future_time)
96
-
97
- # Add one minute to the time, set seconds to 0
98
- target_time = (future_time + 1.minute).change(:sec => 0)
95
+ # Able to start at same time as it is valid for * * * * *
96
+ target_time = future_time
99
97
  assert_equal target_time, recurring_logic.tasks.first.start_at
100
98
  end
101
99
 
100
+ it 'can start at scheduled time' do
101
+ future_time = (Time.zone.now + 2.minutes).change(:sec => 0)
102
+ cron = future_time.min.to_s + " * * * *"
103
+ recurring_logic = ForemanTasks::RecurringLogic.new_from_cronline(cron)
104
+ recurring_logic.start_after(::Support::DummyRecurringDynflowAction, future_time)
105
+ assert_equal future_time, recurring_logic.tasks.first.start_at
106
+ end
107
+
102
108
  it 'has a task group associated to all tasks that were created as part of the recurring logic' do
103
109
  recurring_logic = ForemanTasks::RecurringLogic.new_from_cronline('* * * * *')
104
110
  recurring_logic.save
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman-tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.4
4
+ version: 0.14.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-11 00:00:00.000000000 Z
11
+ date: 2018-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foreman-tasks-core
@@ -300,7 +300,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
300
300
  version: '0'
301
301
  requirements: []
302
302
  rubyforge_project:
303
- rubygems_version: 2.7.6
303
+ rubygems_version: 2.7.3
304
304
  signing_key:
305
305
  specification_version: 4
306
306
  summary: Foreman plugin for showing tasks information for resoruces and users