diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index edf0b5d7b..f09099842 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -23,7 +23,7 @@ jobs: ruby-version: 2.7 - name: Setup run: | - gem install bundler -v 2.4.22 + gem install bundler --version=2.4.22 bundle install --jobs=3 --retry=3 - name: Run rubocop run: bundle exec rubocop diff --git a/.rubocop.yml b/.rubocop.yml index fea17f5fa..be83e32c8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,29 +1,35 @@ inherit_from: .rubocop_todo.yml +inherit_gem: + theforeman-rubocop: + - lenient.yml AllCops: - TargetRubyVersion: 2.3 + TargetRubyVersion: 2.7 # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. -Style/ExtraSpacing: +Layout/ExtraSpacing: Enabled: true # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: with_first_parameter, with_fixed_indentation -Style/AlignParameters: +Layout/ParameterAlignment: Enabled: true # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. # SupportedStyles: aligned, indented -Style/MultilineOperationIndentation: +Layout/MultilineOperationIndentation: Enabled: true # Cop supports --auto-correct. -Style/EmptyLines: +Layout/EmptyLines: Enabled: true Metrics/ModuleLength: Exclude: - test/**/* + +Style/LambdaCall: + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d16050395..ed6654930 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,418 +1,787 @@ # This configuration was generated by -# `rubocop --auto-gen-config --exclude-limit 0` -# on 2016-08-24 10:37:35 -0400 using RuboCop version 0.39.0. +# `rubocop --auto-gen-config` +# on 2024-01-26 13:59:46 UTC using RuboCop version 0.89.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 7 -Lint/AmbiguousOperator: - Enabled: false +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleAlignWith. +# SupportedStylesAlignWith: either, start_of_block, start_of_line +Layout/BlockAlignment: + Exclude: + - 'test/test_helper.rb' -# Offense count: 2 -Lint/AmbiguousRegexpLiteral: +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_braces +Layout/FirstHashElementIndentation: + Exclude: + - 'lib/dynflow/execution_plan/steps/finalize_step.rb' + - 'lib/dynflow/execution_plan/steps/run_step.rb' + - 'lib/dynflow/persistence_adapters/sequel_migrations/022_store_flows_as_msgpack.rb' + - 'lib/dynflow/persistence_adapters/sequel_migrations/024_store_execution_plan_data_as_msgpack.rb' + - 'test/persistence_test.rb' + +# Offense count: 201 +# Cop supports --auto-correct. +# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/HashAlignment: Enabled: false -# Offense count: 7 +# Offense count: 8 # Configuration parameters: AllowSafeAssignment. Lint/AssignmentInCondition: - Enabled: false - -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: AlignWith, SupportedStyles. -# SupportedStyles: either, start_of_block, start_of_line -Lint/BlockAlignment: - Enabled: false + Exclude: + - 'doc/pages/plugins/tags.rb' + - 'lib/dynflow/action/v2/with_sub_plans.rb' + - 'lib/dynflow/connectors/direct.rb' + - 'lib/dynflow/director/running_steps_manager.rb' + - 'lib/dynflow/testing/dummy_execution_plan.rb' + - 'lib/dynflow/testing/managed_clock.rb' + - 'lib/dynflow/web/console_helpers.rb' + - 'test/test_helper.rb' -# Offense count: 1 +# Offense count: 4 Lint/DuplicateMethods: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: AlignWith, SupportedStyles, AutoCorrect. -# SupportedStyles: keyword, variable, start_of_line -Lint/EndAlignment: - Enabled: false + Exclude: + - 'lib/dynflow/coordinator.rb' + - 'lib/dynflow/executors/parallel/pool.rb' + - 'lib/dynflow/rails/configuration.rb' + - 'lib/dynflow/rails/daemon.rb' # Offense count: 6 Lint/IneffectiveAccessModifier: - Enabled: false + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/execution_plan/output_reference.rb' + - 'lib/dynflow/execution_plan/steps/abstract.rb' + - 'lib/dynflow/flows/atom.rb' + - 'lib/dynflow/persistence_adapters/sequel.rb' -# Offense count: 5 -Lint/ParenthesesAsGroupedExpression: - Enabled: false +# Offense count: 1 +# Configuration parameters: MaximumRangeSize. +Lint/MissingCopEnableDirective: + Exclude: + - 'test/persistence_test.rb' # Offense count: 1 Lint/RandOne: - Enabled: false + Exclude: + - 'examples/orchestrate_evented.rb' # Offense count: 3 Lint/RescueException: - Enabled: false + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/delayed_executors/abstract_core.rb' + - 'lib/dynflow/persistence_adapters/sequel.rb' -# Offense count: 1 +# Offense count: 3 +# Cop supports --auto-correct. +Lint/ScriptPermission: + Exclude: + - 'examples/chunked_output_benchmark.rb' + - 'examples/memory_limit_watcher.rb' + - 'examples/sub_plan_concurrency_control.rb' + +# Offense count: 3 Lint/ShadowingOuterLocalVariable: - Enabled: false + Exclude: + - 'lib/dynflow/logger_adapters/abstract.rb' + - 'lib/dynflow/rails/daemon.rb' # Offense count: 1 +# Configuration parameters: AllowKeywordBlockArguments. Lint/UnderscorePrefixedVariableName: - Enabled: false + Exclude: + - 'lib/dynflow/utils/indifferent_hash.rb' -# Offense count: 17 +# Offense count: 30 # Cop supports --auto-correct. -# Configuration parameters: IgnoreEmptyBlocks. +# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. Lint/UnusedBlockArgument: Enabled: false -# Offense count: 78 +# Offense count: 43 # Cop supports --auto-correct. -# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods. +# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods. Lint/UnusedMethodArgument: Enabled: false -# Offense count: 3 +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods. Lint/UselessAccessModifier: - Enabled: false + Exclude: + - 'lib/dynflow/dead_letter_silencer.rb' + - 'lib/dynflow/delayed_executors/abstract_core.rb' + - 'lib/dynflow/execution_plan/output_reference.rb' + - 'lib/dynflow/execution_plan/steps/abstract.rb' + - 'lib/dynflow/flows/atom.rb' + - 'lib/dynflow/rails/daemon.rb' -# Offense count: 5 +# Offense count: 9 Lint/UselessAssignment: - Enabled: false + Exclude: + - 'doc/pages/plugins/plantuml.rb' + - 'examples/memory_limit_watcher.rb' + - 'examples/singletons.rb' + - 'lib/dynflow/executors/parallel.rb' + - 'lib/dynflow/persistence_adapters/sequel.rb' + - 'lib/dynflow/rails/configuration.rb' + - 'lib/dynflow/world.rb' + - 'test/concurrency_control_test.rb' + +# Offense count: 1 +# Configuration parameters: CheckForMethodsWithNoSideEffects. +Lint/Void: + Exclude: + - 'test/executor_test.rb' -# Offense count: 73 +# Offense count: 86 +# Configuration parameters: IgnoredMethods. Metrics/AbcSize: - Max: 207 + Max: 66 -# Offense count: 9 -# Configuration parameters: CountComments. -Metrics/ClassLength: - Max: 402 +# Offense count: 101 +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods. +# ExcludedMethods: refine +Metrics/BlockLength: + Max: 738 # Offense count: 11 -Metrics/CyclomaticComplexity: - Max: 11 +# Configuration parameters: CountComments, CountAsOne. +Metrics/ClassLength: + Max: 292 -# Offense count: 521 -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes. -# URISchemes: http, https -Metrics/LineLength: - Max: 166 +# Offense count: 19 +# Configuration parameters: IgnoredMethods. +Metrics/CyclomaticComplexity: + Max: 18 -# Offense count: 99 -# Configuration parameters: CountComments. +# Offense count: 135 +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods. Metrics/MethodLength: - Max: 104 + Max: 47 -# Offense count: 14 -# Configuration parameters: CountComments. +# Offense count: 4 +# Configuration parameters: CountComments, CountAsOne. Metrics/ModuleLength: - Max: 548 + Max: 188 -# Offense count: 3 +# Offense count: 8 # Configuration parameters: CountKeywordArgs. Metrics/ParameterLists: Max: 13 -# Offense count: 9 +# Offense count: 15 +# Configuration parameters: IgnoredMethods. Metrics/PerceivedComplexity: - Max: 11 + Max: 18 + +# Offense count: 10 +Naming/AccessorMethodName: + Exclude: + - 'examples/example_helper.rb' + - 'lib/dynflow/action.rb' + - 'lib/dynflow/director.rb' + - 'lib/dynflow/semaphores/abstract.rb' + - 'lib/dynflow/semaphores/aggregating.rb' + - 'lib/dynflow/semaphores/dummy.rb' + - 'lib/dynflow/semaphores/stateful.rb' + - 'lib/dynflow/telemetry.rb' + - 'lib/dynflow/testing.rb' + - 'lib/dynflow/watchers/memory_consumption_watcher.rb' -# Offense count: 16 +# Offense count: 1 +Naming/BinaryOperatorParameterName: + Exclude: + - 'lib/dynflow/coordinator.rb' + +# Offense count: 3 +Naming/ConstantName: + Exclude: + - 'examples/sub_plan_concurrency_control.rb' + +# Offense count: 5 +# Configuration parameters: EnforcedStyleForLeadingUnderscores. +# SupportedStylesForLeadingUnderscores: disallowed, required, optional +Naming/MemoizedInstanceVariableName: + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/execution_plan/steps/abstract_flow_step.rb' + - 'lib/dynflow/persistence_adapters/abstract.rb' + - 'lib/dynflow/testing/in_thread_world.rb' + - 'test/test_helper.rb' + +# Offense count: 13 +# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. +# AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to +Naming/MethodParameterName: + Exclude: + - 'lib/dynflow/flows/abstract_composed.rb' + - 'lib/dynflow/logger_adapters/abstract.rb' + - 'lib/dynflow/logger_adapters/formatters/abstract.rb' + - 'lib/dynflow/logger_adapters/simple.rb' + - 'lib/dynflow/semaphores/abstract.rb' + - 'lib/dynflow/semaphores/aggregating.rb' + - 'lib/dynflow/semaphores/dummy.rb' + - 'lib/dynflow/semaphores/stateful.rb' + - 'lib/dynflow/testing/mimic.rb' + +# Offense count: 4 +# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros. +# NamePrefix: is_, has_, have_ +# ForbiddenPrefixes: is_, has_, have_ +# AllowedMethods: is_a? +# MethodDefinitionMacros: define_method, define_singleton_method +Naming/PredicateName: + Exclude: + - 'spec/**/*' + - 'lib/dynflow/semaphores/abstract.rb' + - 'lib/dynflow/semaphores/aggregating.rb' + - 'lib/dynflow/semaphores/dummy.rb' + - 'lib/dynflow/semaphores/stateful.rb' + +# Offense count: 7 # Cop supports --auto-correct. -Performance/RedundantBlockCall: - Enabled: false +# Configuration parameters: PreferredName. +Naming/RescuedExceptionsVariableName: + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/action/polling.rb' + - 'lib/dynflow/action/progress.rb' + - 'lib/dynflow/execution_plan.rb' + - 'lib/dynflow/executors/parallel.rb' + - 'lib/dynflow/serializable.rb' + +# Offense count: 3 +# Configuration parameters: MinSize. +Performance/CollectionLiteralInLoop: + Exclude: + - 'lib/dynflow/coordinator.rb' + - 'lib/dynflow/director/sequential_manager.rb' + - 'lib/dynflow/execution_plan.rb' # Offense count: 4 # Cop supports --auto-correct. +Performance/Count: + Exclude: + - 'lib/dynflow/world/invalidation.rb' + - 'test/concurrency_control_test.rb' + +# Offense count: 17 +# Cop supports --auto-correct. +Performance/RedundantBlockCall: + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/coordinator.rb' + - 'lib/dynflow/delayed_executors/abstract_core.rb' + - 'lib/dynflow/director/sequential_manager.rb' + - 'lib/dynflow/execution_plan.rb' + - 'lib/dynflow/execution_plan/steps/abstract.rb' + - 'lib/dynflow/persistence_adapters/sequel_migrations/018_add_uuid_column.rb' + - 'lib/dynflow/testing/assertions.rb' + - 'lib/dynflow/testing/dummy_execution_plan.rb' + - 'lib/dynflow/testing/factories.rb' + - 'lib/dynflow/transaction_adapters/none.rb' + - 'lib/dynflow/world.rb' + - 'test/test_helper.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Performance/RegexpMatch: + Exclude: + - 'test/support/code_workflow_example.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect. Performance/TimesMap: - Enabled: false + Exclude: + - 'examples/sub_plan_concurrency_control.rb' + - 'test/action_test.rb' + - 'test/concurrency_control_test.rb' -# Offense count: 8 -Style/AccessorMethodName: - Enabled: false +# Offense count: 7 +Performance/UnfreezeString: + Exclude: + - 'lib/dynflow/execution_plan/output_reference.rb' + - 'lib/dynflow/extensions/msgpack.rb' + - 'test/support/middleware_example.rb' + - 'test/test_helper.rb' -# Offense count: 13 +# Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: prefer_alias, prefer_alias_method -Style/Alias: - Enabled: false +# Configuration parameters: Include. +# Include: **/test/**/* +Rails/AssertNot: + Exclude: + - 'test/executor_test.rb' # Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles. -# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit -Style/AlignHash: - Enabled: false +# Configuration parameters: NilOrEmpty, NotPresent, UnlessPresent. +Rails/Blank: + Exclude: + - 'lib/dynflow/telemetry_adapters/statsd.rb' -# Offense count: 11 +# Offense count: 3 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: strict, flexible +Rails/Date: + Exclude: + - 'lib/dynflow/extensions/msgpack.rb' + - 'lib/dynflow/persistence.rb' + +# Offense count: 12 +# Cop supports --auto-correct. +# Configuration parameters: EnforceForPrefixed. +Rails/Delegate: + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/execution_plan.rb' + - 'lib/dynflow/execution_plan/steps/abstract.rb' + - 'lib/dynflow/persistence.rb' + - 'lib/dynflow/rails/configuration.rb' + - 'lib/dynflow/web/world_helpers.rb' + - 'lib/dynflow/world.rb' + +# Offense count: 2 +# Configuration parameters: Include. +# Include: app/**/*.rb, config/**/*.rb, lib/**/*.rb +Rails/Exit: + Exclude: + - 'lib/**/*.rake' + - 'lib/dynflow/rails/daemon.rb' + - 'lib/dynflow/world.rb' + +# Offense count: 1 +# Configuration parameters: Include. +# Include: app/**/*.rb, config/**/*.rb, db/**/*.rb, lib/**/*.rb +Rails/Output: + Exclude: + - 'lib/dynflow/testing/in_thread_world.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Rails/PluralizationGrammar: + Exclude: + - 'test/activejob_adapter_test.rb' + +# Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: always, conditionals -Style/AndOr: +# Configuration parameters: Include. +# Include: **/Rakefile, **/*.rake +Rails/RakeEnvironment: + Exclude: + - 'lib/capistrano/tasks/**/*.rake' + - 'doc/pages/Rakefile' + +# Offense count: 24 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, Include. +# SupportedStyles: assert_not, refute +# Include: **/test/**/* +Rails/RefuteMethods: + Exclude: + - 'test/abnormal_states_recovery_test.rb' + - 'test/action_test.rb' + - 'test/dispatcher_test.rb' + - 'test/execution_plan_hooks_test.rb' + - 'test/execution_plan_test.rb' + - 'test/executor_test.rb' + - 'test/test_helper.rb' + +# Offense count: 14 +# Configuration parameters: ForbiddenMethods, AllowedMethods. +# ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all +Rails/SkipsModelValidations: + Exclude: + - 'db/migrate/*.rb' + - 'lib/dynflow/connectors/abstract.rb' + - 'lib/dynflow/connectors/database.rb' + - 'lib/dynflow/connectors/direct.rb' + - 'lib/dynflow/execution_plan.rb' + - 'lib/dynflow/executors/parallel/worker.rb' + - 'lib/dynflow/executors/sidekiq/worker_jobs.rb' + - 'lib/dynflow/persistence_adapters/sequel.rb' + - 'test/persistence_test.rb' + +# Offense count: 37 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: strict, flexible +Rails/TimeZone: Enabled: false +# Offense count: 2 +Security/MarshalLoad: + Exclude: + - 'lib/dynflow/dispatcher.rb' + - 'lib/dynflow/serializer.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: prefer_alias, prefer_alias_method +Style/Alias: + Exclude: + - 'lib/dynflow/rails/configuration.rb' + - 'lib/dynflow/testing/assertions.rb' + # Offense count: 2 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Configuration parameters: EnforcedStyle. # SupportedStyles: percent_q, bare_percent Style/BarePercentLiterals: - Enabled: false + Exclude: + - 'doc/pages/plugins/tags.rb' # Offense count: 3 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods. -# SupportedStyles: line_count_based, semantic, braces_for_chaining +# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods, AllowBracesOnProceduralOneLiners, BracesRequiredMethods. +# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object # FunctionalMethods: let, let!, subject, watch # IgnoredMethods: lambda, proc, it Style/BlockDelimiters: - Enabled: false + Exclude: + - 'doc/pages/plugins/tags.rb' -# Offense count: 18 +# Offense count: 10 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: braces, no_braces, context_dependent -Style/BracesAroundHashParameters: - Enabled: false - -# Offense count: 13 +# Configuration parameters: AllowOnConstant. Style/CaseEquality: - Enabled: false - -# Offense count: 24 -# Configuration parameters: EnforcedStyle, SupportedStyles. + Exclude: + - 'lib/dynflow/action/with_bulk_sub_plans.rb' + - 'lib/dynflow/clock.rb' + - 'lib/dynflow/connectors/database.rb' + - 'lib/dynflow/connectors/direct.rb' + - 'lib/dynflow/director/running_steps_manager.rb' + - 'lib/dynflow/dispatcher/client_dispatcher.rb' + - 'lib/dynflow/logger_adapters/formatters/exception.rb' + - 'lib/dynflow/serializer.rb' + - 'test/abnormal_states_recovery_test.rb' + - 'test/support/rescue_example.rb' + +# Offense count: 29 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, EnforcedStyle. # SupportedStyles: nested, compact Style/ClassAndModuleChildren: Enabled: false -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: is_a?, kind_of? -Style/ClassCheck: - Enabled: false - -# Offense count: 4 +# Offense count: 5 # Cop supports --auto-correct. Style/ColonMethodCall: - Enabled: false + Exclude: + - 'doc/pages/plugins/graphviz.rb' + - 'doc/pages/plugins/plantuml.rb' + - 'test/executor_test.rb' # Offense count: 5 # Cop supports --auto-correct. # Configuration parameters: Keywords. # Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW Style/CommentAnnotation: - Enabled: false - -# Offense count: 4 -Style/ConstantName: - Enabled: false - -# Offense count: 3 -# Cop supports --auto-correct. -Style/DeprecatedHashMethods: - Enabled: false + Exclude: + - 'doc/pages/plugins/tags.rb' + - 'examples/remote_executor.rb' + - 'lib/dynflow.rb' + - 'lib/dynflow/world.rb' + - 'test/support/code_workflow_example.rb' -# Offense count: 172 -Style/Documentation: - Enabled: false +# Offense count: 1 +Style/CommentedKeyword: + Exclude: + - 'doc/pages/plugins/plantuml.rb' -# Offense count: 20 +# Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: leading, trailing -Style/DotPosition: - Enabled: false - -# Offense count: 3 -Style/DoubleNegation: - Enabled: false +Style/Dir: + Exclude: + - 'test/test_helper.rb' # Offense count: 1 -Style/EachWithObject: - Enabled: false +# Configuration parameters: EnforcedStyle. +# SupportedStyles: allowed_in_returns, forbidden +Style/DoubleNegation: + Exclude: + - 'lib/dynflow/config.rb' # Offense count: 2 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: empty, nil, both -Style/EmptyElse: - Enabled: false - -# Offense count: 5 -# Cop supports --auto-correct. -# Configuration parameters: AllowAdjacentOneLineDefs. -Style/EmptyLineBetweenDefs: - Enabled: false +Style/EachWithObject: + Exclude: + - 'lib/dynflow/execution_plan.rb' # Offense count: 1 # Cop supports --auto-correct. -Style/EmptyLinesAroundAccessModifier: - Enabled: false +Style/EmptyCaseCondition: + Exclude: + - 'lib/dynflow/serializer.rb' -# Offense count: 91 +# Offense count: 2 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: empty_lines, no_empty_lines -Style/EmptyLinesAroundBlockBody: - Enabled: false +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty, nil, both +Style/EmptyElse: + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/execution_plan.rb' -# Offense count: 143 +# Offense count: 9 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: empty_lines, no_empty_lines -Style/EmptyLinesAroundClassBody: - Enabled: false +# Configuration parameters: EnforcedStyle. +# SupportedStyles: compact, expanded +Style/EmptyMethod: + Exclude: + - 'test/action_test.rb' + - 'test/execution_plan_cleaner_test.rb' + - 'test/executor_test.rb' + - 'test/support/dummy_example.rb' -# Offense count: 2 +# Offense count: 7 # Cop supports --auto-correct. -Style/EmptyLinesAroundMethodBody: - Enabled: false +Style/Encoding: + Exclude: + - 'dynflow.gemspec' + - 'examples/remote_executor.rb' + - 'lib/dynflow/rails.rb' + - 'lib/dynflow/world.rb' + - 'test/abnormal_states_recovery_test.rb' + - 'test/executor_test.rb' + - 'test/round_robin_test.rb' -# Offense count: 52 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: empty_lines, no_empty_lines -Style/EmptyLinesAroundModuleBody: - Enabled: false - -# Offense count: 9 +# Offense count: 8 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. -# SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses -Style/FirstParameterIndentation: - Enabled: false +Style/ExpandPathArguments: + Exclude: + - 'dynflow.gemspec' + - 'examples/example_helper.rb' + - 'examples/remote_executor.rb' + - 'lib/dynflow/persistence_adapters/sequel.rb' + - 'lib/dynflow/rails.rb' + - 'lib/dynflow/web.rb' + - 'test/daemon_test.rb' # Offense count: 4 -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. # SupportedStyles: format, sprintf, percent Style/FormatString: - Enabled: false + Exclude: + - 'lib/dynflow/coordinator.rb' + - 'lib/dynflow/web/console_helpers.rb' + +# Offense count: 31 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: annotated, template, unannotated +Style/FormatStringToken: + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/actor.rb' + - 'lib/dynflow/coordinator.rb' + - 'lib/dynflow/execution_plan.rb' + - 'lib/dynflow/execution_plan/steps/error.rb' + - 'lib/dynflow/logger_adapters/simple.rb' + - 'lib/dynflow/web/console_helpers.rb' # Offense count: 7 # Configuration parameters: AllowedVariables. Style/GlobalVars: - Enabled: false + Exclude: + - 'test/executor_test.rb' + - 'test/support/dummy_example.rb' + - 'test/testing_test.rb' -# Offense count: 13 +# Offense count: 60 # Configuration parameters: MinBodyLength. Style/GuardClause: Enabled: false -# Offense count: 106 +# Offense count: 10 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues. -# SupportedStyles: ruby19, ruby19_no_mixed_keys, hash_rockets +# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys Style/HashSyntax: - Enabled: false + Exclude: + - 'lib/dynflow/persistence_adapters/sequel.rb' + - 'test/persistence_test.rb' -# Offense count: 4 +# Offense count: 8 +# Configuration parameters: AllowIfModifier. Style/IfInsideElse: - Enabled: false + Exclude: + - 'lib/dynflow/action/rescue.rb' + - 'lib/dynflow/action/with_polling_sub_plans.rb' + - 'lib/dynflow/clock.rb' + - 'lib/dynflow/dispatcher/client_dispatcher.rb' + - 'lib/dynflow/rails/configuration.rb' + - 'lib/dynflow/utils.rb' + - 'lib/dynflow/world/invalidation.rb' -# Offense count: 22 +# Offense count: 69 # Cop supports --auto-correct. -# Configuration parameters: MaxLineLength. Style/IfUnlessModifier: Enabled: false -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: IndentationWidth. -Style/IndentAssignment: - Enabled: false - -# Offense count: 2 +# Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_braces -Style/IndentHash: - Enabled: false +# Configuration parameters: InverseMethods, InverseBlocks. +Style/InverseMethods: + Exclude: + - 'lib/dynflow/middleware/resolver.rb' # Offense count: 8 # Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: line_count_dependent, lambda, literal Style/Lambda: - Enabled: false - -# Offense count: 13 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: call, braces -Style/LambdaCall: - Enabled: false - -# Offense count: 3 -# Cop supports --auto-correct. -Style/LineEndConcatenation: - Enabled: false + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/extensions/msgpack.rb' + - 'lib/dynflow/rails/daemon.rb' + - 'lib/dynflow/testing/mimic.rb' + - 'test/concurrency_control_test.rb' + - 'test/test_helper.rb' -# Offense count: 3 +# Offense count: 12 # Cop supports --auto-correct. -Style/MethodCallParentheses: - Enabled: false +# Configuration parameters: IgnoredMethods. +Style/MethodCallWithoutArgsParentheses: + Exclude: + - 'doc/pages/plugins/plantuml.rb' + - 'lib/dynflow/delayed_executors/abstract_core.rb' + - 'lib/dynflow/director.rb' + - 'test/action_test.rb' + - 'test/dispatcher_test.rb' + - 'test/v2_sub_plans_test.rb' -# Offense count: 2 +# Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Configuration parameters: EnforcedStyle. # SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline Style/MethodDefParentheses: - Enabled: false + Exclude: + - 'doc/pages/plugins/graphviz.rb' -# Offense count: 6 +# Offense count: 1 +Style/MissingRespondToMissing: + Exclude: + - 'lib/dynflow/config.rb' + +# Offense count: 5 Style/MultilineBlockChain: - Enabled: false + Exclude: + - 'lib/dynflow/dispatcher/executor_dispatcher.rb' + - 'lib/dynflow/world.rb' + - 'test/executor_test.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Style/MultilineIfModifier: + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/execution_plan.rb' # Offense count: 1 # Cop supports --auto-correct. Style/MultilineIfThen: - Enabled: false + Exclude: + - 'doc/pages/plugins/graphviz.rb' -# Offense count: 23 +# Offense count: 3 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. -# SupportedStyles: aligned, indented -Style/MultilineMethodCallIndentation: - Enabled: false +Style/MultilineWhenThen: + Exclude: + - 'doc/pages/plugins/graphviz.rb' -# Offense count: 9 +# Offense count: 1 +Style/MultipleComparison: + Exclude: + - 'test/action_test.rb' + +# Offense count: 4 # Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: literals, strict Style/MutableConstant: - Enabled: false + Exclude: + - 'doc/pages/plugins/alert_block.rb' + - 'lib/dynflow/persistence_adapters/sequel.rb' # Offense count: 5 # Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: both, prefix, postfix Style/NegatedIf: - Enabled: false + Exclude: + - 'doc/pages/plugins/graphviz.rb' + - 'doc/pages/plugins/plantuml.rb' + - 'doc/pages/plugins/tags.rb' + - 'lib/dynflow/actor.rb' -# Offense count: 9 +# Offense count: 11 +# Cop supports --auto-correct. +# Configuration parameters: AllowedMethods. +# AllowedMethods: be, be_a, be_an, be_between, be_falsey, be_kind_of, be_instance_of, be_truthy, be_within, eq, eql, end_with, include, match, raise_error, respond_to, start_with Style/NestedParenthesizedCalls: - Enabled: false + Exclude: + - 'lib/dynflow/persistence_adapters/sequel.rb' + - 'lib/dynflow/web/console.rb' -# Offense count: 2 +# Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles. +# Configuration parameters: EnforcedStyle, MinBodyLength. # SupportedStyles: skip_modifier_ifs, always Style/Next: - Enabled: false + Exclude: + - 'doc/pages/plugins/tags.rb' # Offense count: 2 # Cop supports --auto-correct. Style/Not: - Enabled: false - -# Offense count: 2 -Style/OpMethod: - Enabled: false + Exclude: + - 'doc/pages/plugins/graphviz.rb' + - 'doc/pages/plugins/tags.rb' + +# Offense count: 15 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods. +# SupportedStyles: predicate, comparison +Style/NumericPredicate: + Exclude: + - 'spec/**/*' + - 'lib/dynflow/action/v2/with_sub_plans.rb' + - 'lib/dynflow/action/with_bulk_sub_plans.rb' + - 'lib/dynflow/action/with_sub_plans.rb' + - 'lib/dynflow/execution_plan.rb' + - 'lib/dynflow/flows/abstract.rb' + - 'lib/dynflow/rails.rb' + - 'lib/dynflow/rails/daemon.rb' + - 'lib/dynflow/semaphores/aggregating.rb' + - 'lib/dynflow/semaphores/stateful.rb' + - 'test/execution_plan_hooks_test.rb' # Offense count: 5 # Cop supports --auto-correct. Style/ParallelAssignment: - Enabled: false + Exclude: + - 'doc/pages/plugins/tags.rb' + - 'test/executor_test.rb' + - 'test/support/test_execution_log.rb' + - 'test/test_helper.rb' -# Offense count: 24 +# Offense count: 45 # Cop supports --auto-correct. # Configuration parameters: PreferredDelimiters. Style/PercentLiteralDelimiters: @@ -421,44 +790,67 @@ Style/PercentLiteralDelimiters: # Offense count: 1 # Cop supports --auto-correct. Style/PerlBackrefs: - Enabled: false + Exclude: + - 'test/support/dummy_example.rb' -# Offense count: 4 -# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist. -# NamePrefix: is_, has_, have_ -# NamePrefixBlacklist: is_, has_, have_ -# NameWhitelist: is_a? -Style/PredicateName: - Enabled: false +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: short, verbose +Style/PreferredHashMethods: + Exclude: + - 'lib/dynflow/middleware/resolver.rb' + - 'lib/dynflow/world.rb' # Offense count: 6 # Cop supports --auto-correct. Style/Proc: - Enabled: false + Exclude: + - 'examples/remote_executor.rb' + - 'test/abnormal_states_recovery_test.rb' + - 'test/dispatcher_test.rb' -# Offense count: 4 -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. # SupportedStyles: compact, exploded Style/RaiseArgs: - Enabled: false + Exclude: + - 'lib/dynflow/action/v2/with_sub_plans.rb' + - 'lib/dynflow/action/with_sub_plans.rb' + - 'lib/dynflow/coordinator.rb' + - 'lib/dynflow/coordinator_adapters/sequel.rb' + - 'lib/dynflow/dispatcher/client_dispatcher.rb' -# Offense count: 1 +# Offense count: 7 # Cop supports --auto-correct. Style/RedundantBegin: - Enabled: false + Exclude: + - 'examples/remote_executor.rb' + - 'lib/dynflow/execution_plan/hooks.rb' + - 'lib/dynflow/rails/daemon.rb' + - 'lib/dynflow/world.rb' + - 'test/test_helper.rb' -# Offense count: 2 +# Offense count: 1 +# Cop supports --auto-correct. +Style/RedundantCapitalW: + Exclude: + - 'test/future_execution_test.rb' + +# Offense count: 1 # Cop supports --auto-correct. Style/RedundantParentheses: - Enabled: false + Exclude: + - 'test/coordinator_test.rb' -# Offense count: 43 +# Offense count: 72 # Cop supports --auto-correct. # Configuration parameters: AllowMultipleReturnValues. Style/RedundantReturn: Enabled: false -# Offense count: 87 +# Offense count: 107 # Cop supports --auto-correct. Style/RedundantSelf: Enabled: false @@ -466,145 +858,185 @@ Style/RedundantSelf: # Offense count: 1 # Cop supports --auto-correct. Style/RescueModifier: + Exclude: + - 'lib/dynflow/serializer.rb' + +# Offense count: 22 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: implicit, explicit +Style/RescueStandardError: + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/action/polling.rb' + - 'lib/dynflow/action/progress.rb' + - 'lib/dynflow/clock.rb' + - 'lib/dynflow/connectors/database.rb' + - 'lib/dynflow/director.rb' + - 'lib/dynflow/dispatcher/client_dispatcher.rb' + - 'lib/dynflow/execution_plan.rb' + - 'lib/dynflow/execution_plan/hooks.rb' + - 'lib/dynflow/executors/parallel.rb' + - 'lib/dynflow/rails/daemon.rb' + - 'lib/dynflow/testing/in_thread_executor.rb' + - 'lib/dynflow/testing/in_thread_world.rb' + - 'lib/dynflow/world.rb' + - 'lib/dynflow/world/invalidation.rb' + +# Offense count: 21 +# Cop supports --auto-correct. +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods. +# AllowedMethods: present?, blank?, presence, try, try! +Style/SafeNavigation: Enabled: false # Offense count: 6 # Cop supports --auto-correct. # Configuration parameters: AllowAsExpressionSeparator. Style/Semicolon: - Enabled: false + Exclude: + - 'test/abnormal_states_recovery_test.rb' + - 'test/concurrency_control_test.rb' + - 'test/dispatcher_test.rb' + - 'test/executor_test.rb' # Offense count: 3 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Configuration parameters: EnforcedStyle. # SupportedStyles: only_raise, only_fail, semantic Style/SignalException: - Enabled: false - -# Offense count: 6 -# Configuration parameters: Methods. -# Methods: {"reduce"=>["a", "e"]}, {"inject"=>["a", "e"]} -Style/SingleLineBlockParams: - Enabled: false + Exclude: + - 'lib/dynflow/action/singleton.rb' + - 'lib/dynflow/action/timeouts.rb' + - 'lib/dynflow/action/with_sub_plans.rb' # Offense count: 6 # Cop supports --auto-correct. # Configuration parameters: AllowIfMethodIsEmpty. Style/SingleLineMethods: - Enabled: false - -# Offense count: 42 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment. -Style/SpaceAroundOperators: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -Style/SpaceBeforeComma: - Enabled: false - -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. -# SupportedStyles: space, no_space -Style/SpaceInsideBlockBraces: - Enabled: false + Exclude: + - 'lib/dynflow/utils/indifferent_hash.rb' + - 'test/support/dummy_example.rb' -# Offense count: 7 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles. -# SupportedStyles: space, no_space -Style/SpaceInsideHashLiteralBraces: - Enabled: false - -# Offense count: 7 -# Cop supports --auto-correct. -Style/SpaceInsideParens: - Enabled: false - -# Offense count: 8 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: space, no_space -Style/SpaceInsideStringInterpolation: - Enabled: false - -# Offense count: 9 +# Offense count: 14 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Configuration parameters: EnforcedStyle. # SupportedStyles: use_perl_names, use_english_names Style/SpecialGlobalVars: - Enabled: false + Exclude: + - 'dynflow.gemspec' + - 'examples/chunked_output_benchmark.rb' + - 'examples/example_helper.rb' + - 'examples/future_execution.rb' + - 'examples/memory_limit_watcher.rb' + - 'examples/orchestrate.rb' + - 'examples/orchestrate_evented.rb' + - 'examples/remote_executor.rb' + - 'examples/singletons.rb' + - 'examples/sub_plan_concurrency_control.rb' + - 'examples/sub_plans.rb' + - 'examples/sub_plans_v2.rb' + - 'examples/termination.rb' -# Offense count: 5 +# Offense count: 4 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Configuration parameters: EnforcedStyle. # SupportedStyles: require_parentheses, require_no_parentheses Style/StabbyLambdaParentheses: - Enabled: false + Exclude: + - 'lib/dynflow/action.rb' + - 'lib/dynflow/clock.rb' + - 'lib/dynflow/testing/mimic.rb' -# Offense count: 230 +# Offense count: 2 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline. -# SupportedStyles: single_quotes, double_quotes -Style/StringLiterals: - Enabled: false +Style/StderrPuts: + Exclude: + - 'lib/dynflow/rails/daemon.rb' # Offense count: 2 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Configuration parameters: EnforcedStyle. # SupportedStyles: single_quotes, double_quotes Style/StringLiteralsInInterpolation: - Enabled: false + Exclude: + - 'lib/dynflow/web/console.rb' + - 'lib/dynflow/web/console_helpers.rb' -# Offense count: 9 +# Offense count: 10 # Cop supports --auto-correct. # Configuration parameters: IgnoredMethods. -# IgnoredMethods: respond_to +# IgnoredMethods: respond_to, define_method Style/SymbolProc: - Enabled: false - -# Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: final_newline, final_blank_line -Style/TrailingBlankLines: - Enabled: false + Exclude: + - 'doc/pages/plugins/tags.rb' + - 'lib/dynflow/action.rb' + - 'lib/dynflow/action/v2/with_sub_plans.rb' + - 'lib/dynflow/action/with_polling_sub_plans.rb' + - 'lib/dynflow/action/with_sub_plans.rb' + - 'lib/dynflow/director.rb' + - 'lib/dynflow/director/sequence_cursor.rb' + - 'lib/dynflow/world.rb' + - 'test/concurrency_control_test.rb' + - 'test/test_helper.rb' # Offense count: 2 # Cop supports --auto-correct. -# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist. -# Whitelist: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym -Style/TrivialAccessors: - Enabled: false +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInArrayLiteral: + Exclude: + - 'lib/dynflow/config.rb' + - 'lib/dynflow/debug/telemetry/persistence.rb' -# Offense count: 1 +# Offense count: 9 # Cop supports --auto-correct. -Style/UnneededCapitalW: - Enabled: false +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInHashLiteral: + Exclude: + - 'lib/dynflow/execution_plan/steps/finalize_step.rb' + - 'lib/dynflow/execution_plan/steps/run_step.rb' + - 'lib/dynflow/persistence_adapters/sequel_migrations/022_store_flows_as_msgpack.rb' + - 'lib/dynflow/persistence_adapters/sequel_migrations/024_store_execution_plan_data_as_msgpack.rb' + - 'lib/dynflow/rails/daemon.rb' + - 'lib/dynflow/semaphores/stateful.rb' + - 'test/persistence_test.rb' + - 'test/semaphores_test.rb' -# Offense count: 2 -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: snake_case, camelCase -Style/VariableName: - Enabled: false +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, AllowedMethods. +# AllowedMethods: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym +Style/TrivialAccessors: + Exclude: + - 'lib/dynflow/director.rb' + - 'test/support/middleware_example.rb' + - 'test/support/test_execution_log.rb' # Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: MaxLineLength. -Style/WhileUntilModifier: - Enabled: false +Style/UnpackFirst: + Exclude: + - 'lib/dynflow/persistence_adapters/sequel.rb' -# Offense count: 7 +# Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: SupportedStyles, WordRegex. -# SupportedStyles: percent, brackets -Style/WordArray: - EnforcedStyle: percent - MinSize: 4 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: forbid_for_all_comparison_operators, forbid_for_equality_operators_only, require_for_all_comparison_operators, require_for_equality_operators_only +Style/YodaCondition: + Exclude: + - 'lib/dynflow/actor.rb' # Offense count: 1 # Cop supports --auto-correct. Style/ZeroLengthPredicate: - Enabled: false + Exclude: + - 'lib/dynflow/flows/abstract.rb' + +# Offense count: 86 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Layout/LineLength: + Max: 165 diff --git a/Gemfile b/Gemfile index 055f43e57..e7698b572 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,5 @@ # frozen_string_literal: true + source 'https://rubygems.org' gemspec @@ -13,8 +14,8 @@ group :pry do end group :sidekiq do - gem 'sidekiq' gem 'gitlab-sidekiq-fetcher', :require => 'sidekiq-reliable-fetch' + gem 'sidekiq' end group :postgresql do @@ -26,7 +27,7 @@ group :mysql do end group :lint do - gem 'rubocop', '0.39.0' + gem 'theforeman-rubocop', '~> 0.0.4' end group :memory_watcher do @@ -35,8 +36,8 @@ end group :rails do gem 'daemons' - gem 'rails', '>= 4.2.9', '< 7' gem 'logging' + gem 'rails', '>= 4.2.9', '< 7' end group :telemetry do diff --git a/Rakefile b/Rakefile index 7a3757155..ad437eb58 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'rake/testtask' require 'fileutils' diff --git a/doc/pages/Gemfile b/doc/pages/Gemfile index 964644014..6aa75ad80 100644 --- a/doc/pages/Gemfile +++ b/doc/pages/Gemfile @@ -1,10 +1,11 @@ # frozen_string_literal: true + source 'https://rubygems.org' -gem 'rake' gem 'jekyll' gem 'pry' +gem 'pygments.rb' +gem 'rake' +gem 'redcarpet' gem 'ruby-nuggets' # require by tags plugin gem 'therubyracer' -gem 'redcarpet' -gem 'pygments.rb' diff --git a/doc/pages/Rakefile b/doc/pages/Rakefile index 410160ef7..784b92a19 100644 --- a/doc/pages/Rakefile +++ b/doc/pages/Rakefile @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'rubygems' require 'rake' diff --git a/doc/pages/plugins/alert_block.rb b/doc/pages/plugins/alert_block.rb index e1f299c32..da6e2038e 100644 --- a/doc/pages/plugins/alert_block.rb +++ b/doc/pages/plugins/alert_block.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'div_tag' module Jekyll diff --git a/doc/pages/plugins/div_tag.rb b/doc/pages/plugins/div_tag.rb index 301276dee..c726a536d 100644 --- a/doc/pages/plugins/div_tag.rb +++ b/doc/pages/plugins/div_tag.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Jekyll class DivTag < Liquid::Block def render(context) diff --git a/doc/pages/plugins/graphviz.rb b/doc/pages/plugins/graphviz.rb index 784c57be8..2e5e175f5 100644 --- a/doc/pages/plugins/graphviz.rb +++ b/doc/pages/plugins/graphviz.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true + # taken from https://raw.githubusercontent.com/kui/octopress-graphviz/master/graphviz_block.rb require 'open3' module Jekyll class GraphvizBlock < Liquid::Block - DIV_CLASS_ATTR = 'graphviz-wrapper' DEFAULT_GRAPH_NAME = 'Graphviz' DOT_OPTS = '-Tsvg' @@ -13,9 +13,9 @@ class GraphvizBlock < Liquid::Block DOT_EXTS = (ENV['PATHEXT'] || '.exe;.bat;.com').split(";") DOT_EXTS.unshift '' DOT_PATH = ENV['PATH'].split(File::PATH_SEPARATOR) - .map { |a| File.join a, DOT_EXEC } - .map { |a| DOT_EXTS.map { |ex| a+ex } }.flatten - .find { |c| File.executable_real? c } + .map { |a| File.join a, DOT_EXEC } + .map { |a| DOT_EXTS.map { |ex| a + ex } }.flatten + .find { |c| File.executable_real? c } raise "not found a executable file: #{DOT_EXEC}" if DOT_PATH.nil? DOT_CMD = "#{DOT_PATH} #{DOT_OPTS}" @@ -61,7 +61,7 @@ def filter_for_inline_svg(code) code = add_desc_attrs code code = insert_desc_elements code code = wrap_with_div code - code = code.gsub / " + filepath - result, status = Open3.capture2e(cmd, :stdin_data=>code) + result, status = Open3.capture2e(cmd, :stdin_data => code) Jekyll.logger.debug(filepath + " -->\t" + status.inspect() + "\t" + result) end @@ -79,7 +79,6 @@ def create_tmp_folder(tmproot, folder) Jekyll.logger.info("Create PlantUML image folder: " + folderpath) end end - end # PlantUMLBlock end diff --git a/doc/pages/plugins/play.rb b/doc/pages/plugins/play.rb index 615117daa..d4d33d53a 100644 --- a/doc/pages/plugins/play.rb +++ b/doc/pages/plugins/play.rb @@ -1,14 +1,13 @@ # frozen_string_literal: true + require 'pp' require 'pry' module Jekyll - class Play < Generator def generate(site) # pp site # binding.pry end - end end diff --git a/doc/pages/plugins/tags.rb b/doc/pages/plugins/tags.rb index 77b87f0ce..ffabd42bf 100644 --- a/doc/pages/plugins/tags.rb +++ b/doc/pages/plugins/tags.rb @@ -1,11 +1,10 @@ # frozen_string_literal: true + require 'nuggets/range/quantile' require 'erb' module Jekyll - class Tagger < Generator - safe true attr_accessor :site @@ -44,7 +43,7 @@ def new_tag(tag, posts) page_name = "#{pretty? ? 'index' : name}#{site.layouts[data['layout']].ext}" site.pages << TagPage.new( - site, site.source, tag_dir, page_name, data + site, site.source, tag_dir, page_name, data ) end } @@ -79,11 +78,9 @@ def active_tags def pretty? @pretty ||= (site.permalink_style == :pretty || site.config['tag_permalink_style'] == 'pretty') end - end class TagPage < Page - def initialize(site, base, dir, name, data = {}) self.content = data.delete('content') || '' self.data = data @@ -94,11 +91,9 @@ def initialize(site, base, dir, name, data = {}) def read_yaml(*) # Do nothing end - end module Filters - def tag_cloud(site) active_tag_data.map { |tag, set| tag_link(tag, tag_url(tag), :class => "set-#{set} label label-default") @@ -134,5 +129,4 @@ def active_tag_data(site = Tagger.site) site.config["tag_data"].reject { |tag, set| site.config["ignored_tags"].include? tag } end end - end diff --git a/doc/pages/plugins/toc.rb b/doc/pages/plugins/toc.rb index 216efdde3..fcf35d385 100644 --- a/doc/pages/plugins/toc.rb +++ b/doc/pages/plugins/toc.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Jekyll module FancyToCFilter def fancytoc(input) - converter = @context.registers[:site].converters.find { |c| c.is_a? Jekyll::Converters::Markdown } extensions = converter.instance_variable_get(:@parser).instance_variable_get(:@redcarpet_extensions) toc_generator = Redcarpet::Markdown.new(Redcarpet::Render::HTML_TOC, extensions) diff --git a/dynflow.gemspec b/dynflow.gemspec index 009a40fb8..64d0e1223 100644 --- a/dynflow.gemspec +++ b/dynflow.gemspec @@ -1,5 +1,6 @@ # -*- encoding: utf-8 -*- # frozen_string_literal: true + $:.push File.expand_path("../lib", __FILE__) require "dynflow/version" @@ -17,24 +18,24 @@ Gem::Specification.new do |s| s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") s.require_paths = ["lib"] - s.required_ruby_version = '>= 2.3.0' + s.required_ruby_version = '>= 2.7.0' - s.add_dependency "multi_json" - s.add_dependency "msgpack", '~> 1.3', '>= 1.3.3' - s.add_dependency "apipie-params" s.add_dependency "algebrick", '~> 0.7.0' + s.add_dependency "apipie-params" s.add_dependency "concurrent-ruby", '~> 1.1.3' s.add_dependency "concurrent-ruby-edge", '~> 0.6.0' + s.add_dependency "msgpack", '~> 1.3', '>= 1.3.3' + s.add_dependency "multi_json" s.add_dependency "sequel", '>= 4.0.0' - s.add_development_dependency "rake" - s.add_development_dependency "rack-test" + s.add_development_dependency 'activejob' + s.add_development_dependency "activerecord" s.add_development_dependency "minitest", "< 5.19" s.add_development_dependency "minitest-reporters" s.add_development_dependency "minitest-stub-const" - s.add_development_dependency "activerecord" - s.add_development_dependency 'activejob' - s.add_development_dependency "sqlite3" - s.add_development_dependency "sinatra" s.add_development_dependency 'mocha' + s.add_development_dependency "rack-test" + s.add_development_dependency "rake" + s.add_development_dependency "sinatra" + s.add_development_dependency "sqlite3" end diff --git a/examples/clock_benchmark.rb b/examples/clock_benchmark.rb index bd8d7ea03..37ffb0bd4 100644 --- a/examples/clock_benchmark.rb +++ b/examples/clock_benchmark.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'dynflow' require 'benchmark' diff --git a/examples/example_helper.rb b/examples/example_helper.rb index b6df2cd8b..9317a7d3e 100644 --- a/examples/example_helper.rb +++ b/examples/example_helper.rb @@ -1,12 +1,13 @@ # frozen_string_literal: true + $:.unshift(File.expand_path('../../lib', __FILE__)) require 'dynflow' class ExampleHelper - CONSOLE_URL='http://localhost:4567' - DYNFLOW_URL="#{CONSOLE_URL}/dynflow" - SIDEKIQ_URL="#{CONSOLE_URL}/sidekiq" + CONSOLE_URL = 'http://localhost:4567' + DYNFLOW_URL = "#{CONSOLE_URL}/dynflow" + SIDEKIQ_URL = "#{CONSOLE_URL}/sidekiq" class << self def world diff --git a/examples/future_execution.rb b/examples/future_execution.rb index 70e9f6b72..89abcc097 100755 --- a/examples/future_execution.rb +++ b/examples/future_execution.rb @@ -25,7 +25,6 @@ def deserialize(arg) end class DelayedAction < Dynflow::Action - def delay(delay_options, *args) CustomPassedObjectSerializer.new(args) end @@ -36,7 +35,6 @@ def plan(passed_object) def run end - end if $0 == __FILE__ diff --git a/examples/memory_limit_watcher.rb b/examples/memory_limit_watcher.rb index 665cfb96f..917ebf89c 100644 --- a/examples/memory_limit_watcher.rb +++ b/examples/memory_limit_watcher.rb @@ -3,14 +3,14 @@ require_relative 'example_helper' -example_description = < 'host1', - :storage_machine => 'host2') + 'host3', + 'web_server', + :db_machine => 'host1', + :storage_machine => 'host2') end end end class CreateMachine < Dynflow::Action - def plan(name, profile, config_options = {}) prepare_disk = plan_action(PrepareDisk, 'name' => name) create_vm = plan_action(CreateVM, - :name => name, - :disk => prepare_disk.output['path']) + :name => name, + :disk => prepare_disk.output['path']) plan_action(AddIPtoHosts, :name => name, :ip => create_vm.output[:ip]) plan_action(ConfigureMachine, - :ip => create_vm.output[:ip], - :profile => profile, - :config_options => config_options) + :ip => create_vm.output[:ip], + :profile => profile, + :config_options => config_options) plan_self(:name => name) end @@ -61,7 +58,6 @@ def finalize # this is called after run methods of the actions in the # execution plan were finished end - end class Base < Dynflow::Action @@ -71,7 +67,6 @@ def sleep! end class PrepareDisk < Base - def queue :slow end @@ -88,11 +83,9 @@ def run sleep! output[:path] = "/var/images/#{input[:name]}.img" end - end class CreateVM < Base - input_format do param :name param :disk @@ -106,11 +99,9 @@ def run sleep! output[:ip] = "192.168.100.#{rand(256)}" end - end class AddIPtoHosts < Base - input_format do param :ip end @@ -118,11 +109,9 @@ class AddIPtoHosts < Base def run sleep! end - end class ConfigureMachine < Base - input_format do param :ip param :profile @@ -144,7 +133,6 @@ def run sleep! end - end end diff --git a/examples/orchestrate_evented.rb b/examples/orchestrate_evented.rb index 8df844dde..9ec63f972 100755 --- a/examples/orchestrate_evented.rb +++ b/examples/orchestrate_evented.rb @@ -24,9 +24,7 @@ DESC module OrchestrateEvented - class CreateInfrastructure < Dynflow::Action - def plan(get_stuck = false) sequence do concurrence do @@ -34,59 +32,54 @@ def plan(get_stuck = false) plan_action(CreateMachine, 'host2', 'storage') end plan_action(CreateMachine, - 'host3', - 'web_server', - :db_machine => 'host1', - :storage_machine => 'host2') + 'host3', + 'web_server', + :db_machine => 'host1', + :storage_machine => 'host2') end end end class CreateMachine < Dynflow::Action - def plan(name, profile, config_options = {}) prepare_disk = plan_action(PrepareDisk, 'name' => name) create_vm = plan_action(CreateVM, - :name => name, - :disk => prepare_disk.output['path']) + :name => name, + :disk => prepare_disk.output['path']) plan_action(AddIPtoHosts, :name => name, :ip => create_vm.output[:ip]) plan_action(ConfigureMachine, - :ip => create_vm.output[:ip], - :profile => profile, - :config_options => config_options) + :ip => create_vm.output[:ip], + :profile => profile, + :config_options => config_options) plan_self(:name => name) end def finalize end - end class Base < Dynflow::Action - Finished = Algebrick.atom def run(event = nil) match(event, - (on Finished do - on_finish - end), - (on Dynflow::Action::Skip do - # do nothing - end), - (on nil do - suspend { |suspended_action| world.clock.ping suspended_action, rand(1), Finished } - end)) + (on Finished do + on_finish + end), + (on Dynflow::Action::Skip do + # do nothing + end), + (on nil do + suspend { |suspended_action| world.clock.ping suspended_action, rand(1), Finished } + end)) end def on_finish raise NotImplementedError end - end class PrepareDisk < Base - input_format do param :name end @@ -98,11 +91,9 @@ class PrepareDisk < Base def on_finish output[:path] = "/var/images/#{input[:name]}.img" end - end class CreateVM < Base - input_format do param :name param :disk @@ -115,22 +106,18 @@ class CreateVM < Base def on_finish output[:ip] = "192.168.100.#{rand(256)}" end - end class AddIPtoHosts < Base - input_format do param :ip end def on_finish end - end class ConfigureMachine < Base - # thanks to this Dynflow knows this action can be politely # asked to get canceled include ::Dynflow::Action::Cancellable @@ -163,9 +150,7 @@ def on_finish suspend end end - end - end if $0 == __FILE__ diff --git a/examples/remote_executor.rb b/examples/remote_executor.rb index c6ab59385..3823c6eb7 100755 --- a/examples/remote_executor.rb +++ b/examples/remote_executor.rb @@ -45,7 +45,6 @@ def run class RemoteExecutorExample class << self - def run_observer world = ExampleHelper.create_world do |config| config.persistence_adapter = persistence_adapter @@ -136,7 +135,6 @@ def run_client sleep 0.5 end end - end end @@ -145,17 +143,17 @@ def run_client if $0 == __FILE__ case command when 'observer' - puts < key, required do + getter = ->key, required do required ? attributes.fetch(key) : attributes.fetch(key, {}) end @@ -236,10 +236,10 @@ def plan_step # returned actions are in Present phase def planned_actions(filter = Action) phase! Present - plan_step. - planned_steps(execution_plan). - map { |s| s.action(execution_plan) }. - select { |a| a.is_a?(filter) } + plan_step + .planned_steps(execution_plan) + .map { |s| s.action(execution_plan) } + .select { |a| a.is_a?(filter) } end # @param [Class] filter_class return only actions which are kind of `filter_class` @@ -248,8 +248,8 @@ def planned_actions(filter = Action) def all_planned_actions(filter_class = Action) phase! Present mine = planned_actions - (mine + mine.reduce([]) { |arr, action| arr + action.all_planned_actions }). - select { |a| a.is_a?(filter_class) } + (mine + mine.reduce([]) { |arr, action| arr + action.all_planned_actions }) + .select { |a| a.is_a?(filter_class) } end def run_step @@ -268,18 +268,19 @@ def steps def to_hash recursive_to_hash( - { class: self.class.name, - execution_plan_id: execution_plan_id, - id: id, - plan_step_id: plan_step_id, - run_step_id: run_step_id, - finalize_step_id: finalize_step_id, - caller_execution_plan_id: caller_execution_plan_id, - caller_action_id: caller_action_id, - input: input }, - if phase? Run, Finalize, Present - { output: output } - end) + { class: self.class.name, + execution_plan_id: execution_plan_id, + id: id, + plan_step_id: plan_step_id, + run_step_id: run_step_id, + finalize_step_id: finalize_step_id, + caller_execution_plan_id: caller_execution_plan_id, + caller_action_id: caller_action_id, + input: input }, + if phase? Run, Finalize, Present + { output: output } + end + ) end def state @@ -307,7 +308,7 @@ def execute(*args) # @return [Array] - ids of steps referenced from action def required_step_ids(input = self.input) results = [] - recursion =-> value do + recursion = ->value do case value when Hash value.values.each { |v| recursion.(v) } @@ -364,9 +365,9 @@ def delayed_events def state=(state) phase! Executable @world.logger.debug format('%13s %s:%2d %9s >> %9s in phase %8s %s', - 'Step', execution_plan_id, @step.id, - self.state, state, - phase.to_s_humanized, self.class) + 'Step', execution_plan_id, @step.id, + self.state, state, + phase.to_s_humanized, self.class) @step.state = state end @@ -502,6 +503,7 @@ def with_error_handling(propagate_error = nil, &block) when :skipping self.state = :skipped when :suspended, :error + # Do nothing else raise "wrong state #{self.state}" end @@ -551,11 +553,10 @@ def execute_plan(*args) end # TODO: This is getting out of hand, refactoring needed - # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity def execute_run(event) phase! Run @world.logger.debug format('%13s %s:%2d got event %s', - 'Step', execution_plan_id, @step.id, event) if event + 'Step', execution_plan_id, @step.id, event) if event case when state == :running @@ -599,7 +600,6 @@ def execute_run(event) raise "wrong state #{state} when event:#{event}" end end - # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity def execute_finalize phase! Finalize diff --git a/lib/dynflow/action/cancellable.rb b/lib/dynflow/action/cancellable.rb index 59946e6db..c1702538b 100644 --- a/lib/dynflow/action/cancellable.rb +++ b/lib/dynflow/action/cancellable.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Action::Cancellable Cancel = Algebrick.atom diff --git a/lib/dynflow/action/format.rb b/lib/dynflow/action/format.rb index 6706bfbaa..bc9369982 100644 --- a/lib/dynflow/action/format.rb +++ b/lib/dynflow/action/format.rb @@ -1,11 +1,10 @@ # frozen_string_literal: true -module Dynflow +module Dynflow # Input/output format validation logic calling # input_format/output_format with block acts as a setter for # specifying the format. Without a block it acts as a getter module Action::Format - # we don't evaluate tbe block immediatelly, but postpone it till all the # action classes are loaded, because we can use them to reference output format def input_format(&block) @@ -41,7 +40,5 @@ def output_format(&block) end end end - end end - diff --git a/lib/dynflow/action/missing.rb b/lib/dynflow/action/missing.rb index 14c3f89bf..852da1034 100644 --- a/lib/dynflow/action/missing.rb +++ b/lib/dynflow/action/missing.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true + module Dynflow # for cases the serialized action was renamed and it's not available # in the code base anymore. class Action::Missing < Dynflow::Action - def self.generate(action_name) Class.new(self).tap do |klass| klass.singleton_class.send(:define_method, :name) do @@ -14,17 +14,17 @@ def self.generate(action_name) def plan(*args) raise StandardError, - "The action class was not found and therefore plan phase failed, this can happen if the action was added/renamed but the executor was not restarted." + "The action class was not found and therefore plan phase failed, this can happen if the action was added/renamed but the executor was not restarted." end def run raise StandardError, - "The action class was not found and therefore run phase failed, this can happen if the action was added/renamed but the executor was not restarted." + "The action class was not found and therefore run phase failed, this can happen if the action was added/renamed but the executor was not restarted." end def finalize raise StandardError, - "The action class was not found and therefore finalize phase failed, this can happen if the action was added/renamed but the executor was not restarted." + "The action class was not found and therefore finalize phase failed, this can happen if the action was added/renamed but the executor was not restarted." end end end diff --git a/lib/dynflow/action/polling.rb b/lib/dynflow/action/polling.rb index 2296644ff..6fca7b8d8 100644 --- a/lib/dynflow/action/polling.rb +++ b/lib/dynflow/action/polling.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true + require 'dynflow/action/timeouts' module Dynflow module Action::Polling - def self.included(base) base.send :include, Action::Timeouts end @@ -71,7 +71,7 @@ def attempts_before_next_interval # Returns the time to wait between two polling intervals. def poll_interval - interval_level = poll_attempts[:total]/attempts_before_next_interval + interval_level = poll_attempts[:total] / attempts_before_next_interval poll_intervals[interval_level] || poll_intervals.last end @@ -116,6 +116,5 @@ def rescue_external_task(error) raise error end end - end end diff --git a/lib/dynflow/action/progress.rb b/lib/dynflow/action/progress.rb index 691505b18..c73ec772c 100644 --- a/lib/dynflow/action/progress.rb +++ b/lib/dynflow/action/progress.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Dynflow +module Dynflow # Methods for specifying the progress of the action # the +*_progress+ methods should return number in 0..1. # The weight is there to increase/decrease the portion of this task @@ -10,9 +10,7 @@ module Dynflow # The +*_progress+ is run only when the action is in running/suspend state. Otherwise # the progress is 1 for success/skipped actions and 0 for errorneous ones. module Action::Progress - class Calculate < Middleware - def run(*args) with_progress_calculation(*args) do [action.run_progress, action.run_progress_weight] @@ -61,4 +59,3 @@ def finalize_progress_weight attr_accessor :calculated_progress end end - diff --git a/lib/dynflow/action/rescue.rb b/lib/dynflow/action/rescue.rb index 682c6151e..8b6c5bc22 100644 --- a/lib/dynflow/action/rescue.rb +++ b/lib/dynflow/action/rescue.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true + module Dynflow module Action::Rescue - Strategy = Algebrick.type do variants Skip = atom, Pause = atom, Fail = atom end @@ -65,4 +65,3 @@ def combine_suggested_strategies(suggested_strategies) end end end - diff --git a/lib/dynflow/action/singleton.rb b/lib/dynflow/action/singleton.rb index dd202f1c5..94c521c45 100644 --- a/lib/dynflow/action/singleton.rb +++ b/lib/dynflow/action/singleton.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow class Action module Singleton diff --git a/lib/dynflow/action/suspended.rb b/lib/dynflow/action/suspended.rb index 03013d8e0..cff9ed347 100644 --- a/lib/dynflow/action/suspended.rb +++ b/lib/dynflow/action/suspended.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow class Action::Suspended attr_reader :execution_plan_id, :step_id diff --git a/lib/dynflow/action/timeouts.rb b/lib/dynflow/action/timeouts.rb index cb26c9220..e09ffdb1b 100644 --- a/lib/dynflow/action/timeouts.rb +++ b/lib/dynflow/action/timeouts.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Action::Timeouts Timeout = Algebrick.atom diff --git a/lib/dynflow/action/with_bulk_sub_plans.rb b/lib/dynflow/action/with_bulk_sub_plans.rb index 6cf23f75d..61aadc9d1 100644 --- a/lib/dynflow/action/with_bulk_sub_plans.rb +++ b/lib/dynflow/action/with_bulk_sub_plans.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Action::WithBulkSubPlans include Dynflow::Action::Cancellable diff --git a/lib/dynflow/action/with_polling_sub_plans.rb b/lib/dynflow/action/with_polling_sub_plans.rb index 7b4d72ecc..4950e7f60 100644 --- a/lib/dynflow/action/with_polling_sub_plans.rb +++ b/lib/dynflow/action/with_polling_sub_plans.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true + module Dynflow module Action::WithPollingSubPlans - REFRESH_INTERVAL = 10 Poll = Algebrick.atom diff --git a/lib/dynflow/action/with_sub_plans.rb b/lib/dynflow/action/with_sub_plans.rb index 259a32743..0fcfdfb25 100644 --- a/lib/dynflow/action/with_sub_plans.rb +++ b/lib/dynflow/action/with_sub_plans.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Action::WithSubPlans include Dynflow::Action::Cancellable @@ -16,23 +17,23 @@ def backtrace def run(event = nil) match event, - (on nil do - if output[:total_count] - resume - else - initiate - end - end), - (on SubPlanFinished do - mark_as_done(event.execution_plan_id, event.success) - try_to_finish or suspend - end), - (on Action::Cancellable::Cancel do - cancel! - end), - (on Action::Cancellable::Abort do - abort! - end) + (on nil do + if output[:total_count] + resume + else + initiate + end + end), + (on SubPlanFinished do + mark_as_done(event.execution_plan_id, event.success) + try_to_finish or suspend + end), + (on Action::Cancellable::Cancel do + cancel! + end), + (on Action::Cancellable::Abort do + abort! + end) end def initiate @@ -109,8 +110,8 @@ def calculate_time_distribution # Assume concurrency level 1 unless stated otherwise level = input[:concurrency_control].fetch(:level, {}).fetch(:free, 1) semaphore = ::Dynflow::Semaphores::Stateful.new(nil, level, - :interval => time.to_f / (count * level), - :time_span => time) + :interval => time.to_f / (count * level), + :time_span => time) input[:concurrency_control][:time] = semaphore.to_hash end end diff --git a/lib/dynflow/active_job/queue_adapter.rb b/lib/dynflow/active_job/queue_adapter.rb index 678602838..59c69e400 100644 --- a/lib/dynflow/active_job/queue_adapter.rb +++ b/lib/dynflow/active_job/queue_adapter.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module ActiveJob module QueueAdapters @@ -13,7 +14,7 @@ def enqueue(job) def enqueue_at(job, timestamp) job.provider_job_id = job.job_id ::Rails.application.dynflow.world - .delay_with_options(id: job.provider_job_id, + .delay_with_options(id: job.provider_job_id, action_class: JobWrapper, delay_options: { :start_at => Time.at(timestamp) }, args: [job.serialize]) diff --git a/lib/dynflow/actor.rb b/lib/dynflow/actor.rb index 97f6c7564..84305865d 100644 --- a/lib/dynflow/actor.rb +++ b/lib/dynflow/actor.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Dynflow +module Dynflow FULL_BACKTRACE = %w[1 y yes].include?((ENV['DYNFLOW_FULL_BACKTRACE'] || '').downcase) BACKTRACE_LIMIT = begin limit = ENV['DYNFLOW_BACKTRACE_LIMIT'].to_i @@ -94,7 +94,7 @@ def filter_line(line) # takes an array of backtrace lines and replaces each chunk def filter_backtrace(backtrace) trace = backtrace.map { |line| filter_line(line) } - .chunk_while { |l1, l2| l1 == l2} + .chunk_while { |l1, l2| l1 == l2 } .map(&:first) if BACKTRACE_LIMIT count = trace.count diff --git a/lib/dynflow/actors.rb b/lib/dynflow/actors.rb index c759fc313..2e2008fca 100644 --- a/lib/dynflow/actors.rb +++ b/lib/dynflow/actors.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Actors require 'dynflow/actors/execution_plan_cleaner' diff --git a/lib/dynflow/actors/execution_plan_cleaner.rb b/lib/dynflow/actors/execution_plan_cleaner.rb index 47d6a7e1d..c85192047 100644 --- a/lib/dynflow/actors/execution_plan_cleaner.rb +++ b/lib/dynflow/actors/execution_plan_cleaner.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Actors class ExecutionPlanCleaner diff --git a/lib/dynflow/clock.rb b/lib/dynflow/clock.rb index 29ff6bd9a..3655769cd 100644 --- a/lib/dynflow/clock.rb +++ b/lib/dynflow/clock.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true + module Dynflow class Clock < Actor - include Algebrick::Types Timer = Algebrick.type do @@ -13,7 +13,7 @@ class Clock < Actor module Timer def self.[](*fields) - super(*fields).tap { |v| Match! v.who, -> who { who.respond_to? v.where } } + super(*fields).tap { |v| Match! v.who, ->who { who.respond_to? v.where } } end include Comparable @@ -116,7 +116,7 @@ def current_time def ping(who, time, with_what = nil, where = :<<, optional: false) Type! time, Time, Numeric - time = current_time + time if time.is_a? Numeric + time = current_time + time if time.is_a? Numeric if who.is_a?(Action::Suspended) who.plan_event(with_what, time, optional: optional) else @@ -125,5 +125,4 @@ def ping(who, time, with_what = nil, where = :<<, optional: false) end end end - end diff --git a/lib/dynflow/config.rb b/lib/dynflow/config.rb index b1c978679..79bd4178d 100644 --- a/lib/dynflow/config.rb +++ b/lib/dynflow/config.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'socket' module Dynflow @@ -6,11 +7,11 @@ class Config include Algebrick::TypeCheck def self.config_attr(name, *types, &default) - self.send(:define_method, "validate_#{ name }!") do |value| + self.send(:define_method, "validate_#{name}!") do |value| Type! value, *types unless types.empty? end self.send(:define_method, name) do - var_name = "@#{ name }" + var_name = "@#{name}" if instance_variable_defined?(var_name) return instance_variable_get(var_name) else @@ -41,7 +42,7 @@ def method_missing(name) return @cache[name] if @cache.key?(name) value = @config.send(name) value = value.call(@world, self) if value.is_a? Proc - validation_method = "validate_#{ name }!" + validation_method = "validate_#{name}!" @config.send(validation_method, value) if @config.respond_to?(validation_method) @cache[name] = value end @@ -51,7 +52,7 @@ class QueuesConfig attr_reader :queues def initialize - @queues = {:default => {}} + @queues = { :default => {} } end # Add a new queue to the configuration @@ -204,7 +205,7 @@ def validate(config_for_world) "it's #{ar_pool_size} but there is #{config_for_world.pool_size} " + 'threads in Dynflow pool.' end - rescue ActiveRecord::ConnectionNotEstablished # rubocop:disable Lint/HandleExceptions + rescue ActiveRecord::ConnectionNotEstablished # If in tests or in an environment where ActiveRecord doesn't have a # real DB connection, we want to skip AR configuration altogether end diff --git a/lib/dynflow/connectors.rb b/lib/dynflow/connectors.rb index 7b180ad06..2a01c3f33 100644 --- a/lib/dynflow/connectors.rb +++ b/lib/dynflow/connectors.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Connectors require 'dynflow/connectors/abstract' diff --git a/lib/dynflow/connectors/abstract.rb b/lib/dynflow/connectors/abstract.rb index 7ce9604a3..ce57eaf71 100644 --- a/lib/dynflow/connectors/abstract.rb +++ b/lib/dynflow/connectors/abstract.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Connectors class Abstract @@ -35,16 +36,16 @@ def receive(world, envelope) Type! envelope, Dispatcher::Envelope Telemetry.with_instance { |t| t.increment_counter(:dynflow_connector_envelopes, 1, :world => world.id, :direction => 'incoming') } match(envelope.message, - (on Dispatcher::Ping do - response_envelope = envelope.build_response_envelope(Dispatcher::Pong, world) - send(response_envelope) - end), - (on Dispatcher::Request do - world.executor_dispatcher.tell([:handle_request, envelope]) - end), - (on Dispatcher::Response do - world.client_dispatcher.tell([:dispatch_response, envelope]) - end)) + (on Dispatcher::Ping do + response_envelope = envelope.build_response_envelope(Dispatcher::Pong, world) + send(response_envelope) + end), + (on Dispatcher::Request do + world.executor_dispatcher.tell([:handle_request, envelope]) + end), + (on Dispatcher::Response do + world.client_dispatcher.tell([:dispatch_response, envelope]) + end)) end end end diff --git a/lib/dynflow/connectors/database.rb b/lib/dynflow/connectors/database.rb index 0c231abbe..5d7cca9a3 100644 --- a/lib/dynflow/connectors/database.rb +++ b/lib/dynflow/connectors/database.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Dynflow module Connectors class Database < Abstract - class PostgresListerner def initialize(core, world_id, db) @core = core @@ -22,7 +22,7 @@ def started? def start @started.set true @thread = Thread.new do - @db.listen("world:#{ @world_id }", :loop => true) do + @db.listen("world:#{@world_id}", :loop => true) do if started? @core << :check_inbox else diff --git a/lib/dynflow/connectors/direct.rb b/lib/dynflow/connectors/direct.rb index b586bcd5d..503b39ba0 100644 --- a/lib/dynflow/connectors/direct.rb +++ b/lib/dynflow/connectors/direct.rb @@ -1,10 +1,9 @@ # frozen_string_literal: true + module Dynflow module Connectors class Direct < Abstract - class Core < Actor - def initialize(connector) @connector = connector @worlds = {} @@ -30,7 +29,7 @@ def handle_envelope(envelope) if world = find_receiver(envelope) @connector.receive(world, envelope) else - log(Logger::ERROR, "Receiver for envelope #{ envelope } not found") + log(Logger::ERROR, "Receiver for envelope #{envelope} not found") end end diff --git a/lib/dynflow/coordinator.rb b/lib/dynflow/coordinator.rb index 6cce9bc48..267de13a4 100644 --- a/lib/dynflow/coordinator.rb +++ b/lib/dynflow/coordinator.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true + require 'dynflow/coordinator_adapters' module Dynflow class Coordinator - include Algebrick::TypeCheck class DuplicateRecordError < Dynflow::Error @@ -41,7 +41,7 @@ def self.constantize(name) end def initialize(*args) - @data ||= {} + @data = {} @data = Utils.indifferent_hash(@data.merge(class: self.class.name)) end diff --git a/lib/dynflow/coordinator_adapters.rb b/lib/dynflow/coordinator_adapters.rb index 39e521525..6942d0271 100644 --- a/lib/dynflow/coordinator_adapters.rb +++ b/lib/dynflow/coordinator_adapters.rb @@ -1,9 +1,8 @@ # frozen_string_literal: true + module Dynflow module CoordinatorAdapters - require 'dynflow/coordinator_adapters/abstract' require 'dynflow/coordinator_adapters/sequel' - end end diff --git a/lib/dynflow/coordinator_adapters/abstract.rb b/lib/dynflow/coordinator_adapters/abstract.rb index e9f8b3ca3..5a395387a 100644 --- a/lib/dynflow/coordinator_adapters/abstract.rb +++ b/lib/dynflow/coordinator_adapters/abstract.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module CoordinatorAdapters class Abstract diff --git a/lib/dynflow/coordinator_adapters/sequel.rb b/lib/dynflow/coordinator_adapters/sequel.rb index 54df6aeb4..f9c821d01 100644 --- a/lib/dynflow/coordinator_adapters/sequel.rb +++ b/lib/dynflow/coordinator_adapters/sequel.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module CoordinatorAdapters class Sequel < Abstract diff --git a/lib/dynflow/dead_letter_silencer.rb b/lib/dynflow/dead_letter_silencer.rb index c2faa500f..493c2d8cc 100644 --- a/lib/dynflow/dead_letter_silencer.rb +++ b/lib/dynflow/dead_letter_silencer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow class DeadLetterSilencer < Concurrent::Actor::DefaultDeadLetterHandler def initialize(matchers) diff --git a/lib/dynflow/debug/telemetry/persistence.rb b/lib/dynflow/debug/telemetry/persistence.rb index 16219ea2e..ad5cb38ca 100644 --- a/lib/dynflow/debug/telemetry/persistence.rb +++ b/lib/dynflow/debug/telemetry/persistence.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Debug module Telemetry @@ -32,7 +33,7 @@ module Persistence methods.each do |name| define_method(name) do |*args| - Dynflow::Telemetry.measure(:dynflow_persistence, :method => name, :world => @world.id) { super *args } + Dynflow::Telemetry.measure(:dynflow_persistence, :method => name, :world => @world.id) { super(*args) } end end end @@ -40,4 +41,4 @@ module Persistence end end -::Dynflow::Persistence.send(:prepend, ::Dynflow::Debug::Persistence) +::Dynflow::Persistence.prepend ::Dynflow::Debug::Persistence diff --git a/lib/dynflow/delayed_executors.rb b/lib/dynflow/delayed_executors.rb index f6d9ab302..7d8a0f957 100644 --- a/lib/dynflow/delayed_executors.rb +++ b/lib/dynflow/delayed_executors.rb @@ -1,10 +1,9 @@ # frozen_string_literal: true + module Dynflow module DelayedExecutors - require 'dynflow/delayed_executors/abstract' require 'dynflow/delayed_executors/abstract_core' require 'dynflow/delayed_executors/polling' - end end diff --git a/lib/dynflow/delayed_executors/abstract.rb b/lib/dynflow/delayed_executors/abstract.rb index 674a715a5..073efafaf 100644 --- a/lib/dynflow/delayed_executors/abstract.rb +++ b/lib/dynflow/delayed_executors/abstract.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Dynflow module DelayedExecutors class Abstract - attr_reader :core def initialize(world, options = {}) @@ -39,7 +39,6 @@ def spawn def core_class raise NotImplementedError end - end end end diff --git a/lib/dynflow/delayed_executors/abstract_core.rb b/lib/dynflow/delayed_executors/abstract_core.rb index fe03134f4..ec1d08e68 100644 --- a/lib/dynflow/delayed_executors/abstract_core.rb +++ b/lib/dynflow/delayed_executors/abstract_core.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Dynflow module DelayedExecutors class AbstractCore < Actor - include Algebrick::TypeCheck attr_reader :world, :logger diff --git a/lib/dynflow/delayed_executors/polling.rb b/lib/dynflow/delayed_executors/polling.rb index dc8f0981f..6fa373928 100644 --- a/lib/dynflow/delayed_executors/polling.rb +++ b/lib/dynflow/delayed_executors/polling.rb @@ -1,12 +1,11 @@ # frozen_string_literal: true + module Dynflow module DelayedExecutors class Polling < Abstract - def core_class Dynflow::DelayedExecutors::PollingCore end - end class PollingCore < AbstractCore diff --git a/lib/dynflow/delayed_plan.rb b/lib/dynflow/delayed_plan.rb index ee0b974c4..972ac8c52 100644 --- a/lib/dynflow/delayed_plan.rb +++ b/lib/dynflow/delayed_plan.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true + module Dynflow class DelayedPlan < Serializable - include Algebrick::TypeCheck attr_reader :execution_plan_uuid, :start_before @@ -72,11 +72,11 @@ def args def self.new_from_hash(world, hash, *args) serializer = Utils.constantize(hash[:args_serializer]).new(nil, hash[:serialized_args]) self.new(world, - hash[:execution_plan_uuid], - string_to_time(hash[:start_at]), - string_to_time(hash[:start_before]), - serializer, - hash[:frozen] || false) + hash[:execution_plan_uuid], + string_to_time(hash[:start_at]), + string_to_time(hash[:start_before]), + serializer, + hash[:frozen] || false) rescue NameError => e error(e.message) end diff --git a/lib/dynflow/director.rb b/lib/dynflow/director.rb index 87aad97b4..2e5fde186 100644 --- a/lib/dynflow/director.rb +++ b/lib/dynflow/director.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow # Director is responsible for telling what to do next when: # * new execution starts @@ -75,9 +76,9 @@ def to_hash def self.new_from_hash(hash, *_args) self.new(hash[:execution_plan_id], - Serializable.from_hash(hash[:step], hash[:execution_plan_id], Dynflow.process_world), - hash[:queue], - hash[:sender_orchestrator_id]) + Serializable.from_hash(hash[:step], hash[:execution_plan_id], Dynflow.process_world), + hash[:queue], + hash[:sender_orchestrator_id]) end end @@ -100,11 +101,11 @@ def to_hash def self.new_from_hash(hash, *_args) self.new(hash[:request_id], - hash[:execution_plan_id], - Serializable.from_hash(hash[:step], hash[:execution_plan_id], Dynflow.process_world), - Dynflow.serializer.load(hash[:event]), - hash[:queue], - hash[:sender_orchestrator_id]) + hash[:execution_plan_id], + Serializable.from_hash(hash[:step], hash[:execution_plan_id], Dynflow.process_world), + Dynflow.serializer.load(hash[:event]), + hash[:queue], + hash[:sender_orchestrator_id]) end end @@ -301,16 +302,16 @@ def track_execution_plan(execution_plan_id, finished) if @execution_plan_managers[execution_plan_id] raise Dynflow::Error, - "cannot execute execution_plan_id:#{execution_plan_id} it's already running" + "cannot execute execution_plan_id:#{execution_plan_id} it's already running" end if execution_plan.state == :stopped raise Dynflow::Error, - "cannot execute execution_plan_id:#{execution_plan_id} it's stopped" + "cannot execute execution_plan_id:#{execution_plan_id} it's stopped" end @execution_plan_managers[execution_plan_id] = - ExecutionPlanManager.new(@world, execution_plan, finished) + ExecutionPlanManager.new(@world, execution_plan, finished) rescue Dynflow::Error => e finished.reject e nil diff --git a/lib/dynflow/director/execution_plan_manager.rb b/lib/dynflow/director/execution_plan_manager.rb index 07a88c13e..e729dc62c 100644 --- a/lib/dynflow/director/execution_plan_manager.rb +++ b/lib/dynflow/director/execution_plan_manager.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow class Director class ExecutionPlanManager @@ -118,7 +119,6 @@ def start_finalize def finish return no_work end - end end end diff --git a/lib/dynflow/director/flow_manager.rb b/lib/dynflow/director/flow_manager.rb index eb8ca89a9..42c0855de 100644 --- a/lib/dynflow/director/flow_manager.rb +++ b/lib/dynflow/director/flow_manager.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow class Director class FlowManager diff --git a/lib/dynflow/director/queue_hash.rb b/lib/dynflow/director/queue_hash.rb index 7eda48265..2844e0b42 100644 --- a/lib/dynflow/director/queue_hash.rb +++ b/lib/dynflow/director/queue_hash.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow class Director class QueueHash @@ -7,7 +8,7 @@ class QueueHash def initialize(key_type = Object, value_type = Object) @key_type = key_type @value_type = value_type - @stash = Hash.new { |hash, key| hash[key] = [] } + @stash = Hash.new { |hash, key| hash[key] = [] } end def push(key, value) diff --git a/lib/dynflow/director/running_steps_manager.rb b/lib/dynflow/director/running_steps_manager.rb index 802db3213..11639678a 100644 --- a/lib/dynflow/director/running_steps_manager.rb +++ b/lib/dynflow/director/running_steps_manager.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow class Director # Handles the events generated while running actions, makes sure @@ -50,13 +51,13 @@ def done(step) while (work = @work_items.shift(step.id)) @world.logger.debug "step #{step.execution_plan_id}:#{step.id} dropping event #{work.request_id}/#{work.event}" finish_event_result(work) do |f| - f.reject UnprocessableEvent.new("Message dropped").tap { |e| e.set_backtrace(caller) } + f.reject(UnprocessableEvent.new("Message dropped").tap { |e| e.set_backtrace(caller) }) end end while (event = @events.shift(step.id)) @world.logger.debug "step #{step.execution_plan_id}:#{step.id} dropping event #{event.request_id}/#{event}" if event.result - event.result.reject UnprocessableEvent.new("Message dropped").tap { |e| e.set_backtrace(caller) } + event.result.reject(UnprocessableEvent.new("Message dropped").tap { |e| e.set_backtrace(caller) }) end end unless @work_items.empty?(step.id) && @events.empty?(step.id) diff --git a/lib/dynflow/director/sequence_cursor.rb b/lib/dynflow/director/sequence_cursor.rb index 073539872..791a92a0e 100644 --- a/lib/dynflow/director/sequence_cursor.rb +++ b/lib/dynflow/director/sequence_cursor.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Dynflow class Director class SequenceCursor - def initialize(flow_manager, sequence, parent_cursor = nil) @flow_manager = flow_manager @sequence = sequence @@ -86,7 +86,6 @@ def add_todo(flow) @todo << @flow_manager.execution_plan.steps[flow.step_id] end end - end end end diff --git a/lib/dynflow/director/sequential_manager.rb b/lib/dynflow/director/sequential_manager.rb index 30cf5741f..d478aa086 100644 --- a/lib/dynflow/director/sequential_manager.rb +++ b/lib/dynflow/director/sequential_manager.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow class Director class SequentialManager diff --git a/lib/dynflow/dispatcher.rb b/lib/dynflow/dispatcher.rb index dfea6e504..ab839ee19 100644 --- a/lib/dynflow/dispatcher.rb +++ b/lib/dynflow/dispatcher.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Dispatcher Request = Algebrick.type do @@ -33,10 +34,10 @@ module Dispatcher Response = Algebrick.type do variants Accepted = atom, - Failed = type { fields! error: String }, - Done = atom, - Pong = atom, - ExecutionStatus = type { fields! execution_status: Hash } + Failed = type { fields! error: String }, + Done = atom, + Pong = atom, + ExecutionStatus = type { fields! execution_status: Hash } end Envelope = Algebrick.type do @@ -49,9 +50,9 @@ module Dispatcher module Envelope def build_response_envelope(response_message, sender) Envelope[self.request_id, - sender.id, - self.sender_id, - response_message] + sender.id, + self.sender_id, + response_message] end end diff --git a/lib/dynflow/dispatcher/abstract.rb b/lib/dynflow/dispatcher/abstract.rb index 0decdea45..278ad5672 100644 --- a/lib/dynflow/dispatcher/abstract.rb +++ b/lib/dynflow/dispatcher/abstract.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Dispatcher class Abstract < Actor diff --git a/lib/dynflow/dispatcher/client_dispatcher.rb b/lib/dynflow/dispatcher/client_dispatcher.rb index fc436660f..8e7d68300 100644 --- a/lib/dynflow/dispatcher/client_dispatcher.rb +++ b/lib/dynflow/dispatcher/client_dispatcher.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Dynflow module Dispatcher class ClientDispatcher < Abstract - TrackedRequest = Algebrick.type do fields! id: String, request: Request, accepted: Concurrent::Promises::ResolvableFuture, finished: Concurrent::Promises::ResolvableFuture @@ -134,16 +134,16 @@ def start_termination(*args) def dispatch_request(request, client_world_id, request_id) ignore_unknown = false executor_id = match request, - (on ~Execution | ~Planning do |execution| - AnyExecutor - end), - (on ~Event do |event| - ignore_unknown = event.optional - find_executor(event.execution_plan_id) - end), - (on Ping.(~any, ~any) | Status.(~any, ~any) do |receiver_id, _| - receiver_id - end) + (on ~Execution | ~Planning do |execution| + AnyExecutor + end), + (on ~Event do |event| + ignore_unknown = event.optional + find_executor(event.execution_plan_id) + end), + (on Ping.(~any, ~any) | Status.(~any, ~any) do |receiver_id, _| + receiver_id + end) envelope = Envelope[request_id, client_world_id, executor_id, request] if Dispatcher::UnknownWorld === envelope.receiver_id raise Dynflow::Error, "Could not find an executor for #{envelope}" unless ignore_unknown @@ -161,22 +161,22 @@ def dispatch_request(request, client_world_id, request_id) def dispatch_response(envelope) return unless @tracked_requests.key?(envelope.request_id) match envelope.message, - (on ~Accepted do - @tracked_requests[envelope.request_id].accept! - end), - (on ~Failed do |msg| - resolve_tracked_request(envelope.request_id, Dynflow::Error.new(msg.error)) - end), - (on Done do - resolve_tracked_request(envelope.request_id) - end), - (on Pong do - add_ping_cache_record(envelope.sender_id) - resolve_tracked_request(envelope.request_id) - end), - (on ExecutionStatus.(~any) do |steps| - @tracked_requests.delete(envelope.request_id).success! steps - end) + (on ~Accepted do + @tracked_requests[envelope.request_id].accept! + end), + (on ~Failed do |msg| + resolve_tracked_request(envelope.request_id, Dynflow::Error.new(msg.error)) + end), + (on Done do + resolve_tracked_request(envelope.request_id) + end), + (on Pong do + add_ping_cache_record(envelope.sender_id) + resolve_tracked_request(envelope.request_id) + end), + (on ExecutionStatus.(~any) do |steps| + @tracked_requests.delete(envelope.request_id).success! steps + end) end # Records when was the world with provided id last seen using a PingCache @@ -233,12 +233,12 @@ def resolve_tracked_request(id, error = nil) else tracked_request = @tracked_requests[id] resolve_to = match tracked_request.request, - (on Execution.(execution_plan_id: ~any) do |uuid| - @world.persistence.load_execution_plan(uuid) - end), - (on Event | Ping do - true - end) + (on Execution.(execution_plan_id: ~any) do |uuid| + @world.persistence.load_execution_plan(uuid) + end), + (on Event | Ping do + true + end) @tracked_requests.delete(id).success! resolve_to end end diff --git a/lib/dynflow/dispatcher/executor_dispatcher.rb b/lib/dynflow/dispatcher/executor_dispatcher.rb index d8ae0d12c..9de385473 100644 --- a/lib/dynflow/dispatcher/executor_dispatcher.rb +++ b/lib/dynflow/dispatcher/executor_dispatcher.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Dispatcher class ExecutorDispatcher < Abstract @@ -9,10 +10,10 @@ def initialize(world, semaphore) def handle_request(envelope) match(envelope.message, - on(Planning) { perform_planning(envelope, envelope.message)}, - on(Execution) { perform_execution(envelope, envelope.message) }, - on(Event) { perform_event(envelope, envelope.message) }, - on(Status) { get_execution_status(envelope, envelope.message) }) + on(Planning) { perform_planning(envelope, envelope.message) }, + on(Execution) { perform_execution(envelope, envelope.message) }, + on(Event) { perform_event(envelope, envelope.message) }, + on(Status) { get_execution_status(envelope, envelope.message) }) end protected @@ -61,13 +62,13 @@ def perform_event(envelope, event_request) end if event_request.time.nil? || event_request.time < Time.now @world.executor.event(envelope.request_id, event_request.execution_plan_id, event_request.step_id, event_request.event, future, - optional: event_request.optional) + optional: event_request.optional) else @world.clock.ping( @world.executor, event_request.time, Director::Event[envelope.request_id, event_request.execution_plan_id, event_request.step_id, event_request.event, Concurrent::Promises.resolvable_future, - event_request.optional], + event_request.optional], :delayed_event ) # resolves the future right away - currently we do not wait for the clock ping diff --git a/lib/dynflow/errors.rb b/lib/dynflow/errors.rb index 1c52ddda9..4d0efe566 100644 --- a/lib/dynflow/errors.rb +++ b/lib/dynflow/errors.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Errors class RescueError < StandardError; end diff --git a/lib/dynflow/execution_history.rb b/lib/dynflow/execution_history.rb index 34385c2cd..25bedab8c 100644 --- a/lib/dynflow/execution_history.rb +++ b/lib/dynflow/execution_history.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow class ExecutionHistory include Algebrick::TypeCheck @@ -35,7 +36,7 @@ def to_hash end def inspect - "ExecutionHistory: #{ @events.inspect }" + "ExecutionHistory: #{@events.inspect}" end def self.new_from_hash(value) diff --git a/lib/dynflow/execution_plan.rb b/lib/dynflow/execution_plan.rb index 787dfeb8c..971ff3fc9 100644 --- a/lib/dynflow/execution_plan.rb +++ b/lib/dynflow/execution_plan.rb @@ -1,18 +1,18 @@ # frozen_string_literal: true + require 'securerandom' module Dynflow # rubocop:disable Metrics/ClassLength # TODO extract planning logic to an extra class ExecutionPlanner class ExecutionPlan < Serializable - # a fallback object representing a plan with some corrupted data, # preventing to load the whole plan properly, this can be used for presenting # at least some data and not running into internal server errors class InvalidPlan attr_reader :exception, :id, :label, :state, - :started_at, :ended_at, - :execution_time, :real_time, :execution_history + :started_at, :ended_at, + :execution_time, :real_time, :execution_history def initialize(exception, id, label, state, started_at = nil, ended_at = nil, @@ -45,8 +45,8 @@ def result require 'dynflow/execution_plan/dependency_graph' attr_reader :id, :world, :label, - :root_plan_step, :steps, :run_flow, :finalize_flow, - :started_at, :ended_at, :execution_time, :real_time, :execution_history + :root_plan_step, :steps, :run_flow, :finalize_flow, + :started_at, :ended_at, :execution_time, :real_time, :execution_history def self.states @states ||= [:pending, :scheduled, :planning, :planned, :running, :paused, :stopped] @@ -83,9 +83,9 @@ def initialize(world, real_time = 0.0, execution_history = ExecutionHistory.new) id ||= SecureRandom.uuid - @id = Type! id, String - @world = Type! world, World - @label = Type! label, String, NilClass + @id = Type! id, String + @world = Type! world, World + @label = Type! label, String, NilClass self.state = state @run_flow = Type! run_flow, Flows::Abstract @finalize_flow = Type! finalize_flow, Flows::Abstract @@ -130,7 +130,7 @@ def update_state(state, history_notice: :auto) key = failure? ? :failure : :success Dynflow::Telemetry.with_instance do |t| t.increment_counter(:dynflow_finished_execution_plans, 1, - telemetry_common_options.merge(:result => key.to_s)) + telemetry_common_options.merge(:result => key.to_s)) end hooks_to_run << key unlock_all_singleton_locks! @@ -140,11 +140,11 @@ def update_state(state, history_notice: :auto) # ignore end logger.debug format('%13s %s %9s >> %9s', - 'ExecutionPlan', id, original, state) + 'ExecutionPlan', id, original, state) add_history_notice(history_notice) self.save toggle_telemetry_state original == :pending ? nil : original.to_s, - self.state == :stopped ? nil : self.state.to_s + self.state == :stopped ? nil : self.state.to_s hooks_to_run.each { |kind| run_hooks kind } end @@ -238,7 +238,7 @@ def failed_steps end def steps_in_state(*states) - self.steps.values.find_all {|step| states.include?(step.state) } + self.steps.values.find_all { |step| states.include?(step.state) } end def generate_action_id @@ -257,11 +257,11 @@ def delay(caller_action, action_class, delay_options, *args) run_hooks(:pending) serializer = root_plan_step.delay(delay_options, args) delayed_plan = DelayedPlan.new(@world, - id, - delay_options[:start_at], - delay_options.fetch(:start_before, nil), - serializer, - delay_options[:frozen] || false) + id, + delay_options[:start_at], + delay_options.fetch(:start_before, nil), + serializer, + delay_options[:frozen] || false) persistence.save_delayed_plan(delayed_plan) ensure update_state(error? ? :stopped : :scheduled) @@ -455,36 +455,36 @@ def self.new_from_hash(hash, world) execution_plan_id = hash[:id] steps = steps_from_hash(hash[:step_ids], execution_plan_id, world) self.new(world, - execution_plan_id, - hash[:label], - hash[:state], - steps[hash[:root_plan_step_id]], - load_flow(hash[:run_flow]), - load_flow(hash[:finalize_flow]), - steps, - string_to_time(hash[:started_at]), - string_to_time(hash[:ended_at]), - hash[:execution_time].to_f, - hash[:real_time].to_f, - ExecutionHistory.new_from_hash(hash[:execution_history])) + execution_plan_id, + hash[:label], + hash[:state], + steps[hash[:root_plan_step_id]], + load_flow(hash[:run_flow]), + load_flow(hash[:finalize_flow]), + steps, + string_to_time(hash[:started_at]), + string_to_time(hash[:ended_at]), + hash[:execution_time].to_f, + hash[:real_time].to_f, + ExecutionHistory.new_from_hash(hash[:execution_history])) rescue => plan_exception begin world.logger.error("Could not load execution plan #{execution_plan_id}") world.logger.error(plan_exception) InvalidPlan.new(plan_exception, execution_plan_id, - hash[:label], - hash[:state], - string_to_time(hash[:started_at]), - string_to_time(hash[:ended_at]), - hash[:execution_time].to_f, - hash[:real_time].to_f, - ExecutionHistory.new_from_hash(hash[:execution_history])) + hash[:label], + hash[:state], + string_to_time(hash[:started_at]), + string_to_time(hash[:ended_at]), + hash[:execution_time].to_f, + hash[:real_time].to_f, + ExecutionHistory.new_from_hash(hash[:execution_history])) rescue => invalid_plan_exception world.logger.error("Could not even load a fallback execution plan for #{execution_plan_id}") world.logger.error(invalid_plan_exception) InvalidPlan.new(invalid_plan_exception, execution_plan_id, - hash[:label], - hash[:state]) + hash[:label], + hash[:state]) end end @@ -530,12 +530,12 @@ def persistence def add_step(step_class, action_class, action_id, state = :pending) step_class.new(self.id, - self.generate_step_id, - state, - action_class, - action_id, - nil, - world).tap do |new_step| + self.generate_step_id, + state, + action_class, + action_id, + nil, + world).tap do |new_step| @steps[new_step.id] = new_step end end @@ -571,9 +571,9 @@ def toggle_telemetry_state(original, new) @label = root_plan_step.action_class if @label.nil? Dynflow::Telemetry.with_instance do |t| t.set_gauge(:dynflow_active_execution_plans, '-1', - telemetry_common_options.merge(:state => original)) unless original.nil? + telemetry_common_options.merge(:state => original)) unless original.nil? t.set_gauge(:dynflow_active_execution_plans, '+1', - telemetry_common_options.merge(:state => new)) unless new.nil? + telemetry_common_options.merge(:state => new)) unless new.nil? end end diff --git a/lib/dynflow/execution_plan/dependency_graph.rb b/lib/dynflow/execution_plan/dependency_graph.rb index eda0143a7..01c8379f2 100644 --- a/lib/dynflow/execution_plan/dependency_graph.rb +++ b/lib/dynflow/execution_plan/dependency_graph.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true + module Dynflow class ExecutionPlan::DependencyGraph - def initialize @graph = Hash.new { |h, k| h[k] = Set.new } end @@ -25,6 +25,5 @@ def mark_satisfied(step_id, required_step_id) def unresolved? @graph.any? { |step_id, required_step_ids| required_step_ids.any? } end - end end diff --git a/lib/dynflow/execution_plan/hooks.rb b/lib/dynflow/execution_plan/hooks.rb index 283afd5bc..c2d9f5758 100644 --- a/lib/dynflow/execution_plan/hooks.rb +++ b/lib/dynflow/execution_plan/hooks.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Dynflow class ExecutionPlan module Hooks - HOOK_KINDS = (ExecutionPlan.states + [:success, :failure]).freeze # A register holding information about hook classes and events diff --git a/lib/dynflow/execution_plan/output_reference.rb b/lib/dynflow/execution_plan/output_reference.rb index af7242838..be167a0fe 100644 --- a/lib/dynflow/execution_plan/output_reference.rb +++ b/lib/dynflow/execution_plan/output_reference.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow class ExecutionPlan::OutputReference < Serializable include Algebrick::TypeCheck @@ -77,10 +78,9 @@ def dereference(persistence) def self.new_from_hash(hash) check_class_matching hash new(hash.fetch(:execution_plan_id), - hash.fetch(:step_id), - hash.fetch(:action_id), - hash.fetch(:subkeys)) + hash.fetch(:step_id), + hash.fetch(:action_id), + hash.fetch(:subkeys)) end - end end diff --git a/lib/dynflow/execution_plan/steps.rb b/lib/dynflow/execution_plan/steps.rb index e98968f3c..935050b9d 100644 --- a/lib/dynflow/execution_plan/steps.rb +++ b/lib/dynflow/execution_plan/steps.rb @@ -1,13 +1,12 @@ # frozen_string_literal: true + module Dynflow module ExecutionPlan::Steps - require 'dynflow/execution_plan/steps/error' require 'dynflow/execution_plan/steps/abstract' require 'dynflow/execution_plan/steps/abstract_flow_step' require 'dynflow/execution_plan/steps/plan_step' require 'dynflow/execution_plan/steps/run_step' require 'dynflow/execution_plan/steps/finalize_step' - end end diff --git a/lib/dynflow/execution_plan/steps/abstract.rb b/lib/dynflow/execution_plan/steps/abstract.rb index 38fedd428..7bb962b5e 100644 --- a/lib/dynflow/execution_plan/steps/abstract.rb +++ b/lib/dynflow/execution_plan/steps/abstract.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module ExecutionPlan::Steps class Abstract < Serializable @@ -6,7 +7,7 @@ class Abstract < Serializable include Stateful attr_reader :execution_plan_id, :id, :state, :action_class, :action_id, :world, :started_at, - :ended_at, :execution_time, :real_time, :queue, :delayed_events + :ended_at, :execution_time, :real_time, :queue, :delayed_events attr_accessor :error # rubocop:disable Metrics/ParameterLists @@ -37,7 +38,7 @@ def initialize(execution_plan_id, @progress_done = Type! progress_done, Numeric, NilClass @progress_weight = Type! progress_weight, Numeric, NilClass - @queue = Type! queue, Symbol, NilClass + @queue = Type! queue, Symbol, NilClass self.state = state.to_sym @@ -144,25 +145,25 @@ def with_sub_plans? def self.new_from_hash(hash, execution_plan_id, world) check_class_matching hash new(execution_plan_id, - hash[:id], - hash[:state], - Action.constantize(hash[:action_class]), - hash[:action_id], - hash_to_error(hash[:error]), - world, - string_to_time(hash[:started_at]), - string_to_time(hash[:ended_at]), - hash[:execution_time].to_f, - hash[:real_time].to_f, - hash[:progress_done].to_f, - hash[:progress_weight].to_f, - (hash[:queue] && hash[:queue].to_sym)) + hash[:id], + hash[:state], + Action.constantize(hash[:action_class]), + hash[:action_id], + hash_to_error(hash[:error]), + world, + string_to_time(hash[:started_at]), + string_to_time(hash[:ended_at]), + hash[:execution_time].to_f, + hash[:real_time].to_f, + hash[:progress_done].to_f, + hash[:progress_weight].to_f, + (hash[:queue] && hash[:queue].to_sym)) end private def with_meta_calculation(action, &block) - start = Time.now.utc + start = Time.now.utc @started_at ||= start block.call ensure @@ -186,12 +187,12 @@ def update_step_telemetry(current_execution_time) Dynflow::Telemetry.with_instance do |t| if [:success, :skipped].include?(state) t.observe_histogram(:dynflow_step_real_time, - real_time * 1000, - :action => action_class.to_s, :phase => phase.to_s_humanized) + real_time * 1000, + :action => action_class.to_s, :phase => phase.to_s_humanized) end t.observe_histogram(:dynflow_step_execution_time, - current_execution_time * 1000, - :action => action_class.to_s, :phase => phase.to_s_humanized) + current_execution_time * 1000, + :action => action_class.to_s, :phase => phase.to_s_humanized) end end end diff --git a/lib/dynflow/execution_plan/steps/abstract_flow_step.rb b/lib/dynflow/execution_plan/steps/abstract_flow_step.rb index f9c471b23..f922b578e 100644 --- a/lib/dynflow/execution_plan/steps/abstract_flow_step.rb +++ b/lib/dynflow/execution_plan/steps/abstract_flow_step.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Dynflow module ExecutionPlan::Steps class AbstractFlowStep < Abstract - # Method called when initializing the step to customize the behavior based on the # action definition during the planning phase def update_from_action(action) diff --git a/lib/dynflow/execution_plan/steps/error.rb b/lib/dynflow/execution_plan/steps/error.rb index c6ea2d400..b7ae5c121 100644 --- a/lib/dynflow/execution_plan/steps/error.rb +++ b/lib/dynflow/execution_plan/steps/error.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module ExecutionPlan::Steps class Error < Serializable @@ -11,12 +12,12 @@ def self.new(*args) case args.size when 1 match obj = args.first, - (on String do - super(StandardError, obj, caller, nil) - end), - (on Exception do - super(obj.class, obj.message, obj.backtrace, obj) - end) + (on String do + super(StandardError, obj, caller, nil) + end), + (on Exception do + super(obj.class, obj.message, obj.backtrace, obj) + end) when 3, 4 super(*args.values_at(0..3)) else @@ -49,9 +50,9 @@ def to_hash def to_s format '%s (%s)\n%s', - (@exception || self).message, - (@exception ? @exception.class : exception_class), - (@exception || self).backtrace + (@exception || self).message, + (@exception ? @exception.class : exception_class), + (@exception || self).backtrace end def exception diff --git a/lib/dynflow/execution_plan/steps/finalize_step.rb b/lib/dynflow/execution_plan/steps/finalize_step.rb index c59cd9800..57532153c 100644 --- a/lib/dynflow/execution_plan/steps/finalize_step.rb +++ b/lib/dynflow/execution_plan/steps/finalize_step.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Dynflow module ExecutionPlan::Steps class FinalizeStep < AbstractFlowStep - def self.state_transitions @state_transitions ||= { pending: [:running, :skipped], # :skipped when its run_step is skipped @@ -27,7 +27,6 @@ def mark_to_skip self.state = :skipped self.save end - end end end diff --git a/lib/dynflow/execution_plan/steps/plan_step.rb b/lib/dynflow/execution_plan/steps/plan_step.rb index ebe694bab..6e14e27f7 100644 --- a/lib/dynflow/execution_plan/steps/plan_step.rb +++ b/lib/dynflow/execution_plan/steps/plan_step.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module ExecutionPlan::Steps class PlanStep < Abstract @@ -73,17 +74,17 @@ def self.state_transitions def self.new_from_hash(hash, execution_plan_id, world) check_class_matching hash new execution_plan_id, - hash[:id], - hash[:state], - Action.constantize(hash[:action_class]), - hash[:action_id], - hash_to_error(hash[:error]), - world, - string_to_time(hash[:started_at]), - string_to_time(hash[:ended_at]), - hash[:execution_time], - hash[:real_time], - hash[:children] + hash[:id], + hash[:state], + Action.constantize(hash[:action_class]), + hash[:action_id], + hash_to_error(hash[:error]), + world, + string_to_time(hash[:started_at]), + string_to_time(hash[:ended_at]), + hash[:execution_time], + hash[:real_time], + hash[:children] end def load_action diff --git a/lib/dynflow/execution_plan/steps/run_step.rb b/lib/dynflow/execution_plan/steps/run_step.rb index be68cbcf3..9b76eceaa 100644 --- a/lib/dynflow/execution_plan/steps/run_step.rb +++ b/lib/dynflow/execution_plan/steps/run_step.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Dynflow module ExecutionPlan::Steps class RunStep < AbstractFlowStep - def self.state_transitions @state_transitions ||= { pending: [:running, :skipped, :error], # :skipped when it cannot be run because it depends on skipping step diff --git a/lib/dynflow/executors.rb b/lib/dynflow/executors.rb index 00523f720..155b2a650 100644 --- a/lib/dynflow/executors.rb +++ b/lib/dynflow/executors.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true + module Dynflow module Executors - require 'dynflow/executors/parallel' class << self diff --git a/lib/dynflow/executors/abstract/core.rb b/lib/dynflow/executors/abstract/core.rb index cbac0568d..5669e3622 100644 --- a/lib/dynflow/executors/abstract/core.rb +++ b/lib/dynflow/executors/abstract/core.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Executors module Abstract @@ -20,7 +21,7 @@ def initialize(world, heartbeat_interval, queues_options) def handle_execution(execution_plan_id, finished) if terminating? raise Dynflow::Error, - "cannot accept execution_plan_id:#{execution_plan_id} core is terminating" + "cannot accept execution_plan_id:#{execution_plan_id} core is terminating" end handle_work(@director.start_execution(execution_plan_id, finished)) @@ -30,7 +31,7 @@ def handle_event(event) Type! event, Director::Event if terminating? raise Dynflow::Error, - "cannot accept event: #{event} core is terminating" + "cannot accept event: #{event} core is terminating" end handle_work(@director.handle_event(event)) end @@ -38,7 +39,7 @@ def handle_event(event) def handle_planning(execution_plan_id) if terminating? raise Dynflow::Error, - "cannot accept event: #{event} core is terminating" + "cannot accept event: #{event} core is terminating" end handle_work(@director.handle_planning(execution_plan_id)) diff --git a/lib/dynflow/executors/parallel.rb b/lib/dynflow/executors/parallel.rb index 63d28fdee..c9c26fd4a 100644 --- a/lib/dynflow/executors/parallel.rb +++ b/lib/dynflow/executors/parallel.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Executors class Parallel @@ -12,7 +13,7 @@ class Parallel def initialize(world, executor_class:, heartbeat_interval:, - queues_options: { :default => { :pool_size => 5 }}) + queues_options: { :default => { :pool_size => 5 } }) @world = world @logger = world.logger @core = executor_class.spawn name: 'parallel-executor-core', diff --git a/lib/dynflow/executors/parallel/core.rb b/lib/dynflow/executors/parallel/core.rb index 33aa9c147..572bad5ec 100644 --- a/lib/dynflow/executors/parallel/core.rb +++ b/lib/dynflow/executors/parallel/core.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'dynflow/executors/parallel/pool' require 'dynflow/executors/parallel/worker' @@ -19,8 +20,8 @@ def initialize_queues @queues_options.each do |(queue_name, queue_options)| queue_pool_size = queue_options.fetch(:pool_size, default_pool_size) @pools[queue_name] = Pool.spawn("pool #{queue_name}", @world, - reference, queue_name, queue_pool_size, - @world.transaction_adapter) + reference, queue_name, queue_pool_size, + @world.transaction_adapter) end end diff --git a/lib/dynflow/executors/parallel/pool.rb b/lib/dynflow/executors/parallel/pool.rb index 0b0693121..983b0eb83 100644 --- a/lib/dynflow/executors/parallel/pool.rb +++ b/lib/dynflow/executors/parallel/pool.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Executors class Parallel diff --git a/lib/dynflow/executors/parallel/worker.rb b/lib/dynflow/executors/parallel/worker.rb index e4fe49a68..2ab5cce45 100644 --- a/lib/dynflow/executors/parallel/worker.rb +++ b/lib/dynflow/executors/parallel/worker.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Executors class Parallel diff --git a/lib/dynflow/executors/sidekiq/core.rb b/lib/dynflow/executors/sidekiq/core.rb index 9d730c173..f09ef6089 100644 --- a/lib/dynflow/executors/sidekiq/core.rb +++ b/lib/dynflow/executors/sidekiq/core.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'dynflow/executors/sidekiq/serialization' require 'dynflow/executors/sidekiq/internal_job_base' require 'dynflow/executors/sidekiq/orchestrator_jobs' diff --git a/lib/dynflow/executors/sidekiq/internal_job_base.rb b/lib/dynflow/executors/sidekiq/internal_job_base.rb index ebf4fdb30..b76d5fea1 100644 --- a/lib/dynflow/executors/sidekiq/internal_job_base.rb +++ b/lib/dynflow/executors/sidekiq/internal_job_base.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Executors module Sidekiq diff --git a/lib/dynflow/executors/sidekiq/orchestrator_jobs.rb b/lib/dynflow/executors/sidekiq/orchestrator_jobs.rb index c14d4d9ec..9044a95af 100644 --- a/lib/dynflow/executors/sidekiq/orchestrator_jobs.rb +++ b/lib/dynflow/executors/sidekiq/orchestrator_jobs.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Executors module Sidekiq diff --git a/lib/dynflow/executors/sidekiq/redis_locking.rb b/lib/dynflow/executors/sidekiq/redis_locking.rb index 80d29aa4c..5a4e668b9 100644 --- a/lib/dynflow/executors/sidekiq/redis_locking.rb +++ b/lib/dynflow/executors/sidekiq/redis_locking.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Executors module Sidekiq diff --git a/lib/dynflow/executors/sidekiq/serialization.rb b/lib/dynflow/executors/sidekiq/serialization.rb index bb9869eba..9603dbb0f 100644 --- a/lib/dynflow/executors/sidekiq/serialization.rb +++ b/lib/dynflow/executors/sidekiq/serialization.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Executors module Sidekiq diff --git a/lib/dynflow/executors/sidekiq/worker_jobs.rb b/lib/dynflow/executors/sidekiq/worker_jobs.rb index 5bf7b5fe1..98abdd855 100644 --- a/lib/dynflow/executors/sidekiq/worker_jobs.rb +++ b/lib/dynflow/executors/sidekiq/worker_jobs.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Executors module Sidekiq diff --git a/lib/dynflow/extensions.rb b/lib/dynflow/extensions.rb index 7692c0a13..ac96f9e4f 100644 --- a/lib/dynflow/extensions.rb +++ b/lib/dynflow/extensions.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Extensions require 'dynflow/extensions/msgpack' diff --git a/lib/dynflow/extensions/msgpack.rb b/lib/dynflow/extensions/msgpack.rb index c4b542c5c..cf96bf526 100644 --- a/lib/dynflow/extensions/msgpack.rb +++ b/lib/dynflow/extensions/msgpack.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'msgpack' module Dynflow @@ -25,13 +26,13 @@ def to_msgpack(out = ''.dup) ::DateTime.include ::Dynflow::Extensions::MsgPack::Time ::MessagePack::DefaultFactory.register_type(0x02, DateTime, - packer: ->(datetime) { MessagePack::Time::Packer.(datetime.to_time) }, - unpacker: ->(payload) { unpacker.(payload).to_datetime }) + packer: ->(datetime) { MessagePack::Time::Packer.(datetime.to_time) }, + unpacker: ->(payload) { unpacker.(payload).to_datetime }) ::Date.include ::Dynflow::Extensions::MsgPack::Time ::MessagePack::DefaultFactory.register_type(0x03, Date, - packer: ->(date) { MessagePack::Time::Packer.(date.to_time) }, - unpacker: ->(payload) { unpacker.(payload).to_date }) + packer: ->(date) { MessagePack::Time::Packer.(date.to_time) }, + unpacker: ->(payload) { unpacker.(payload).to_date }) rescue LoadError # This is fine nil diff --git a/lib/dynflow/flows.rb b/lib/dynflow/flows.rb index 2c934a767..4d1c7748d 100644 --- a/lib/dynflow/flows.rb +++ b/lib/dynflow/flows.rb @@ -1,15 +1,14 @@ # frozen_string_literal: true + require 'forwardable' module Dynflow module Flows - require 'dynflow/flows/registry' require 'dynflow/flows/abstract' require 'dynflow/flows/atom' require 'dynflow/flows/abstract_composed' require 'dynflow/flows/concurrence' require 'dynflow/flows/sequence' - end end diff --git a/lib/dynflow/flows/abstract.rb b/lib/dynflow/flows/abstract.rb index fe1971d0a..06ae4048e 100644 --- a/lib/dynflow/flows/abstract.rb +++ b/lib/dynflow/flows/abstract.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true + module Dynflow module Flows - class Abstract < Serializable include Algebrick::TypeCheck diff --git a/lib/dynflow/flows/abstract_composed.rb b/lib/dynflow/flows/abstract_composed.rb index 453be8003..c659ac4d4 100644 --- a/lib/dynflow/flows/abstract_composed.rb +++ b/lib/dynflow/flows/abstract_composed.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Dynflow module Flows class AbstractComposed < Abstract - attr_reader :flows def initialize(flows) @@ -94,7 +94,6 @@ def expand_steps(index) index += 1 end end - end end end diff --git a/lib/dynflow/flows/atom.rb b/lib/dynflow/flows/atom.rb index 250cd0fcc..b93566468 100644 --- a/lib/dynflow/flows/atom.rb +++ b/lib/dynflow/flows/atom.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Dynflow module Flows class Atom < Abstract - attr_reader :step_id def encode @@ -31,7 +31,6 @@ def self.new_from_hash(hash) check_class_matching hash new(hash[:step_id]) end - end end end diff --git a/lib/dynflow/flows/concurrence.rb b/lib/dynflow/flows/concurrence.rb index cd80464bf..3814d3274 100644 --- a/lib/dynflow/flows/concurrence.rb +++ b/lib/dynflow/flows/concurrence.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Dynflow module Flows class Concurrence < AbstractComposed - protected def add_to_sequence(satisfying_flows, dependent_flow) diff --git a/lib/dynflow/flows/registry.rb b/lib/dynflow/flows/registry.rb index 660a55ad2..7702bc71e 100644 --- a/lib/dynflow/flows/registry.rb +++ b/lib/dynflow/flows/registry.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Flows class Registry diff --git a/lib/dynflow/flows/sequence.rb b/lib/dynflow/flows/sequence.rb index d9dfe02cf..0f636ebd4 100644 --- a/lib/dynflow/flows/sequence.rb +++ b/lib/dynflow/flows/sequence.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Dynflow module Flows class Sequence < AbstractComposed - protected def add_to_sequence(satisfying_flows, dependent_flow) diff --git a/lib/dynflow/logger_adapters.rb b/lib/dynflow/logger_adapters.rb index 95de88000..3ef33085f 100644 --- a/lib/dynflow/logger_adapters.rb +++ b/lib/dynflow/logger_adapters.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module LoggerAdapters require 'dynflow/logger_adapters/formatters' diff --git a/lib/dynflow/logger_adapters/abstract.rb b/lib/dynflow/logger_adapters/abstract.rb index c890435b9..d5d5164a3 100644 --- a/lib/dynflow/logger_adapters/abstract.rb +++ b/lib/dynflow/logger_adapters/abstract.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Dynflow module LoggerAdapters class Abstract - # @returns [#fatal, #error, #warn, #info, #debug] logger object for logging errors from action execution def action_logger raise NotImplementedError diff --git a/lib/dynflow/logger_adapters/delegator.rb b/lib/dynflow/logger_adapters/delegator.rb index 17fd8ce39..85636fd31 100644 --- a/lib/dynflow/logger_adapters/delegator.rb +++ b/lib/dynflow/logger_adapters/delegator.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Dynflow module LoggerAdapters class Delegator < Abstract - attr_reader :action_logger, :dynflow_logger def initialize(action_logger, dynflow_logger, formatters = [Formatters::Exception]) diff --git a/lib/dynflow/logger_adapters/formatters.rb b/lib/dynflow/logger_adapters/formatters.rb index 740c555de..6180160f7 100644 --- a/lib/dynflow/logger_adapters/formatters.rb +++ b/lib/dynflow/logger_adapters/formatters.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module LoggerAdapters module Formatters diff --git a/lib/dynflow/logger_adapters/formatters/abstract.rb b/lib/dynflow/logger_adapters/formatters/abstract.rb index 1542b7851..a51a1035c 100644 --- a/lib/dynflow/logger_adapters/formatters/abstract.rb +++ b/lib/dynflow/logger_adapters/formatters/abstract.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module LoggerAdapters module Formatters diff --git a/lib/dynflow/logger_adapters/formatters/exception.rb b/lib/dynflow/logger_adapters/formatters/exception.rb index e28df393e..f82c7df3d 100644 --- a/lib/dynflow/logger_adapters/formatters/exception.rb +++ b/lib/dynflow/logger_adapters/formatters/exception.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module LoggerAdapters module Formatters diff --git a/lib/dynflow/logger_adapters/simple.rb b/lib/dynflow/logger_adapters/simple.rb index b0979f4d6..e389092ee 100644 --- a/lib/dynflow/logger_adapters/simple.rb +++ b/lib/dynflow/logger_adapters/simple.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'English' module Dynflow @@ -28,11 +29,11 @@ def level=(v) def formatter(severity, datetime, prog_name, msg) format "[%s #%d] %5s -- %s%s\n", - datetime.strftime('%Y-%m-%d %H:%M:%S.%L'), - $PID, - severity, - (prog_name ? prog_name + ': ' : ''), - msg.to_s + datetime.strftime('%Y-%m-%d %H:%M:%S.%L'), + $PID, + severity, + (prog_name ? prog_name + ': ' : ''), + msg.to_s end class ProgNameWrapper diff --git a/lib/dynflow/middleware.rb b/lib/dynflow/middleware.rb index 4b8f85f31..f9945e4d3 100644 --- a/lib/dynflow/middleware.rb +++ b/lib/dynflow/middleware.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow class Middleware require 'dynflow/middleware/register' diff --git a/lib/dynflow/middleware/common/singleton.rb b/lib/dynflow/middleware/common/singleton.rb index f1e7c041e..ec5977f40 100644 --- a/lib/dynflow/middleware/common/singleton.rb +++ b/lib/dynflow/middleware/common/singleton.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Middleware::Common class Singleton < Middleware diff --git a/lib/dynflow/middleware/common/transaction.rb b/lib/dynflow/middleware/common/transaction.rb index cb57a2bde..9915be0a8 100644 --- a/lib/dynflow/middleware/common/transaction.rb +++ b/lib/dynflow/middleware/common/transaction.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Middleware::Common class Transaction < Middleware diff --git a/lib/dynflow/middleware/register.rb b/lib/dynflow/middleware/register.rb index 01612f373..753858966 100644 --- a/lib/dynflow/middleware/register.rb +++ b/lib/dynflow/middleware/register.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow class Middleware::Register include Algebrick::TypeCheck diff --git a/lib/dynflow/middleware/resolver.rb b/lib/dynflow/middleware/resolver.rb index 11a313a6a..f7649b203 100644 --- a/lib/dynflow/middleware/resolver.rb +++ b/lib/dynflow/middleware/resolver.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true + require 'tsort' module Dynflow class Middleware::Resolver - include TSort include Algebrick::TypeCheck @@ -49,7 +49,7 @@ def normalize_rules(rules) middleware_deps.reject! { |dep| !deps.has_key?(dep) } end - return deps.delete_if {|klass, _| klass.nil? } + return deps.delete_if { |klass, _| klass.nil? } end def tsort_each_node(&block) @@ -59,6 +59,5 @@ def tsort_each_node(&block) def tsort_each_child(node, &block) @deps.fetch(node).each(&block) end - end end diff --git a/lib/dynflow/middleware/stack.rb b/lib/dynflow/middleware/stack.rb index 0c30e9ff2..4592a9ab1 100644 --- a/lib/dynflow/middleware/stack.rb +++ b/lib/dynflow/middleware/stack.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow class Middleware::Stack include Algebrick::TypeCheck diff --git a/lib/dynflow/middleware/world.rb b/lib/dynflow/middleware/world.rb index 91024666d..a4e6cec1f 100644 --- a/lib/dynflow/middleware/world.rb +++ b/lib/dynflow/middleware/world.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true + module Dynflow class Middleware::World - include Algebrick::TypeCheck def initialize @@ -54,6 +54,5 @@ def middleware_classes(action_class) end return @middleware_classes_cache[action_class] end - end end diff --git a/lib/dynflow/persistence.rb b/lib/dynflow/persistence.rb index 60c33ca57..7facce490 100644 --- a/lib/dynflow/persistence.rb +++ b/lib/dynflow/persistence.rb @@ -1,10 +1,9 @@ # frozen_string_literal: true + require 'dynflow/persistence_adapters' module Dynflow - class Persistence - include Algebrick::TypeCheck attr_reader :adapter @@ -18,9 +17,9 @@ def initialize(world, persistence_adapter, options = {}) end def load_action(step) - attributes = adapter. - load_action(step.execution_plan_id, step.action_id). - update(step: step, phase: step.phase) + attributes = adapter + .load_action(step.execution_plan_id, step.action_id) + .update(step: step, phase: step.phase) return Action.from_hash(attributes, step.world) end diff --git a/lib/dynflow/persistence_adapters.rb b/lib/dynflow/persistence_adapters.rb index 01a6516b6..825d7f819 100644 --- a/lib/dynflow/persistence_adapters.rb +++ b/lib/dynflow/persistence_adapters.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module PersistenceAdapters require 'dynflow/persistence_adapters/abstract' diff --git a/lib/dynflow/persistence_adapters/abstract.rb b/lib/dynflow/persistence_adapters/abstract.rb index c043b2cbb..94509b061 100644 --- a/lib/dynflow/persistence_adapters/abstract.rb +++ b/lib/dynflow/persistence_adapters/abstract.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Dynflow module PersistenceAdapters class Abstract - # The logger is set by the world when used inside it attr_accessor :logger diff --git a/lib/dynflow/persistence_adapters/sequel.rb b/lib/dynflow/persistence_adapters/sequel.rb index 5b1e1785c..db91b2942 100644 --- a/lib/dynflow/persistence_adapters/sequel.rb +++ b/lib/dynflow/persistence_adapters/sequel.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'sequel' require 'msgpack' require 'fileutils' @@ -7,7 +8,6 @@ # rubocop:disable Metrics/ClassLength module Dynflow module PersistenceAdapters - Sequel.extension :migration Sequel.database_timezone = :utc @@ -67,10 +67,10 @@ def find_execution_plans(options = {}) table_name = :execution_plan options[:order_by] ||= :started_at data_set = filter(table_name, - order(table_name, - paginate(table(table_name), options), - options), - options[:filters]) + order(table_name, + paginate(table(table_name), options), + options), + options[:filters]) data_set.all.map { |record| execution_plan_column_map(load_data(record, table_name)) } end @@ -80,7 +80,7 @@ def find_execution_plan_counts(options = {}) def find_execution_plan_statuses(options) plans = filter(:execution_plan, table(:execution_plan), options[:filters]) - .select(:uuid, :state, :result) + .select(:uuid, :state, :result) plans.each_with_object({}) do |current, acc| uuid = current.delete(:uuid) @@ -169,7 +169,7 @@ def load_steps(execution_plan_id) def save_step(execution_plan_id, step_id, value, update_conditions = {}) save :step, { execution_plan_uuid: execution_plan_id, id: step_id }, value, - with_data: false, update_conditions: update_conditions + with_data: false, update_conditions: update_conditions end def load_action(execution_plan_id, action_id) @@ -254,7 +254,7 @@ def insert_coordinator_record(value) def update_coordinator_record(class_name, record_id, value) coordinator_feature! - save :coordinator_record, {class: class_name, :id => record_id}, value + save :coordinator_record, { class: class_name, :id => record_id }, value end def delete_coordinator_record(class_name, record_id) @@ -365,7 +365,7 @@ def save(what, condition, value, with_data: true, update_conditions: {}) def load_record(what, condition) table = table(what) - if (record = with_retry { table.first(Utils.symbolize_keys(condition)) } ) + if (record = with_retry { table.first(Utils.symbolize_keys(condition)) }) load_data(record, what) else raise KeyError, "searching: #{what} by: #{condition.inspect}" @@ -491,13 +491,13 @@ def filter(what, data_set, filters) end if filters.key?('caller_execution_plan_id') - data_set = data_set.join_table(:inner, TABLES[:action], :execution_plan_uuid => :uuid). - select_all(TABLES[:execution_plan]).distinct + data_set = data_set.join_table(:inner, TABLES[:action], :execution_plan_uuid => :uuid) + .select_all(TABLES[:execution_plan]).distinct end if filters.key?('delayed') filters.delete('delayed') - data_set = data_set.join_table(:inner, TABLES[:delayed], :execution_plan_uuid => :uuid). - select_all(TABLES[:execution_plan]).distinct + data_set = data_set.join_table(:inner, TABLES[:delayed], :execution_plan_uuid => :uuid) + .select_all(TABLES[:execution_plan]).distinct end end diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/001_initial.rb b/lib/dynflow/persistence_adapters/sequel_migrations/001_initial.rb index 1263c40ba..ce7529451 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/001_initial.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/001_initial.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Sequel.migration do up do create_table(:dynflow_execution_plans) do @@ -33,7 +34,7 @@ index [:execution_plan_uuid, :id], :unique => true column :action_id, Integer foreign_key [:execution_plan_uuid, :action_id], :dynflow_actions, - name: :dynflow_steps_execution_plan_uuid_fkey1 + name: :dynflow_steps_execution_plan_uuid_fkey1 index [:execution_plan_uuid, :action_id] column :data, String, text: true diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/002_incremental_progress.rb b/lib/dynflow/persistence_adapters/sequel_migrations/002_incremental_progress.rb index 2b2a4e410..cfaf26af5 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/002_incremental_progress.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/002_incremental_progress.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Sequel.migration do change do alter_table(:dynflow_steps) do diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/003_parent_action.rb b/lib/dynflow/persistence_adapters/sequel_migrations/003_parent_action.rb index 0e535ee33..59c93432f 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/003_parent_action.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/003_parent_action.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Sequel.migration do change do alter_table(:dynflow_actions) do diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/004_coordinator_records.rb b/lib/dynflow/persistence_adapters/sequel_migrations/004_coordinator_records.rb index 25e0ac214..3dd4e2dbe 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/004_coordinator_records.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/004_coordinator_records.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Sequel.migration do change do create_table(:dynflow_coordinator_records) do @@ -12,4 +13,3 @@ end end end - diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/005_envelopes.rb b/lib/dynflow/persistence_adapters/sequel_migrations/005_envelopes.rb index 9e5ad91be..187d4a6a0 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/005_envelopes.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/005_envelopes.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Sequel.migration do change do create_table(:dynflow_envelopes) do diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/006_fix_data_length.rb b/lib/dynflow/persistence_adapters/sequel_migrations/006_fix_data_length.rb index 6ea8069ec..ad7c8ac80 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/006_fix_data_length.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/006_fix_data_length.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Sequel.migration do up do alter_table(:dynflow_steps) do diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/007_future_execution.rb b/lib/dynflow/persistence_adapters/sequel_migrations/007_future_execution.rb index cdbe1238d..93cfa5aa1 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/007_future_execution.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/007_future_execution.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Sequel.migration do change do create_table(:dynflow_scheduled_plans) do diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/008_rename_scheduled_plans_to_delayed_plans.rb b/lib/dynflow/persistence_adapters/sequel_migrations/008_rename_scheduled_plans_to_delayed_plans.rb index 8f2eb7040..94985c5d9 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/008_rename_scheduled_plans_to_delayed_plans.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/008_rename_scheduled_plans_to_delayed_plans.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Sequel.migration do change do rename_table(:dynflow_scheduled_plans, :dynflow_delayed_plans) diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/009_fix_mysql_data_length.rb b/lib/dynflow/persistence_adapters/sequel_migrations/009_fix_mysql_data_length.rb index 730a323f9..df49e691a 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/009_fix_mysql_data_length.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/009_fix_mysql_data_length.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Sequel.migration do affected_tables = [:dynflow_actions, :dynflow_coordinator_records, :dynflow_delayed_plans, :dynflow_envelopes, :dynflow_execution_plans] @@ -22,4 +23,3 @@ end end end - diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/010_add_execution_plans_label.rb b/lib/dynflow/persistence_adapters/sequel_migrations/010_add_execution_plans_label.rb index eefd67ab9..77f05f381 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/010_add_execution_plans_label.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/010_add_execution_plans_label.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Sequel.migration do change do alter_table(:dynflow_execution_plans) do diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/011_placeholder.rb b/lib/dynflow/persistence_adapters/sequel_migrations/011_placeholder.rb index 38e1ed058..92955bdfe 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/011_placeholder.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/011_placeholder.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Sequel.migration do # Placeholder for 011_add_uuid_column.rb - it was readded in # 018_add_uuid_column.rb with fixed check for postgresql diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/012_add_delayed_plans_serialized_args.rb b/lib/dynflow/persistence_adapters/sequel_migrations/012_add_delayed_plans_serialized_args.rb index 936c8d084..daedc1eb7 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/012_add_delayed_plans_serialized_args.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/012_add_delayed_plans_serialized_args.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Sequel.migration do change do alter_table(:dynflow_delayed_plans) do diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/013_add_action_columns.rb b/lib/dynflow/persistence_adapters/sequel_migrations/013_add_action_columns.rb index ab79e6dce..f1877689a 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/013_add_action_columns.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/013_add_action_columns.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Sequel.migration do change do alter_table(:dynflow_actions) do diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/014_add_step_columns.rb b/lib/dynflow/persistence_adapters/sequel_migrations/014_add_step_columns.rb index 6aadb9022..08171e04c 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/014_add_step_columns.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/014_add_step_columns.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Sequel.migration do change do alter_table(:dynflow_steps) do diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/015_add_execution_plan_columns.rb b/lib/dynflow/persistence_adapters/sequel_migrations/015_add_execution_plan_columns.rb index 836ce43d8..236836ffe 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/015_add_execution_plan_columns.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/015_add_execution_plan_columns.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Sequel.migration do change do alter_table(:dynflow_execution_plans) do diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/016_add_step_queue.rb b/lib/dynflow/persistence_adapters/sequel_migrations/016_add_step_queue.rb index aed5792a2..296c95a8e 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/016_add_step_queue.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/016_add_step_queue.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Sequel.migration do change do alter_table(:dynflow_steps) do diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/017_add_delayed_plan_frozen.rb b/lib/dynflow/persistence_adapters/sequel_migrations/017_add_delayed_plan_frozen.rb index 31d97ff74..2026cb255 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/017_add_delayed_plan_frozen.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/017_add_delayed_plan_frozen.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Sequel.migration do change do alter_table(:dynflow_delayed_plans) do diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/018_add_uuid_column.rb b/lib/dynflow/persistence_adapters/sequel_migrations/018_add_uuid_column.rb index 5b648d801..1f59640c0 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/018_add_uuid_column.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/018_add_uuid_column.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + helper = Module.new do def to_uuid(table_name, column_name) set_column_type(table_name, column_name, :uuid, :using => "#{column_name}::uuid") @@ -30,11 +31,11 @@ def with_foreign_key_recreation(&block) alter_table :dynflow_steps do add_foreign_key [:execution_plan_uuid], :dynflow_execution_plans add_foreign_key [:execution_plan_uuid, :action_id], :dynflow_actions, - :name => :dynflow_steps_execution_plan_uuid_fkey1 + :name => :dynflow_steps_execution_plan_uuid_fkey1 end alter_table :dynflow_delayed_plans do add_foreign_key [:execution_plan_uuid], :dynflow_execution_plans, - :name => :dynflow_scheduled_plans_execution_plan_uuid_fkey + :name => :dynflow_scheduled_plans_execution_plan_uuid_fkey end end end diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/019_update_mysql_time_precision.rb b/lib/dynflow/persistence_adapters/sequel_migrations/019_update_mysql_time_precision.rb index 20ef54b85..25308a39e 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/019_update_mysql_time_precision.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/019_update_mysql_time_precision.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Sequel.migration do up do alter_table(:dynflow_execution_plans) do diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/020_drop_duplicate_indices.rb b/lib/dynflow/persistence_adapters/sequel_migrations/020_drop_duplicate_indices.rb index 99b55a4f3..8b8b87be2 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/020_drop_duplicate_indices.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/020_drop_duplicate_indices.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Sequel.migration do up do alter_table(:dynflow_actions) do diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/021_create_output_chunks.rb b/lib/dynflow/persistence_adapters/sequel_migrations/021_create_output_chunks.rb index 72fe0fa0d..14a114141 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/021_create_output_chunks.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/021_create_output_chunks.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Sequel.migration do up do type = database_type @@ -6,16 +7,16 @@ primary_key :id column_properties = if type.to_s.include?('postgres') - {type: :uuid} + { type: :uuid } else - {type: String, size: 36, fixed: true, null: false} + { type: String, size: 36, fixed: true, null: false } end foreign_key :execution_plan_uuid, :dynflow_execution_plans, **column_properties index :execution_plan_uuid column :action_id, Integer, null: false foreign_key [:execution_plan_uuid, :action_id], :dynflow_actions, - name: :dynflow_output_chunks_execution_plan_uuid_fkey1 + name: :dynflow_output_chunks_execution_plan_uuid_fkey1 index [:execution_plan_uuid, :action_id] column :chunk, String, text: true diff --git a/lib/dynflow/persistence_adapters/sequel_migrations/023_sqlite_workarounds.rb b/lib/dynflow/persistence_adapters/sequel_migrations/023_sqlite_workarounds.rb index 51c84e4b0..f85be570b 100644 --- a/lib/dynflow/persistence_adapters/sequel_migrations/023_sqlite_workarounds.rb +++ b/lib/dynflow/persistence_adapters/sequel_migrations/023_sqlite_workarounds.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + tables = [:dynflow_actions, :dynflow_delayed_plans, :dynflow_steps, :dynflow_output_chunks] Sequel.migration do up do diff --git a/lib/dynflow/rails.rb b/lib/dynflow/rails.rb index d644d3d5f..c24424ad9 100644 --- a/lib/dynflow/rails.rb +++ b/lib/dynflow/rails.rb @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # frozen_string_literal: true + module Dynflow # Class for configuring and preparing the Dynflow runtime environment. class Rails @@ -32,8 +33,8 @@ def initialize! return @world if @world if config.lazy_initialization && defined?(::PhusionPassenger) - config.dynflow_logger. - warn('Dynflow: lazy loading with PhusionPassenger might lead to unexpected results') + config.dynflow_logger + .warn('Dynflow: lazy loading with PhusionPassenger might lead to unexpected results') end init_world.tap do |world| @world = world diff --git a/lib/dynflow/rails/configuration.rb b/lib/dynflow/rails/configuration.rb index 46005d5d2..f3c778813 100644 --- a/lib/dynflow/rails/configuration.rb +++ b/lib/dynflow/rails/configuration.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'rails' require 'active_record' diff --git a/lib/dynflow/rails/daemon.rb b/lib/dynflow/rails/daemon.rb index 25f968eba..5b401717d 100644 --- a/lib/dynflow/rails/daemon.rb +++ b/lib/dynflow/rails/daemon.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'fileutils' require 'get_process_mem' require 'dynflow/watchers/memory_consumption_watcher' @@ -175,7 +176,6 @@ def to_gb(string) else raise "Unknown unit: #{unit.inspect}!" end end - end end end diff --git a/lib/dynflow/round_robin.rb b/lib/dynflow/round_robin.rb index 12625e47d..b6e3cb505 100644 --- a/lib/dynflow/round_robin.rb +++ b/lib/dynflow/round_robin.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow # A simple round-robin scheduling implementation used at various # places in Dynflow @@ -19,7 +20,7 @@ def delete(item) end def next - @cursor = 0 if @cursor > @data.size-1 + @cursor = 0 if @cursor > @data.size - 1 @data[@cursor] ensure @cursor += 1 @@ -35,4 +36,3 @@ def empty? attr_writer :data end end - diff --git a/lib/dynflow/semaphores.rb b/lib/dynflow/semaphores.rb index b427b86fa..c69d76e40 100644 --- a/lib/dynflow/semaphores.rb +++ b/lib/dynflow/semaphores.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Semaphores require 'dynflow/semaphores/abstract' diff --git a/lib/dynflow/semaphores/abstract.rb b/lib/dynflow/semaphores/abstract.rb index 431339246..ad1c9abb4 100644 --- a/lib/dynflow/semaphores/abstract.rb +++ b/lib/dynflow/semaphores/abstract.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Dynflow module Semaphores class Abstract - # Tries to get ticket from the semaphore # Returns true if thing got a ticket # Rturns false otherwise and puts the thing into the semaphore's queue diff --git a/lib/dynflow/semaphores/aggregating.rb b/lib/dynflow/semaphores/aggregating.rb index f964ab5b5..12bb1c01a 100644 --- a/lib/dynflow/semaphores/aggregating.rb +++ b/lib/dynflow/semaphores/aggregating.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Dynflow module Semaphores class Aggregating < Abstract - attr_reader :children, :waiting def initialize(children) @@ -58,7 +58,6 @@ def release(n = 1, key = nil) @children[key].release n end end - end end end diff --git a/lib/dynflow/semaphores/dummy.rb b/lib/dynflow/semaphores/dummy.rb index d07151033..e5e74b7c6 100644 --- a/lib/dynflow/semaphores/dummy.rb +++ b/lib/dynflow/semaphores/dummy.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Dynflow module Semaphores class Dummy < Abstract - def wait(thing) true end diff --git a/lib/dynflow/semaphores/stateful.rb b/lib/dynflow/semaphores/stateful.rb index da98d3c0c..6c36d5d6a 100644 --- a/lib/dynflow/semaphores/stateful.rb +++ b/lib/dynflow/semaphores/stateful.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Dynflow module Semaphores class Stateful < Abstract - attr_reader :free, :tickets, :waiting, :meta def initialize(tickets, free = tickets, meta = {}) diff --git a/lib/dynflow/serializable.rb b/lib/dynflow/serializable.rb index 16777077f..5b0c78659 100644 --- a/lib/dynflow/serializable.rb +++ b/lib/dynflow/serializable.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'date' module Dynflow class Serializable diff --git a/lib/dynflow/serializer.rb b/lib/dynflow/serializer.rb index 84a7d8bfc..b243a2429 100644 --- a/lib/dynflow/serializer.rb +++ b/lib/dynflow/serializer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'algebrick/serializer' module Dynflow @@ -7,7 +8,6 @@ def self.serializer end class Serializer < Algebrick::Serializer - ARBITRARY_TYPE_KEY = :class MARSHAL_KEY = :marshaled @@ -38,7 +38,7 @@ def parse_other(other, options = {}) end if (type_name = other[ARBITRARY_TYPE_KEY] || other[ARBITRARY_TYPE_KEY.to_s]) - if type_name == 'Time' && ( time_str = other['value'] ) + if type_name == 'Time' && (time_str = other['value']) return Serializable.send(:string_to_time, time_str) end type = Utils.constantize(type_name) rescue nil diff --git a/lib/dynflow/serializers.rb b/lib/dynflow/serializers.rb index 341a51e0e..b85ac78b7 100644 --- a/lib/dynflow/serializers.rb +++ b/lib/dynflow/serializers.rb @@ -1,9 +1,8 @@ # frozen_string_literal: true + module Dynflow module Serializers - require 'dynflow/serializers/abstract' require 'dynflow/serializers/noop' - end end diff --git a/lib/dynflow/serializers/abstract.rb b/lib/dynflow/serializers/abstract.rb index afb77532d..99324a642 100644 --- a/lib/dynflow/serializers/abstract.rb +++ b/lib/dynflow/serializers/abstract.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Serializers # @abstract @@ -6,7 +7,6 @@ module Serializers # Used by {DelayedPlan} to store arguments which should be passed into # the {Dynflow::Action}'s #plan method when the plan is executed. class Abstract - attr_reader :args, :serialized_args # @param args [Array] arguments to be serialized @@ -65,7 +65,6 @@ def serialize(arg) def deserialize(arg) raise NotImplementedError end - end end end diff --git a/lib/dynflow/serializers/noop.rb b/lib/dynflow/serializers/noop.rb index 2871121c6..31a643934 100644 --- a/lib/dynflow/serializers/noop.rb +++ b/lib/dynflow/serializers/noop.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Dynflow module Serializers class Noop < Abstract - def serialize(arg) arg end @@ -10,7 +10,6 @@ def serialize(arg) def deserialize(arg) arg end - end end end diff --git a/lib/dynflow/stateful.rb b/lib/dynflow/stateful.rb index 9fb83c275..c7329909a 100644 --- a/lib/dynflow/stateful.rb +++ b/lib/dynflow/stateful.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Stateful def self.included(base) diff --git a/lib/dynflow/telemetry.rb b/lib/dynflow/telemetry.rb index cb5eed537..2d84bb70b 100644 --- a/lib/dynflow/telemetry.rb +++ b/lib/dynflow/telemetry.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'dynflow/telemetry_adapters/abstract' require 'dynflow/telemetry_adapters/dummy' require 'dynflow/telemetry_adapters/statsd' @@ -33,32 +34,32 @@ def register_metrics! with_instance do |t| # Worker related t.add_gauge :dynflow_active_workers, 'The number of currently busy workers', - [:queue, :world] + [:queue, :world] t.add_counter :dynflow_worker_events, 'The number of processed events', - [:queue, :world, :worker] + [:queue, :world, :worker] # Execution plan related t.add_gauge :dynflow_active_execution_plans, 'The number of active execution plans', - [:action, :world, :state] + [:action, :world, :state] t.add_gauge :dynflow_queue_size, 'Number of items in queue', - [:queue, :world] + [:queue, :world] t.add_counter :dynflow_finished_execution_plans, 'The number of execution plans', - [:action, :world, :result] + [:action, :world, :result] # Step related # TODO: Configure buckets in a sane manner t.add_histogram :dynflow_step_real_time, 'The time between the start end end of the step', - [:action, :phase] + [:action, :phase] t.add_histogram :dynflow_step_execution_time, 'The time spent executing a step', - [:action, :phase] + [:action, :phase] # Connector related t.add_counter :dynflow_connector_envelopes, 'The number of envelopes handled by a connector', - [:world, :direction] + [:world, :direction] # Persistence related t.add_histogram :dynflow_persistence, 'The time spent communicating with the database', - [:world, :method] + [:world, :method] end end end diff --git a/lib/dynflow/telemetry_adapters/abstract.rb b/lib/dynflow/telemetry_adapters/abstract.rb index 5c37a22aa..cd42f32b5 100644 --- a/lib/dynflow/telemetry_adapters/abstract.rb +++ b/lib/dynflow/telemetry_adapters/abstract.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module TelemetryAdapters class Abstract diff --git a/lib/dynflow/telemetry_adapters/dummy.rb b/lib/dynflow/telemetry_adapters/dummy.rb index 10a9f951c..3d84e294c 100644 --- a/lib/dynflow/telemetry_adapters/dummy.rb +++ b/lib/dynflow/telemetry_adapters/dummy.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module TelemetryAdapters # Telemetry adapter which does not evaluate blocks passed to {#with_instance}. diff --git a/lib/dynflow/telemetry_adapters/statsd.rb b/lib/dynflow/telemetry_adapters/statsd.rb index 1c8372153..f74404e1f 100644 --- a/lib/dynflow/telemetry_adapters/statsd.rb +++ b/lib/dynflow/telemetry_adapters/statsd.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module TelemetryAdapters class StatsD < Abstract @@ -42,7 +43,7 @@ def observe_histogram(name, value, tags) def name_tag_mapping(name, tags) instances = @instances[name] return name if instances.nil? || instances.empty? - (name.to_s + '.' + instances.map {|x| tags[x]}.compact.join('.')).tr('-:/ ', '____') + (name.to_s + '.' + instances.map { |x| tags[x] }.compact.join('.')).tr('-:/ ', '____') end end end diff --git a/lib/dynflow/testing.rb b/lib/dynflow/testing.rb index 2cdf906f5..581469a5c 100644 --- a/lib/dynflow/testing.rb +++ b/lib/dynflow/testing.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Testing extend Algebrick::TypeCheck diff --git a/lib/dynflow/testing/assertions.rb b/lib/dynflow/testing/assertions.rb index a3faecacc..12a906a71 100644 --- a/lib/dynflow/testing/assertions.rb +++ b/lib/dynflow/testing/assertions.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Testing module Assertions @@ -15,8 +16,8 @@ def assert_action_planned_with(action, planned_action_class, *plan_input, &block end assert(!found.empty?, - "Action #{planned_action_class} with plan_input #{plan_input} was not planned, " + - "there were only #{found_classes.map(&:plan_input)}") + "Action #{planned_action_class} with plan_input #{plan_input} was not planned, " + + "there were only #{found_classes.map(&:plan_input)}") found end @@ -24,8 +25,8 @@ def assert_action_planned_with(action, planned_action_class, *plan_input, &block def assert_action_planned(action, planned_action_class) Match! action.phase, Action::Plan Match! action.state, :success - found = action.execution_plan.planned_plan_steps. - select { |a| a.is_a?(planned_action_class) } + found = action.execution_plan.planned_plan_steps + .select { |a| a.is_a?(planned_action_class) } assert(!found.empty?, "Action #{planned_action_class} was not planned") found @@ -34,8 +35,8 @@ def assert_action_planned(action, planned_action_class) def refute_action_planned(action, planned_action_class) Match! action.phase, Action::Plan Match! action.state, :success - found = action.execution_plan.planned_plan_steps. - select { |a| a.is_a?(planned_action_class) } + found = action.execution_plan.planned_plan_steps + .select { |a| a.is_a?(planned_action_class) } assert(found.empty?, "Action #{planned_action_class} was planned") found @@ -74,7 +75,6 @@ def refute_finalize_phase(action) Match! action.state, :success _(action.execution_plan.planned_finalize_steps).wont_include action end - end end end diff --git a/lib/dynflow/testing/dummy_coordinator.rb b/lib/dynflow/testing/dummy_coordinator.rb index d42b772cf..77c201a44 100644 --- a/lib/dynflow/testing/dummy_coordinator.rb +++ b/lib/dynflow/testing/dummy_coordinator.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Testing class DummyCoordinator diff --git a/lib/dynflow/testing/dummy_execution_plan.rb b/lib/dynflow/testing/dummy_execution_plan.rb index eea91dbd3..6bb48fc3f 100644 --- a/lib/dynflow/testing/dummy_execution_plan.rb +++ b/lib/dynflow/testing/dummy_execution_plan.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Testing class DummyExecutionPlan diff --git a/lib/dynflow/testing/dummy_executor.rb b/lib/dynflow/testing/dummy_executor.rb index 416c90af3..ee1ca352f 100644 --- a/lib/dynflow/testing/dummy_executor.rb +++ b/lib/dynflow/testing/dummy_executor.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Testing class DummyExecutor diff --git a/lib/dynflow/testing/dummy_planned_action.rb b/lib/dynflow/testing/dummy_planned_action.rb index c9b552a67..12ae55e9d 100644 --- a/lib/dynflow/testing/dummy_planned_action.rb +++ b/lib/dynflow/testing/dummy_planned_action.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Testing class DummyPlannedAction @@ -8,7 +9,8 @@ class DummyPlannedAction def initialize(klass) mimic! klass @output = ExecutionPlan::OutputReference.new( - Testing.get_id.to_s, Testing.get_id, Testing.get_id) + Testing.get_id.to_s, Testing.get_id, Testing.get_id + ) end def execute(execution_plan, event, from_subscription, *args) diff --git a/lib/dynflow/testing/dummy_step.rb b/lib/dynflow/testing/dummy_step.rb index e59638a9e..7cc0554e8 100644 --- a/lib/dynflow/testing/dummy_step.rb +++ b/lib/dynflow/testing/dummy_step.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Testing class DummyStep diff --git a/lib/dynflow/testing/dummy_world.rb b/lib/dynflow/testing/dummy_world.rb index 1beb4b705..1a945d820 100644 --- a/lib/dynflow/testing/dummy_world.rb +++ b/lib/dynflow/testing/dummy_world.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Testing class DummyWorld diff --git a/lib/dynflow/testing/factories.rb b/lib/dynflow/testing/factories.rb index 72314c593..b484fed2c 100644 --- a/lib/dynflow/testing/factories.rb +++ b/lib/dynflow/testing/factories.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Testing module Factories @@ -9,14 +10,15 @@ def create_action(action_class, trigger = nil) execution_plan = DummyExecutionPlan.new step = DummyStep.new action_class.new( - { step: DummyStep.new, - execution_plan_id: execution_plan.id, - id: Testing.get_id, - phase: Action::Plan, - plan_step_id: step.id, - run_step_id: nil, - finalize_step_id: nil }, - execution_plan.world).tap do |action| + { step: DummyStep.new, + execution_plan_id: execution_plan.id, + id: Testing.get_id, + phase: Action::Plan, + plan_step_id: step.id, + run_step_id: nil, + finalize_step_id: nil }, + execution_plan.world + ).tap do |action| action.set_plan_context(execution_plan, trigger, false) end end @@ -24,15 +26,16 @@ def create_action(action_class, trigger = nil) def create_action_presentation(action_class) execution_plan = DummyExecutionPlan.new action_class.new( - { execution_plan: execution_plan, - execution_plan_id: execution_plan.id, - id: Testing.get_id, - phase: Action::Present, - plan_step_id: 1, - run_step_id: nil, - finalize_step_id: nil, - input: nil }, - execution_plan.world) + { execution_plan: execution_plan, + execution_plan_id: execution_plan.id, + id: Testing.get_id, + phase: Action::Present, + plan_step_id: 1, + run_step_id: nil, + finalize_step_id: nil, + input: nil }, + execution_plan.world + ) end # @return [Action::PlanPhase] @@ -58,15 +61,16 @@ def run_action(plan_action, event = nil, &stubbing) step = DummyStep.new run_action = if plan_action.phase == Action::Plan plan_action.class.new( - { step: step, - execution_plan_id: plan_action.execution_plan_id, - id: plan_action.id, - plan_step_id: plan_action.plan_step_id, - run_step_id: step.id, - finalize_step_id: nil, - phase: Action::Run, - input: plan_action.input }, - plan_action.world) + { step: step, + execution_plan_id: plan_action.execution_plan_id, + id: plan_action.id, + plan_step_id: plan_action.plan_step_id, + run_step_id: step.id, + finalize_step_id: nil, + phase: Action::Run, + input: plan_action.input }, + plan_action.world + ) else plan_action @@ -85,22 +89,23 @@ def finalize_action(run_action, &stubbing) Match! run_action.phase, Action::Plan, Action::Run step = DummyStep.new finalize_action = run_action.class.new( - { step: step, - execution_plan_id: run_action.execution_plan_id, - id: run_action.id, - plan_step_id: run_action.plan_step_id, - run_step_id: run_action.run_step_id, - finalize_step_id: step.id, - phase: Action::Finalize, - input: run_action.input }, - run_action.world) + { step: step, + execution_plan_id: run_action.execution_plan_id, + id: run_action.id, + plan_step_id: run_action.plan_step_id, + run_step_id: run_action.run_step_id, + finalize_step_id: step.id, + phase: Action::Finalize, + input: run_action.input }, + run_action.world + ) stubbing.call finalize_action if stubbing finalize_action.execute finalize_action end - def progress_action_time action + def progress_action_time(action) Match! action.phase, Action::Run if action.world.clock.progress return action.world.executor.progress diff --git a/lib/dynflow/testing/in_thread_executor.rb b/lib/dynflow/testing/in_thread_executor.rb index e73a7c4c1..7eef34afc 100644 --- a/lib/dynflow/testing/in_thread_executor.rb +++ b/lib/dynflow/testing/in_thread_executor.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Testing class InThreadExecutor diff --git a/lib/dynflow/testing/in_thread_world.rb b/lib/dynflow/testing/in_thread_world.rb index b0190f118..e59e2cecb 100644 --- a/lib/dynflow/testing/in_thread_world.rb +++ b/lib/dynflow/testing/in_thread_world.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Testing class InThreadWorld < Dynflow::World diff --git a/lib/dynflow/testing/managed_clock.rb b/lib/dynflow/testing/managed_clock.rb index 8b652f154..2b7ab5523 100644 --- a/lib/dynflow/testing/managed_clock.rb +++ b/lib/dynflow/testing/managed_clock.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Dynflow module Testing class ManagedClock - attr_reader :pending_pings include Algebrick::Types diff --git a/lib/dynflow/testing/mimic.rb b/lib/dynflow/testing/mimic.rb index 8d9ec3542..4952ae78c 100644 --- a/lib/dynflow/testing/mimic.rb +++ b/lib/dynflow/testing/mimic.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true + module Dynflow module Testing - # when extended into Class or an_object it makes all instances of the class or the object # mimic the supplied types. It does so by hooking into kind_of? method. # @example @@ -18,7 +18,7 @@ def ===(v) end def mimic!(*types) - define =-> _ do + define = ->_ do define_method :mimic_types do types end diff --git a/lib/dynflow/throttle_limiter.rb b/lib/dynflow/throttle_limiter.rb index e49ad0a35..94b550d1e 100644 --- a/lib/dynflow/throttle_limiter.rb +++ b/lib/dynflow/throttle_limiter.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true + module Dynflow class ThrottleLimiter - attr_reader :core def initialize(world) diff --git a/lib/dynflow/transaction_adapters.rb b/lib/dynflow/transaction_adapters.rb index 4e81fa299..d2ebb291e 100644 --- a/lib/dynflow/transaction_adapters.rb +++ b/lib/dynflow/transaction_adapters.rb @@ -1,10 +1,9 @@ # frozen_string_literal: true + module Dynflow module TransactionAdapters - require 'dynflow/transaction_adapters/abstract' require 'dynflow/transaction_adapters/none' require 'dynflow/transaction_adapters/active_record' - end end diff --git a/lib/dynflow/transaction_adapters/abstract.rb b/lib/dynflow/transaction_adapters/abstract.rb index 23a03c2e1..75b7d0e4d 100644 --- a/lib/dynflow/transaction_adapters/abstract.rb +++ b/lib/dynflow/transaction_adapters/abstract.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module TransactionAdapters class Abstract diff --git a/lib/dynflow/transaction_adapters/active_record.rb b/lib/dynflow/transaction_adapters/active_record.rb index 554a80632..d4b295303 100644 --- a/lib/dynflow/transaction_adapters/active_record.rb +++ b/lib/dynflow/transaction_adapters/active_record.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module TransactionAdapters class ActiveRecord < Abstract diff --git a/lib/dynflow/transaction_adapters/none.rb b/lib/dynflow/transaction_adapters/none.rb index 7a116ea93..97c1c4134 100644 --- a/lib/dynflow/transaction_adapters/none.rb +++ b/lib/dynflow/transaction_adapters/none.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module TransactionAdapters class None < Abstract diff --git a/lib/dynflow/utils.rb b/lib/dynflow/utils.rb index 32132cb4d..51449667e 100644 --- a/lib/dynflow/utils.rb +++ b/lib/dynflow/utils.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true + module Dynflow module Utils - require 'dynflow/utils/indifferent_hash' require 'dynflow/utils/priority_queue' diff --git a/lib/dynflow/utils/indifferent_hash.rb b/lib/dynflow/utils/indifferent_hash.rb index 9873c59a7..647f8f933 100644 --- a/lib/dynflow/utils/indifferent_hash.rb +++ b/lib/dynflow/utils/indifferent_hash.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Utils # Heavily inpired by ActiveSupport::HashWithIndifferentAccess, @@ -84,7 +85,7 @@ def reverse_merge(other_hash) end def reverse_merge!(other_hash) - replace(reverse_merge( other_hash )) + replace(reverse_merge(other_hash)) end def replace(other_hash) @@ -96,9 +97,13 @@ def delete(key) end def stringify_keys!; self end + def deep_stringify_keys!; self end + def stringify_keys; dup end + def deep_stringify_keys; dup end + def to_options!; self end def select(*args, &block) @@ -119,6 +124,7 @@ def to_hash end protected + def convert_key(key) key.kind_of?(Symbol) ? key.to_s : key end diff --git a/lib/dynflow/utils/priority_queue.rb b/lib/dynflow/utils/priority_queue.rb index ae6952d31..d0bae70a6 100644 --- a/lib/dynflow/utils/priority_queue.rb +++ b/lib/dynflow/utils/priority_queue.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Utils # Heavily inspired by rubyworks/pqueue diff --git a/lib/dynflow/version.rb b/lib/dynflow/version.rb index 8021d72a1..19806c22c 100644 --- a/lib/dynflow/version.rb +++ b/lib/dynflow/version.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow VERSION = '1.8.2' end diff --git a/lib/dynflow/watchers/memory_consumption_watcher.rb b/lib/dynflow/watchers/memory_consumption_watcher.rb index 80c4da58c..b0a72e0a8 100644 --- a/lib/dynflow/watchers/memory_consumption_watcher.rb +++ b/lib/dynflow/watchers/memory_consumption_watcher.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true + require 'get_process_mem' module Dynflow module Watchers class MemoryConsumptionWatcher - attr_reader :memory_limit, :world def initialize(world, memory_limit, options) diff --git a/lib/dynflow/web.rb b/lib/dynflow/web.rb index 5ec087cc5..3e473bc60 100644 --- a/lib/dynflow/web.rb +++ b/lib/dynflow/web.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'dynflow' require 'pp' require 'sinatra/base' @@ -6,11 +7,10 @@ module Dynflow module Web - def self.setup(&block) - console = Sinatra.new(Web::Console) { instance_exec(&block)} + console = Sinatra.new(Web::Console) { instance_exec(&block) } Rack::Builder.app do - run Rack::URLMap.new('/' => console) + run Rack::URLMap.new('/' => console) end end diff --git a/lib/dynflow/web/console.rb b/lib/dynflow/web/console.rb index 4fee958a7..cd0639b4d 100644 --- a/lib/dynflow/web/console.rb +++ b/lib/dynflow/web/console.rb @@ -1,9 +1,8 @@ - # frozen_string_literal: true + module Dynflow module Web class Console < Sinatra::Base - set :public_folder, Web.web_dir('assets') set :views, Web.web_dir('views') set :per_page, 10 @@ -107,7 +106,6 @@ class Console < Sinatra::Base redirect(url "/#{plan.id}?notice=#{url_encode('The step does not support cancelling')}") end end - end end end diff --git a/lib/dynflow/web/console_helpers.rb b/lib/dynflow/web/console_helpers.rb index 4737bf746..413d395d4 100644 --- a/lib/dynflow/web/console_helpers.rb +++ b/lib/dynflow/web/console_helpers.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Web module ConsoleHelpers @@ -36,7 +37,7 @@ def prettyprint(value) pretty_value = prettify_value(value) <<-HTML
#{h(pretty_value)}
- HTML + HTML else "" end @@ -90,7 +91,7 @@ def show_action_data(label, value) #{h(label)} #{value_html}

- HTML + HTML else "" end @@ -177,9 +178,9 @@ def filter_checkbox(field, values) checkboxes = values.map do |value| field_filter = filtering_options[:filters][field] checked = field_filter && field_filter.include?(value) - %{#{value}} + %{#{value}} end.join(' ') - out %= checkboxes + out %= checkboxes return out end end diff --git a/lib/dynflow/web/filtering_helpers.rb b/lib/dynflow/web/filtering_helpers.rb index e586811c1..a5df0eb26 100644 --- a/lib/dynflow/web/filtering_helpers.rb +++ b/lib/dynflow/web/filtering_helpers.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Web module FilteringHelpers diff --git a/lib/dynflow/web/world_helpers.rb b/lib/dynflow/web/world_helpers.rb index 2b0146f7f..ef41ccb2b 100644 --- a/lib/dynflow/web/world_helpers.rb +++ b/lib/dynflow/web/world_helpers.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow module Web module WorldHelpers diff --git a/lib/dynflow/web_console.rb b/lib/dynflow/web_console.rb index 3965ad7a1..198d8e989 100644 --- a/lib/dynflow/web_console.rb +++ b/lib/dynflow/web_console.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'dynflow/web' warn %{"require 'dynflow/web_console'" is deprecated, use "require 'dynflow/web'" instead} diff --git a/lib/dynflow/world.rb b/lib/dynflow/world.rb index bf0a1ba31..6694980ff 100644 --- a/lib/dynflow/world.rb +++ b/lib/dynflow/world.rb @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # frozen_string_literal: true + require 'dynflow/world/invalidation' module Dynflow @@ -9,10 +10,10 @@ class World include Invalidation attr_reader :id, :config, :client_dispatcher, :executor_dispatcher, :executor, :connector, - :transaction_adapter, :logger_adapter, :coordinator, - :persistence, :action_classes, :subscription_index, - :middleware, :auto_rescue, :clock, :meta, :delayed_executor, :auto_validity_check, :validity_check_timeout, :throttle_limiter, - :termination_timeout, :terminated, :dead_letter_handler, :execution_plan_cleaner + :transaction_adapter, :logger_adapter, :coordinator, + :persistence, :action_classes, :subscription_index, + :middleware, :auto_rescue, :clock, :meta, :delayed_executor, :auto_validity_check, :validity_check_timeout, :throttle_limiter, + :termination_timeout, :terminated, :dead_letter_handler, :execution_plan_cleaner def initialize(config) @config = Config::ForWorld.new(config, self) @@ -27,14 +28,14 @@ def initialize(config) @config.validate @transaction_adapter = @config.transaction_adapter @persistence = Persistence.new(self, @config.persistence_adapter, - :backup_deleted_plans => @config.backup_deleted_plans, - :backup_dir => @config.backup_dir) + :backup_deleted_plans => @config.backup_deleted_plans, + :backup_dir => @config.backup_dir) @coordinator = Coordinator.new(@config.coordinator_adapter) if @config.executor @executor = Executors::Parallel.new(self, - executor_class: @config.executor, - heartbeat_interval: @config.executor_heartbeat_interval, - queues_options: @config.queues) + executor_class: @config.executor, + heartbeat_interval: @config.executor_heartbeat_interval, + queues_options: @config.queues) end @action_classes = @config.action_classes @auto_rescue = @config.auto_rescue @@ -86,7 +87,7 @@ def before_termination(&block) end def update_register - @meta ||= @config.meta + @meta ||= @config.meta @meta['queues'] = @config.queues if @executor @meta['delayed_executor'] = true if @delayed_executor @meta['execution_plan_cleaner'] = true if @execution_plan_cleaner @@ -278,7 +279,7 @@ def terminating? def auto_execute coordinator.acquire(Coordinator::AutoExecuteLock.new(self)) do planned_execution_plans = - self.persistence.find_execution_plans filters: { 'state' => %w(planned paused), 'result' => (ExecutionPlan.results - [:error]).map(&:to_s) } + self.persistence.find_execution_plans filters: { 'state' => %w(planned paused), 'result' => (ExecutionPlan.results - [:error]).map(&:to_s) } planned_execution_plans.map do |ep| if coordinator.find_locks(Dynflow::Coordinator::ExecutionLock.unique_filter(ep.id)).empty? execute(ep.id) @@ -361,12 +362,12 @@ def start_termination def calculate_subscription_index @subscription_index = - action_classes.each_with_object(Hash.new { |h, k| h[k] = [] }) do |klass, index| - next unless klass.subscribe - Array(klass.subscribe).each do |subscribed_class| - index[Utils.constantize(subscribed_class.to_s)] << klass - end - end.tap { |o| o.freeze } + action_classes.each_with_object(Hash.new { |h, k| h[k] = [] }) do |klass, index| + next unless klass.subscribe + Array(klass.subscribe).each do |subscribed_class| + index[Utils.constantize(subscribed_class.to_s)] << klass + end + end.tap { |o| o.freeze } end def run_before_termination_hooks @@ -388,6 +389,5 @@ def spawn_and_wait(klass, name, *args) initialized.wait return actor end - end end diff --git a/lib/dynflow/world/invalidation.rb b/lib/dynflow/world/invalidation.rb index 7e1234b9a..f8ec7d872 100644 --- a/lib/dynflow/world/invalidation.rb +++ b/lib/dynflow/world/invalidation.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Dynflow class World module Invalidation diff --git a/test/abnormal_states_recovery_test.rb b/test/abnormal_states_recovery_test.rb index 634069e44..689cc5d59 100644 --- a/test/abnormal_states_recovery_test.rb +++ b/test/abnormal_states_recovery_test.rb @@ -1,13 +1,12 @@ # -*- coding: utf-8 -*- # frozen_string_literal: true + require_relative 'test_helper' require 'ostruct' module Dynflow module ConsistencyCheckTest - describe "consistency check" do - include TestHelpers def with_invalidation_while_executing(finish) @@ -43,7 +42,6 @@ def with_invalidation_while_executing(finish) let(:client_world_2) { create_world(false) } describe "for plans assigned to invalid world" do - before do # mention the executors to make sure they are initialized [executor_world, executor_world_2] @@ -187,7 +185,6 @@ def with_invalidation_while_executing(finish) end describe 'auto execute' do - before do client_world.persistence.delete_execution_plans({}) end @@ -273,10 +270,10 @@ def with_invalidation_while_executing(finish) end it 'by default, the auto_validity_check is enabled only for executor words' do - client_world_config = Config::ForWorld.new(Config.new.tap { |c| c.executor = false }, create_world ) + client_world_config = Config::ForWorld.new(Config.new.tap { |c| c.executor = false }, create_world) _(client_world_config.auto_validity_check).must_equal false - executor_world_config = Config::ForWorld.new(Config.new.tap { |c| c.executor = Executors::Parallel::Core }, create_world ) + executor_world_config = Config::ForWorld.new(Config.new.tap { |c| c.executor = Executors::Parallel::Core }, create_world) _(executor_world_config.auto_validity_check).must_equal true end @@ -304,7 +301,7 @@ def with_invalidation_while_executing(finish) _(client_world.coordinator.find_worlds(false, id: [invalid_world.id, invalid_world_2.id]).size).must_equal 2 results = client_world.worlds_validity_check(true, :id => invalid_world.id) - _(results).must_equal(invalid_world.id => :invalidated) + _(results).must_equal(invalid_world.id => :invalidated) _(client_world.coordinator.find_worlds(false, id: [invalid_world.id, invalid_world_2.id]).size).must_equal 1 end end @@ -382,4 +379,3 @@ def plan_in_state(state) end end end - diff --git a/test/action_test.rb b/test/action_test.rb index e24504d0f..2a976a49d 100644 --- a/test/action_test.rb +++ b/test/action_test.rb @@ -1,14 +1,13 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'mocha/minitest' module Dynflow describe 'action' do - let(:world) { WorldFactory.create_world } describe Action::Missing do - let :action_data do { class: 'RenamedAction', id: 1, @@ -32,7 +31,6 @@ module Dynflow end describe 'children' do - smart_action_class = Class.new(Dynflow::Action) smarter_action_class = Class.new(smart_action_class) @@ -50,7 +48,6 @@ module Dynflow end describe Action::Present do - let :execution_plan do result = world.trigger(Support::CodeWorkflowExample::IncomingIssues, issues_data) _(result).must_be :planned? @@ -74,7 +71,6 @@ module Dynflow end describe 'serialization' do - include Testing it 'fails when input is not serializable' do @@ -196,10 +192,9 @@ def wont_fail end class TestPollingAction < Dynflow::Action - class Config attr_accessor :external_service, :poll_max_retries, - :poll_intervals, :attempts_before_next_interval + :poll_intervals, :attempts_before_next_interval def initialize @external_service = ExternalService.new @@ -383,7 +378,6 @@ def next_ping(action) end describe Action::WithSubPlans do - class FailureSimulator class << self attr_accessor :fail_in_child_plan, :fail_in_child_run @@ -399,7 +393,6 @@ def run; end end class ParentAction < Dynflow::Action - include Dynflow::Action::WithSubPlans def plan(*_) @@ -413,7 +406,7 @@ def create_sub_plans def resume(*args) output[:custom_resume] = true - super *args + super(*args) end end @@ -481,7 +474,6 @@ def create_sub_plans def batch(from, size) total_count.times.drop(from).take(size) end - end let(:execution_plan) { world.trigger(ParentAction, count: 2).finished.value } @@ -506,7 +498,7 @@ def batch(from, size) end specify "it saves the information about number for sub plans in the output" do - _(execution_plan.entry_action.output).must_equal('total_count' => 2, + _(execution_plan.entry_action.output).must_equal('total_count' => 2, 'failed_count' => 0, 'success_count' => 2, 'pending_count' => 0) @@ -514,7 +506,7 @@ def batch(from, size) specify "when a sub plan fails, the caller action fails as well" do FailureSimulator.fail_in_child_run = true - _(execution_plan.entry_action.output).must_equal('total_count' => 2, + _(execution_plan.entry_action.output).must_equal('total_count' => 2, 'failed_count' => 2, 'success_count' => 0, 'pending_count' => 0) @@ -789,7 +781,7 @@ def run plan = world.plan(SingletonAction) _(plan.state).must_equal :planned lock_filter = ::Dynflow::Coordinator::SingletonActionLock - .unique_filter plan.entry_action.class.name + .unique_filter plan.entry_action.class.name _(world.coordinator.find_locks(lock_filter).count).must_equal 1 plan = world.execute(plan.id).wait!.value _(plan.state).must_equal :stopped @@ -801,7 +793,7 @@ def run plan = world.plan(SingletonActionWithFinalize) _(plan.state).must_equal :planned lock_filter = ::Dynflow::Coordinator::SingletonActionLock - .unique_filter plan.entry_action.class.name + .unique_filter plan.entry_action.class.name _(world.coordinator.find_locks(lock_filter).count).must_equal 1 plan = world.execute(plan.id).wait!.value _(plan.state).must_equal :stopped @@ -813,7 +805,7 @@ def run plan = world.plan(SuspendedSingletonAction) _(plan.state).must_equal :planned lock_filter = ::Dynflow::Coordinator::SingletonActionLock - .unique_filter plan.entry_action.class.name + .unique_filter plan.entry_action.class.name _(world.coordinator.find_locks(lock_filter).count).must_equal 1 future = world.execute(plan.id) wait_for do @@ -859,7 +851,7 @@ def run # The lock was released when plan3 stopped lock_filter = ::Dynflow::Coordinator::SingletonActionLock - .unique_filter plan3.entry_action.class.name + .unique_filter plan3.entry_action.class.name _(world.coordinator.find_locks(lock_filter)).must_be :empty? end @@ -868,7 +860,7 @@ def run plan1 = world.plan(BadAction, true) _(plan1.state).must_equal :planned lock_filter = ::Dynflow::Coordinator::SingletonActionLock - .unique_filter plan1.entry_action.class.name + .unique_filter plan1.entry_action.class.name _(world.coordinator.find_locks(lock_filter).count).must_equal 0 plan2 = world.plan(BadAction, false) _(plan2.state).must_equal :planned diff --git a/test/activejob_adapter_test.rb b/test/activejob_adapter_test.rb index 1295a2d85..aff0e5062 100644 --- a/test/activejob_adapter_test.rb +++ b/test/activejob_adapter_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'active_job' require 'dynflow/active_job/queue_adapter' @@ -21,7 +22,7 @@ def perform(msg) end before(:all) do - ::ActiveJob::QueueAdapters.send(:include, ::Dynflow::ActiveJob::QueueAdapters) + ::ActiveJob::QueueAdapters.include ::Dynflow::ActiveJob::QueueAdapters ::ActiveJob::Base.queue_adapter = :dynflow dynflow_mock = Minitest::Mock.new dynflow_mock.expect(:world, world) @@ -71,4 +72,3 @@ def perform(msg) end end end - diff --git a/test/batch_sub_tasks_test.rb b/test/batch_sub_tasks_test.rb index b3feffe47..e293a5abd 100644 --- a/test/batch_sub_tasks_test.rb +++ b/test/batch_sub_tasks_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' module Dynflow @@ -109,7 +110,6 @@ def total_count _(action.send(:can_spawn_next_batch?)).must_equal false _(action.current_batch).must_be :empty? end - end end end diff --git a/test/clock_test.rb b/test/clock_test.rb index 38069b514..32bb598b2 100644 --- a/test/clock_test.rb +++ b/test/clock_test.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'logger' clock_class = Dynflow::Clock describe clock_class do - let(:clock) { clock_class.spawn 'clock' } it 'refuses who without #<< method' do @@ -48,7 +48,6 @@ assert_equal (0...times).to_a, Array.new(times) { q.pop }.sort end end - threads.each &:join + threads.each(&:join) end - end diff --git a/test/concurrency_control_test.rb b/test/concurrency_control_test.rb index dc2d3dbd7..fd2b50449 100644 --- a/test/concurrency_control_test.rb +++ b/test/concurrency_control_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' module Dynflow @@ -81,8 +82,8 @@ def create_sub_plans end def check_step(plan, total, finished) - _(world.throttle_limiter.observe(plan.id).length).must_equal (total - finished) - _(plan.sub_plans.select { |sub| planned? sub }.count).must_equal (total - finished) + _(world.throttle_limiter.observe(plan.id).length).must_equal(total - finished) + _(plan.sub_plans.select { |sub| planned? sub }.count).must_equal(total - finished) _(plan.sub_plans.select { |sub| successful? sub }.count).must_equal finished end @@ -95,14 +96,12 @@ def successful?(plan) end class LoggingThrottleLimiter < Dynflow::ThrottleLimiter - class LoggingCore < Dynflow::ThrottleLimiter::Core - attr_reader :running def initialize(*args) @running = [0] - super *args + super(*args) end def release(*args) @@ -233,12 +232,12 @@ def core_class planned, running = plan.sub_plans.partition { |sub| planned? sub } _(planned.count).must_equal total - level _(running.count).must_equal level - _(world.throttle_limiter.observe(plan.id).length).must_equal (total - 1) + _(world.throttle_limiter.observe(plan.id).length).must_equal(total - 1) 4.times { klok.progress } wait_for { future.resolved? } finished, stopped = plan.sub_plans.partition { |sub| successful? sub } _(finished.count).must_equal level - _(stopped.count).must_equal (total - level) + _(stopped.count).must_equal(total - level) end end end diff --git a/test/coordinator_test.rb b/test/coordinator_test.rb index c28b38409..1088fd129 100644 --- a/test/coordinator_test.rb +++ b/test/coordinator_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'fileutils' diff --git a/test/daemon_test.rb b/test/daemon_test.rb index aefd91191..70981d4e2 100644 --- a/test/daemon_test.rb +++ b/test/daemon_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'test_helper' require 'active_support' require 'mocha/minitest' @@ -34,8 +35,8 @@ class DaemonTest < ActiveSupport::TestCase @daemon.stubs(:sleep).returns(true) # don't pause the execution @current_folder = File.expand_path('../support/rails/', __FILE__) ::ActiveRecord::Base.configurations = { 'development' => {} } - ::Dynflow::Rails::Configuration.any_instance.stubs(:initialize_persistence). - returns(WorldFactory.persistence_adapter) + ::Dynflow::Rails::Configuration.any_instance.stubs(:initialize_persistence) + .returns(WorldFactory.persistence_adapter) end teardown do diff --git a/test/dead_letter_silencer_test.rb b/test/dead_letter_silencer_test.rb index 73e7a1d71..dbf3fa395 100644 --- a/test/dead_letter_silencer_test.rb +++ b/test/dead_letter_silencer_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'ostruct' @@ -12,7 +13,7 @@ module DeadLetterSilencerTest it 'is started for each world' do _(world.dead_letter_handler.actor_class) - .must_equal ::Dynflow::DeadLetterSilencer + .must_equal ::Dynflow::DeadLetterSilencer end describe ::Dynflow::DeadLetterSilencer::Matcher do diff --git a/test/dispatcher_test.rb b/test/dispatcher_test.rb index 986fd0481..77344455d 100644 --- a/test/dispatcher_test.rb +++ b/test/dispatcher_test.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true + require_relative 'test_helper' module Dynflow module DispatcherTest describe "dispatcher" do - include TestHelpers let(:persistence_adapter) { WorldFactory.persistence_adapter } @@ -27,8 +27,8 @@ def self.dispatcher_works_with_this_connector it 'succeeds when expected' do result = client_world.trigger(Support::DummyExample::DeprecatedEventedAction, :timeout => 3) step = wait_for do - client_world.persistence.load_execution_plan(result.id). - steps_in_state(:suspended).first + client_world.persistence.load_execution_plan(result.id) + .steps_in_state(:suspended).first end client_world.event(step.execution_plan_id, step.id, 'finish') plan = result.finished.value @@ -53,7 +53,7 @@ def self.dispatcher_works_with_this_connector it 'does not error on dispatching an optional event' do request = client_world.event('123', 1, nil, optional: true) request.wait(20) - assert_match /Could not find an executor for optional .*, discarding/, request.reason.message + assert_match(/Could not find an executor for optional .*, discarding/, request.reason.message) end end end @@ -72,7 +72,6 @@ def self.supports_dynamic_retry assert_plan_reexecuted(plan) end end - end def self.supports_ping_pong diff --git a/test/execution_plan_cleaner_test.rb b/test/execution_plan_cleaner_test.rb index 86233fd4d..cc7b19c98 100644 --- a/test/execution_plan_cleaner_test.rb +++ b/test/execution_plan_cleaner_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'mocha/minitest' diff --git a/test/execution_plan_hooks_test.rb b/test/execution_plan_hooks_test.rb index 6586545b6..c1edc3186 100644 --- a/test/execution_plan_hooks_test.rb +++ b/test/execution_plan_hooks_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' module Dynflow diff --git a/test/execution_plan_test.rb b/test/execution_plan_test.rb index 8ef43e9f8..e776baf5e 100644 --- a/test/execution_plan_test.rb +++ b/test/execution_plan_test.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true + require_relative 'test_helper' module Dynflow module ExecutionPlanTest describe ExecutionPlan do - include PlanAssertions let(:world) { WorldFactory.create_world } @@ -15,7 +15,6 @@ module ExecutionPlanTest end describe 'serialization' do - let :execution_plan do world.plan(Support::CodeWorkflowExample::FastCommit, 'sha' => 'abc123') end @@ -25,7 +24,6 @@ module ExecutionPlanTest end describe 'serialized execution plan' do - before { execution_plan.save } after { world.persistence.delete_execution_plans(:uuid => execution_plan.id) } @@ -46,26 +44,24 @@ module ExecutionPlanTest it 'handles issues with loading the data' do world.persistence.adapter.send(:table, :step) - .where(execution_plan_uuid: execution_plan.id).delete + .where(execution_plan_uuid: execution_plan.id).delete refute deserialized_execution_plan.valid? assert_equal Dynflow::Errors::DataConsistencyError, deserialized_execution_plan.exception.class [:label, :state, :started_at, :ended_at].each do |attr| assert_equal execution_plan.send(attr).to_s, - deserialized_execution_plan.send(attr).to_s, - "invalid plan is supposed to still store #{attr}" + deserialized_execution_plan.send(attr).to_s, + "invalid plan is supposed to still store #{attr}" end [:execution_time, :real_time].each do |attr| assert_equal execution_plan.send(attr).to_f, - deserialized_execution_plan.send(attr).to_f, - "invalid plan is supposed to still store #{attr}" + deserialized_execution_plan.send(attr).to_f, + "invalid plan is supposed to still store #{attr}" end assert_equal execution_plan.execution_history.events, - deserialized_execution_plan.execution_history.events, - "invalid plan is supposed to still store execution history" + deserialized_execution_plan.execution_history.events, + "invalid plan is supposed to still store execution history" end - end - end describe '#label' do @@ -83,24 +79,20 @@ module ExecutionPlanTest end end describe '#result' do - let :execution_plan do world.plan(Support::CodeWorkflowExample::FastCommit, 'sha' => 'abc123') end describe 'for error in planning phase' do - before { execution_plan.steps[2].set_state :error, true } it 'should be :error' do _(execution_plan.result).must_equal :error _(execution_plan.error?).must_equal true end - end describe 'for error in running phase' do - before do step_id = execution_plan.run_flow.all_step_ids[2] execution_plan.steps[step_id].set_state :error, true @@ -109,11 +101,9 @@ module ExecutionPlanTest it 'should be :error' do _(execution_plan.result).must_equal :error end - end describe 'for pending step in running phase' do - before do step_id = execution_plan.run_flow.all_step_ids[2] execution_plan.steps[step_id].set_state :pending, true @@ -122,11 +112,9 @@ module ExecutionPlanTest it 'should be :pending' do _(execution_plan.result).must_equal :pending end - end describe 'for all steps successful or skipped' do - before do execution_plan.run_flow.all_step_ids.each_with_index do |step_id, index| step = execution_plan.steps[step_id] @@ -137,9 +125,7 @@ module ExecutionPlanTest it 'should be :warning' do _(execution_plan.result).must_equal :warning end - end - end describe 'sub plans' do @@ -171,11 +157,9 @@ module ExecutionPlanTest NotifyAssignee PLAN_STEPS end - end describe 'persisted action' do - let :execution_plan do world.plan(Support::CodeWorkflowExample::IncomingIssues, issues_data) end @@ -206,7 +190,6 @@ module ExecutionPlanTest end describe 'planning algorithm' do - describe 'single dependencies' do let :execution_plan do world.plan(Support::CodeWorkflowExample::IncomingIssues, issues_data) @@ -225,7 +208,6 @@ module ExecutionPlanTest 18: NotifyAssignee(pending) {"triage"=>Step(13).output} RUN_FLOW end - end describe 'error in planning phase' do @@ -286,7 +268,6 @@ module ExecutionPlanTest end describe 'finalize flow' do - let :execution_plan do world.plan(Support::CodeWorkflowExample::IncomingIssues, issues_data) end @@ -301,7 +282,6 @@ module ExecutionPlanTest 20: IncomingIssues(pending) {\"issues\"=>[{\"author\"=>\"Peter Smith\", \"text\"=>\"Failing test\"}, {\"author\"=>\"John Doe\", \"text\"=>\"Internal server error\"}]} RUN_FLOW end - end end @@ -355,7 +335,6 @@ module ExecutionPlanTest end describe ExecutionPlan::Steps::Error do - it "doesn't fail when deserializing with missing class" do error = ExecutionPlan::Steps::Error.new_from_hash(exception_class: "RenamedError", message: "This errror is not longer here", @@ -364,7 +343,6 @@ module ExecutionPlanTest _(error.exception_class.to_s).must_equal "Dynflow::Errors::UnknownError[RenamedError]" _(error.exception.inspect).must_equal "Dynflow::Errors::UnknownError[RenamedError]: This errror is not longer here" end - end describe 'with singleton actions' do @@ -382,7 +360,7 @@ def run plan = world.plan(SingletonAction) _(plan.state).must_equal :planned lock_filter = ::Dynflow::Coordinator::SingletonActionLock - .unique_filter plan.entry_action.class.name + .unique_filter plan.entry_action.class.name _(world.coordinator.find_locks(lock_filter).count).must_equal 1 plan = world.execute(plan.id).wait!.value _(plan.state).must_equal :stopped @@ -394,7 +372,7 @@ def run plan = world.plan(SingletonAction, :fail => true) _(plan.state).must_equal :planned lock_filter = ::Dynflow::Coordinator::SingletonActionLock - .unique_filter plan.entry_action.class.name + .unique_filter plan.entry_action.class.name _(world.coordinator.find_locks(lock_filter).count).must_equal 1 plan = world.execute(plan.id).wait!.value _(plan.state).must_equal :paused diff --git a/test/executor_test.rb b/test/executor_test.rb index 1e4840abe..a5b48e90d 100644 --- a/test/executor_test.rb +++ b/test/executor_test.rb @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # frozen_string_literal: true + require_relative 'test_helper' require 'mocha/minitest' @@ -11,11 +12,13 @@ module RedisMocks def release_orchestrator_lock; end + def wait_for_orchestrator_lock; end + def reacquire_orchestrator_lock; end end -::Dynflow::Executors::Sidekiq::Core.send(:prepend, RedisMocks) +::Dynflow::Executors::Sidekiq::Core.prepend RedisMocks module Dynflow module ExecutorTest @@ -71,9 +74,7 @@ module ExecutorTest end describe "execution plan state" do - describe "after successful planning" do - let :execution_plan do world.plan(Support::CodeWorkflowExample::IncomingIssues, issues_data) end @@ -100,7 +101,6 @@ module ExecutorTest end describe "after error in planning" do - class FailingAction < Dynflow::Action def plan raise "I failed" @@ -114,7 +114,6 @@ def plan it "is stopped" do _(execution_plan.state).must_equal :stopped end - end describe "when being executed" do @@ -166,7 +165,6 @@ def plan end describe "execution of run flow" do - before do TestExecutionLog.setup end @@ -230,8 +228,8 @@ def persisted_plan describe 'handling errors in setup' do let :execution_plan do world.plan(Support::DummyExample::Polling, - external_task_id: '123', - text: 'troll setup') + external_task_id: '123', + text: 'troll setup') end it 'fails' do @@ -310,8 +308,8 @@ def persisted_plan describe 'plan with one action' do let :execution_plan do world.plan(Support::DummyExample::Polling, - { external_task_id: '123', - text: 'pause in progress 20%' }) + { external_task_id: '123', + text: 'pause in progress 20%' }) end it 'determines the progress of the execution plan in percents' do @@ -325,8 +323,8 @@ def persisted_plan describe 'plan with more action' do let :execution_plan do world.plan(Support::DummyExample::WeightedPolling, - { external_task_id: '123', - text: 'pause in progress 20%' }) + { external_task_id: '123', + text: 'pause in progress 20%' }) end it 'takes the steps weight in account' do @@ -341,8 +339,8 @@ def persisted_plan describe 'works when resumed after error' do let :execution_plan do world.plan(Support::DummyExample::Polling, - { external_task_id: '123', - text: 'troll progress' }) + { external_task_id: '123', + text: 'troll progress' }) end specify do @@ -356,11 +354,9 @@ def persisted_plan assert_equal :success, ep.run_steps.first.state end end - end describe "action with empty flows" do - let :execution_plan do world.plan(Support::CodeWorkflowExample::Dummy, { :text => "dummy" }).tap do |plan| assert_equal plan.run_flow.size, 0 @@ -379,11 +375,9 @@ def persisted_plan world.execute(execution_plan.id) assert_raises(Dynflow::Error) { world.execute(execution_plan.id).value! } end - end describe 'action with empty run flow but some finalize flow' do - let :execution_plan do world.plan(Support::CodeWorkflowExample::DummyWithFinalize, { :text => "dummy" }).tap do |plan| assert_equal plan.run_flow.size, 0 @@ -395,7 +389,6 @@ def persisted_plan _(result.result).must_equal :success _(result.state).must_equal :stopped end - end describe 'running' do @@ -417,7 +410,6 @@ def persisted_plan EXECUTED_RUN_FLOW end end - end describe "execution of finalize flow" do @@ -438,10 +430,10 @@ def persisted_plan it "runs all the steps in the finalize flow" do assert_finalized(Support::CodeWorkflowExample::IncomingIssues, - { "issues" => [{ "author" => "Peter Smith", "text" => "Failing test" }, - { "author" => "John Doe", "text" => "Internal server error" }] }) + { "issues" => [{ "author" => "Peter Smith", "text" => "Failing test" }, + { "author" => "John Doe", "text" => "Internal server error" }] }) assert_finalized(Support::CodeWorkflowExample::Triage, - { "author" => "Peter Smith", "text" => "Failing test" }) + { "author" => "Peter Smith", "text" => "Failing test" }) end end @@ -454,7 +446,6 @@ def persisted_plan _(TestExecutionLog.finalize.size).must_equal 0 end end - end describe "re-execution of run flow after fix in run phase" do @@ -493,13 +484,11 @@ def persisted_plan 13: Triage(success) {\"author\"=>\"John Doe\", \"text\"=>\"ok\"} --> {\"classification\"=>{\"assignee\"=>\"John Doe\", \"severity\"=>\"medium\"}} 16: UpdateIssue(success) {\"author\"=>\"John Doe\", \"text\"=>\"trolling\", \"assignee\"=>\"John Doe\", \"severity\"=>\"medium\"} --> {} 18: NotifyAssignee(success) {\"triage\"=>{\"classification\"=>{\"assignee\"=>\"John Doe\", \"severity\"=>\"medium\"}}} --> {} - EXECUTED_RUN_FLOW + EXECUTED_RUN_FLOW end - end describe "re-execution of run flow after fix in finalize phase" do - after do TestExecutionLog.teardown end @@ -532,13 +521,11 @@ def persisted_plan 14: Triage(success) {\"author\"=>\"John Doe\", \"text\"=>\"ok\"} --> {\"classification\"=>{\"assignee\"=>\"John Doe\", \"severity\"=>\"medium\"}} 19: NotifyAssignee(success) {\"triage\"=>{\"classification\"=>{\"assignee\"=>\"John Doe\", \"severity\"=>\"medium\"}}} --> {} 20: IncomingIssues(success) {\"issues\"=>[{\"author\"=>\"Peter Smith\", \"text\"=>\"Failing test\"}, {\"author\"=>\"John Doe\", \"text\"=>\"trolling in finalize\"}]} --> {} - EXECUTED_RUN_FLOW + EXECUTED_RUN_FLOW end - end describe "re-execution of run flow after skipping" do - after do TestExecutionLog.teardown end @@ -571,7 +558,7 @@ def persisted_plan 13: Triage(skipped) {\"author\"=>\"John Doe\", \"text\"=>\"trolling\"} --> {} 16: UpdateIssue(skipped) {\"author\"=>\"John Doe\", \"text\"=>\"trolling\", \"assignee\"=>Step(13).output[:classification][:assignee], \"severity\"=>Step(13).output[:classification][:severity]} --> {} 18: NotifyAssignee(skipped) {\"triage\"=>Step(13).output} --> {} - EXECUTED_RUN_FLOW + EXECUTED_RUN_FLOW assert_finalize_flow <<-FINALIZE_FLOW, resumed_execution_plan Dynflow::Flows::Sequence @@ -580,8 +567,7 @@ def persisted_plan 14: Triage(skipped) {\"author\"=>\"John Doe\", \"text\"=>\"trolling\"} --> {} 19: NotifyAssignee(skipped) {\"triage\"=>Step(13).output} --> {} 20: IncomingIssues(success) {\"issues\"=>[{\"author\"=>\"Peter Smith\", \"text\"=>\"Failing test\"}, {\"author\"=>\"John Doe\", \"text\"=>\"trolling\"}]} --> {} - FINALIZE_FLOW - + FINALIZE_FLOW end end @@ -617,7 +603,6 @@ def assert_next_steps(expected_next_step_ids, finished_step_id = nil, success = end describe 'what_is_next with errors' do - it "doesn't return next steps if requirements failed" do assert_next_steps([4, 13]) assert_next_steps([], 4, false) @@ -631,7 +616,6 @@ def assert_next_steps(expected_next_step_ids, finished_step_id = nil, success = assert manager.done? end end - end describe 'Pool::JobStorage' do @@ -673,7 +657,6 @@ def assert_next_steps(expected_next_step_ids, finished_step_id = nil, success = assert_nil storage.pop end end - end describe 'termination' do @@ -682,7 +665,7 @@ def assert_next_steps(expected_next_step_ids, finished_step_id = nil, success = it 'waits for currently running actions' do $slow_actions_done = 0 running = world.trigger(Support::DummyExample::Slow, 1) - suspended = world.trigger(Support::DummyExample::DeprecatedEventedAction, :timeout => 3 ) + suspended = world.trigger(Support::DummyExample::DeprecatedEventedAction, :timeout => 3) sleep 0.2 world.terminate.wait _($slow_actions_done).must_equal 1 diff --git a/test/extensions_test.rb b/test/extensions_test.rb index 70dd323c6..36a733de5 100644 --- a/test/extensions_test.rb +++ b/test/extensions_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'active_support/time' diff --git a/test/flows_test.rb b/test/flows_test.rb index e1768e374..0df16f019 100644 --- a/test/flows_test.rb +++ b/test/flows_test.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'mocha/minitest' module Dynflow describe 'flow' do - class TestRegistry < Flows::Registry class << self def reset! @@ -22,7 +22,7 @@ def reset! TestRegistry.register!(TestRegistry, 'TS') TestRegistry.register!(Integer, 'I') map = TestRegistry.instance_variable_get("@serialization_map") - _(map).must_equal({'TS' => TestRegistry, 'I' => Integer}) + _(map).must_equal({ 'TS' => TestRegistry, 'I' => Integer }) end it "prevents overwriting values" do diff --git a/test/future_execution_test.rb b/test/future_execution_test.rb index bea1c1b6b..b548f9379 100644 --- a/test/future_execution_test.rb +++ b/test/future_execution_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' module Dynflow @@ -9,7 +10,6 @@ module FutureExecutionTest include Dynflow::Testing::Factories describe 'action scheduling' do - before do @start_at = Time.now.utc + 180 world.persistence.delete_delayed_plans({}) @@ -98,10 +98,9 @@ module FutureExecutionTest delayed_plan.timeout _(execution_plan.state).must_equal :stopped _(execution_plan.result).must_equal :error - _(execution_plan.errors.first.message).must_match /could not be started before set time/ + _(execution_plan.errors.first.message).must_match(/could not be started before set time/) _(history_names.call(execution_plan)).must_equal %W(delay timeout) end - end describe 'polling delayed executor' do diff --git a/test/memory_cosumption_watcher_test.rb b/test/memory_cosumption_watcher_test.rb index caa04c940..33a59607b 100644 --- a/test/memory_cosumption_watcher_test.rb +++ b/test/memory_cosumption_watcher_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'fileutils' require 'dynflow/watchers/memory_consumption_watcher' diff --git a/test/middleware_test.rb b/test/middleware_test.rb index a1bf614ab..a1723a56f 100644 --- a/test/middleware_test.rb +++ b/test/middleware_test.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true + require_relative 'test_helper' module Dynflow module MiddlewareTest - describe 'Middleware' do let(:world) { WorldFactory.create_world } let(:log) { Support::MiddlewareExample::LogMiddleware.log } @@ -77,8 +77,7 @@ module MiddlewareTest let(:world_with_middleware) do WorldFactory.create_world.tap do |world| world.middleware.use(Support::MiddlewareExample::AnotherLogRunMiddleware, - after: Support::MiddlewareExample::LogRunMiddleware) - + after: Support::MiddlewareExample::LogRunMiddleware) end end @@ -112,7 +111,7 @@ module MiddlewareTest it "allows access the running action" do world = WorldFactory.create_world world.middleware.use(Support::MiddlewareExample::ObservingMiddleware, - replace: Support::MiddlewareExample::LogRunMiddleware) + replace: Support::MiddlewareExample::LogRunMiddleware) world.trigger(Support::MiddlewareExample::Action, message: 'hello').finished.wait _(log).must_equal %w[input#message:hello run @@ -122,7 +121,7 @@ module MiddlewareTest it "allows modification of the running action when delaying execution" do world = WorldFactory.create_world world.middleware.use(Support::MiddlewareExample::AnotherObservingMiddleware, - replace: Support::MiddlewareExample::LogRunMiddleware) + replace: Support::MiddlewareExample::LogRunMiddleware) delay = world.delay(Support::MiddlewareExample::Action, { :start_at => Time.now - 60 }) plan = world.persistence.load_delayed_plan delay.execution_plan_id plan.plan @@ -183,7 +182,6 @@ module MiddlewareTest _(presenter_without_middleware.input['text']).must_equal('Lord Voldemort is comming') end end - end end end diff --git a/test/persistence_test.rb b/test/persistence_test.rb index 16f7f3f5d..aa0e87ecc 100644 --- a/test/persistence_test.rb +++ b/test/persistence_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'tmpdir' require 'ostruct' @@ -6,7 +7,6 @@ module Dynflow module PersistenceTest describe 'persistence adapters' do - let :execution_plans_data do [{ id: 'plan1', :label => 'test1', root_plan_step_id: 1, class: 'Dynflow::ExecutionPlan', state: 'paused' }, { id: 'plan2', :label => 'test2', root_plan_step_id: 1, class: 'Dynflow::ExecutionPlan', state: 'stopped' }, @@ -20,8 +20,8 @@ module PersistenceTest caller_execution_plan_id: nil, caller_action_id: nil, class: 'Dynflow::Action', - input: {key: 'value'}, - output: {something: 'else'}, + input: { key: 'value' }, + output: { something: 'else' }, plan_step_id: 1, run_step_id: 2, finalize_step_id: 3 @@ -150,9 +150,9 @@ def self.it_acts_as_persistence_adapter _(loaded_plans).must_be_empty adapter.save_delayed_plan('plan1', - :execution_plan_uuid => 'plan1', - :start_at => format_time(Time.now + 60), - :start_before => format_time(Time.now - 60)) + :execution_plan_uuid => 'plan1', + :start_at => format_time(Time.now + 60), + :start_before => format_time(Time.now - 60)) loaded_plans = adapter.find_execution_plans(filters: { label: ['test1'], :delayed => true }) _(loaded_plans.map { |h| h[:id] }).must_equal ['plan1'] end @@ -169,29 +169,29 @@ def self.it_acts_as_persistence_adapter prepare_and_save_plans if adapter.ordering_by.include?('state') loaded_plans = adapter.find_execution_plan_statuses(filters: { label: ['test1'] }) - _(loaded_plans).must_equal({ 'plan1' => { state: 'paused', result: nil} }) + _(loaded_plans).must_equal({ 'plan1' => { state: 'paused', result: nil } }) loaded_plans = adapter.find_execution_plan_statuses(filters: { state: ['paused'] }) - _(loaded_plans).must_equal({"plan1"=>{:state=>"paused", :result=>nil}, - "plan3"=>{:state=>"paused", :result=>nil}, - "plan4"=>{:state=>"paused", :result=>nil}}) + _(loaded_plans).must_equal({ "plan1" => { :state => "paused", :result => nil }, + "plan3" => { :state => "paused", :result => nil }, + "plan4" => { :state => "paused", :result => nil } }) loaded_plans = adapter.find_execution_plan_statuses(filters: { state: ['stopped'] }) - _(loaded_plans).must_equal({"plan2"=>{:state=>"stopped", :result=>nil}}) + _(loaded_plans).must_equal({ "plan2" => { :state => "stopped", :result => nil } }) loaded_plans = adapter.find_execution_plan_statuses(filters: { state: [] }) _(loaded_plans).must_equal({}) loaded_plans = adapter.find_execution_plan_statuses(filters: { state: ['stopped', 'paused'] }) - _(loaded_plans).must_equal({"plan1"=>{:state=>"paused", :result=>nil}, - "plan2"=>{:state=>"stopped", :result=>nil}, - "plan3"=>{:state=>"paused", :result=>nil}, "plan4"=>{:state=>"paused", :result=>nil}}) + _(loaded_plans).must_equal({ "plan1" => { :state => "paused", :result => nil }, + "plan2" => { :state => "stopped", :result => nil }, + "plan3" => { :state => "paused", :result => nil }, "plan4" => { :state => "paused", :result => nil } }) loaded_plans = adapter.find_execution_plan_statuses(filters: { 'state' => ['stopped', 'paused'] }) - _(loaded_plans).must_equal({"plan1"=>{:state=>"paused", :result=>nil}, - "plan2"=>{:state=>"stopped", :result=>nil}, - "plan3"=>{:state=>"paused", :result=>nil}, - "plan4"=>{:state=>"paused", :result=>nil}}) + _(loaded_plans).must_equal({ "plan1" => { :state => "paused", :result => nil }, + "plan2" => { :state => "stopped", :result => nil }, + "plan3" => { :state => "paused", :result => nil }, + "plan4" => { :state => "paused", :result => nil } }) loaded_plans = adapter.find_execution_plan_statuses(filters: { label: ['test1'], :delayed => true }) _(loaded_plans).must_equal({}) @@ -229,9 +229,9 @@ def self.it_acts_as_persistence_adapter _(loaded_plans).must_equal 0 adapter.save_delayed_plan('plan1', - :execution_plan_uuid => 'plan1', - :start_at => format_time(Time.now + 60), - :start_before => format_time(Time.now - 60)) + :execution_plan_uuid => 'plan1', + :start_at => format_time(Time.now + 60), + :start_before => format_time(Time.now - 60)) loaded_plans = adapter.find_execution_plan_counts(filters: { label: ['test1'], :delayed => true }) _(loaded_plans).must_equal 1 end @@ -276,14 +276,14 @@ def self.it_acts_as_persistence_adapter it 'creates backup dir and produce backup including steps and actions' do prepare_plans_with_steps Dir.mktmpdir do |backup_dir| - _(adapter.delete_execution_plans({'uuid' => 'plan1'}, 100, backup_dir)).must_equal 1 + _(adapter.delete_execution_plans({ 'uuid' => 'plan1' }, 100, backup_dir)).must_equal 1 plans = CSV.read(backup_dir + "/execution_plans.csv", :headers => true) assert_equal 1, plans.count assert_equal 'plan1', plans.first.to_hash['uuid'] actions = CSV.read(backup_dir + "/actions.csv", :headers => true) assert_equal 1, actions.count assert_equal 'plan1', actions.first.to_hash['execution_plan_uuid'] - steps = CSV.read(backup_dir +"/steps.csv", :headers => true) + steps = CSV.read(backup_dir + "/steps.csv", :headers => true) assert_equal 1, steps.count assert_equal 'plan1', steps.first.to_hash['execution_plan_uuid'] end @@ -376,7 +376,7 @@ def self.it_acts_as_persistence_adapter it 'deletes output chunks' do prepare_plans_with_actions - adapter.save_output_chunks('plan1', 1, [{chunk: "Hello", timestamp: Time.now}, {chunk: "Bye", timestamp: Time.now}]) + adapter.save_output_chunks('plan1', 1, [{ chunk: "Hello", timestamp: Time.now }, { chunk: "Bye", timestamp: Time.now }]) chunks = adapter.load_output_chunks('plan1', 1) _(chunks.length).must_equal 2 deleted = adapter.delete_output_chunks('plan1', 1) @@ -451,7 +451,7 @@ def self.it_acts_as_persistence_adapter envelopes = [client_envelope, executor_envelope] envelopes.each { |e| adapter.push_envelope(e) } - adapter.insert_coordinator_record({"class"=>"Dynflow::Coordinator::ExecutorWorld", + adapter.insert_coordinator_record({ "class" => "Dynflow::Coordinator::ExecutorWorld", "id" => executor_world_id, "meta" => {}, "active" => true }) assert_equal 1, adapter.prune_undeliverable_envelopes @@ -526,7 +526,7 @@ def self.it_acts_as_persistence_adapter value = 'a' * 1000 - adata = action_data.merge({:output => { :key => value }}) + adata = action_data.merge({ :output => { :key => value } }) plan_record = adapter.send(:prepare_record, :execution_plan, plan.merge(:uuid => plan[:id])) action_record = adapter.send(:prepare_record, :action, adata.dup) diff --git a/test/redis_locking_test.rb b/test/redis_locking_test.rb index f0536c467..b92fbb87f 100644 --- a/test/redis_locking_test.rb +++ b/test/redis_locking_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'mocha/minitest' require 'minitest/stub_const' diff --git a/test/rescue_test.rb b/test/rescue_test.rb index 4022655da..3e3388e48 100644 --- a/test/rescue_test.rb +++ b/test/rescue_test.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true + require_relative 'test_helper' module Dynflow module RescueTest describe 'on error' do - Example = Support::RescueExample let(:world) { WorldFactory.create_world } @@ -21,7 +21,6 @@ def execute(*args) describe 'no auto rescue' do describe 'of simple skippable action in run phase' do - let :execution_plan do execute(Example::ActionWithSkip, 1, :error_on_run) end @@ -36,7 +35,6 @@ def execute(*args) end describe 'of simple skippable action in finalize phase' do - let :execution_plan do execute(Example::ActionWithSkip, 1, :error_on_finalize) end @@ -51,7 +49,6 @@ def execute(*args) end describe 'of complex action with skips in run phase' do - let :execution_plan do execute(Example::ComplexActionWithSkip, :error_on_run) end @@ -66,7 +63,6 @@ def execute(*args) end describe 'of complex action with skips in finalize phase' do - let :execution_plan do execute(Example::ComplexActionWithSkip, :error_on_finalize) end @@ -81,7 +77,6 @@ def execute(*args) end describe 'of complex action without skips' do - let :execution_plan do execute(Example::ComplexActionWithoutSkip, :error_on_run) end @@ -96,7 +91,6 @@ def execute(*args) end describe 'of complex action with fail' do - let :execution_plan do execute(Example::ComplexActionWithFail, :error_on_run) end @@ -112,7 +106,6 @@ def execute(*args) end describe 'auto rescue' do - let(:world) do WorldFactory.create_world do |config| config.auto_rescue = true @@ -127,8 +120,8 @@ def execute(*args) it 'skips the action and continues' do _(rescued_plan.state).must_equal :stopped _(rescued_plan.result).must_equal :warning - _(rescued_plan.entry_action.output[:message]). - must_equal "skipped because some error as you wish" + _(rescued_plan.entry_action.output[:message]) + .must_equal "skipped because some error as you wish" end end @@ -215,7 +208,6 @@ def execute(*args) _(execution_plan.execution_history.map { |h| [h.name, h.world_id] }).must_equal(expected_history) end end - end end end diff --git a/test/round_robin_test.rb b/test/round_robin_test.rb index 7faf84d5f..0fffed9b3 100644 --- a/test/round_robin_test.rb +++ b/test/round_robin_test.rb @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # frozen_string_literal: true + require_relative 'test_helper' module Dynflow diff --git a/test/semaphores_test.rb b/test/semaphores_test.rb index 777cb9f48..52a3f672d 100644 --- a/test/semaphores_test.rb +++ b/test/semaphores_test.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true + require_relative 'test_helper' module Dynflow module SemaphoresTest describe ::Dynflow::Semaphores::Stateful do - let(:semaphore_class) { ::Dynflow::Semaphores::Stateful } let(:tickets_count) { 5 } @@ -41,7 +41,6 @@ module SemaphoresTest waiting = semaphore.get_waiting _(waiting).must_equal 3 end - end describe ::Dynflow::Semaphores::Dummy do @@ -71,10 +70,10 @@ module SemaphoresTest } end - def assert_semaphore_state(semaphore, state_A, state_B) - _(semaphore.children[:child_A].free).must_equal state_A - _(semaphore.children[:child_B].free).must_equal state_B - _(semaphore.free).must_equal [state_A, state_B].min + def assert_semaphore_state(semaphore, state_a, state_b) + _(semaphore.children[:child_A].free).must_equal state_a + _(semaphore.children[:child_B].free).must_equal state_b + _(semaphore.free).must_equal [state_a, state_b].min end it 'can be used as counter' do @@ -94,6 +93,5 @@ def assert_semaphore_state(semaphore, state_A, state_B) assert_semaphore_state semaphore, 0, 0 end end - end end diff --git a/test/support/code_workflow_example.rb b/test/support/code_workflow_example.rb index c181bdc49..3d8b46a0f 100644 --- a/test/support/code_workflow_example.rb +++ b/test/support/code_workflow_example.rb @@ -1,11 +1,10 @@ # frozen_string_literal: true + require 'logger' module Support module CodeWorkflowExample - class IncomingIssues < Dynflow::Action - def plan(issues) issues.each do |issue| plan_action(IncomingIssue, issue) @@ -36,7 +35,6 @@ def summary end class IncomingIssue < Dynflow::Action - def plan(issue) raise "You want me to fail" if issue == :fail plan_self(issue) @@ -47,18 +45,16 @@ def plan(issue) param :author, String param :text, String end - end class Triage < Dynflow::Action - def plan(issue) triage = plan_self(issue) plan_action(UpdateIssue, - author: triage.input[:author], - text: triage.input[:text], - assignee: triage.output[:classification][:assignee], - severity: triage.output[:classification][:severity]) + author: triage.input[:author], + text: triage.input[:text], + assignee: triage.output[:classification][:assignee], + severity: triage.output[:classification][:severity]) end input_format do @@ -84,11 +80,9 @@ def finalize error! 'Trolling detected' if input[:text] == "trolling in finalize" TestExecutionLog.finalize << self end - end class UpdateIssue < Dynflow::Action - input_format do param :author, String param :text, String @@ -101,7 +95,6 @@ def run end class NotifyAssignee < Dynflow::Action - def self.subscribe Triage end @@ -137,15 +130,14 @@ def plan(commit, reviews = { 'Morfeus' => true, 'Neo' => true }) end plan_action(Merge, - commit: commit, - ci_result: ci.output[:passed], - review_results: review_actions.map { |ra| ra.output[:passed] }) + commit: commit, + ci_result: ci.output[:passed], + review_results: review_actions.map { |ra| ra.output[:passed] }) end end end class FastCommit < Dynflow::Action - def plan(commit) sequence do ci, review = concurrence do @@ -154,20 +146,18 @@ def plan(commit) end plan_action(Merge, - commit: commit, - ci_result: ci.output[:passed], - review_results: [review.output[:passed]]) + commit: commit, + ci_result: ci.output[:passed], + review_results: [review.output[:passed]]) end end input_format do param :sha, String end - end class Ci < Dynflow::Action - input_format do param :commit, Commit.input_format end @@ -182,7 +172,6 @@ def run end class Review < Dynflow::Action - input_format do param :reviewer, String param :commit, Commit.input_format @@ -202,7 +191,6 @@ def run end class Merge < Dynflow::Action - input_format do param :commit, Commit.input_format param :ci_result, Ci.output_format @@ -233,25 +221,21 @@ class DummyAnotherTrigger < Dynflow::Action end class DummySubscribe < Dynflow::Action - def self.subscribe DummyTrigger end def run end - end class DummyMultiSubscribe < Dynflow::Action - def self.subscribe [DummyTrigger, DummyAnotherTrigger] end def run end - end class CancelableSuspended < Dynflow::Action @@ -301,6 +285,5 @@ def run_progress external_task && external_task[:progress].to_f / 100 end end - end end diff --git a/test/support/dummy_example.rb b/test/support/dummy_example.rb index a278ea416..94c3a9a71 100644 --- a/test/support/dummy_example.rb +++ b/test/support/dummy_example.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'logger' module Support @@ -24,6 +25,7 @@ class DummyCustomDelaySerializer < Dynflow::Action def delay(delay_options, *args) MySerializer.new(args) end + def run; end end @@ -43,7 +45,7 @@ def run sleep input[:interval] action_logger.debug 'done with sleeping' $slow_actions_done ||= 0 - $slow_actions_done +=1 + $slow_actions_done += 1 end def queue @@ -87,7 +89,6 @@ def run_progress end class WeightedPolling < Dynflow::Action - def plan(input) sequence do plan_self(input) @@ -148,23 +149,23 @@ def run(event = nil) class ComposedAction < Dynflow::Action def run(event = nil) match event, - (on nil do - sub_plan = world.trigger(Dummy) - output[:sub_plan_id] = sub_plan.id - suspend do |suspended_action| - if input[:timeout] - world.clock.ping suspended_action, input[:timeout], "timeout" - end - - sub_plan.finished.on_fulfillment! { suspended_action << 'finish' } - end - end), - (on 'finish' do - output[:event] = 'finish' - end), - (on 'timeout' do - output[:event] = 'timeout' - end) + (on nil do + sub_plan = world.trigger(Dummy) + output[:sub_plan_id] = sub_plan.id + suspend do |suspended_action| + if input[:timeout] + world.clock.ping suspended_action, input[:timeout], "timeout" + end + + sub_plan.finished.on_fulfillment! { suspended_action << 'finish' } + end + end), + (on 'finish' do + output[:event] = 'finish' + end), + (on 'timeout' do + output[:event] = 'timeout' + end) end end end diff --git a/test/support/middleware_example.rb b/test/support/middleware_example.rb index 9bcba667a..9d0f4421d 100644 --- a/test/support/middleware_example.rb +++ b/test/support/middleware_example.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Support module MiddlewareExample class LogMiddleware < Dynflow::Middleware - def self.log @log end @@ -17,7 +17,7 @@ def log(message) def delay(*args) log 'before_delay' - pass *args + pass(*args) log 'after_delay' end @@ -51,11 +51,9 @@ def finalize_phase(*_) pass log 'after_finalize_phase' end - end class LogRunMiddleware < Dynflow::Middleware - def log(message) LogMiddleware.log << "#{self.class.name[/\w+$/]}::#{message}" end @@ -105,7 +103,6 @@ def filter_sensitive_data end class LoggingAction < Dynflow::Action - middleware.use LogMiddleware def log(message) @@ -132,7 +129,6 @@ def finalize end class ObservingMiddleware < Dynflow::Middleware - def log(message) LogMiddleware.log << message end @@ -146,7 +142,6 @@ def run(*args) end class AnotherObservingMiddleware < ObservingMiddleware - def delay(*args) pass(*args).tap do log("delay#set-input:#{action.world.id}") @@ -158,7 +153,6 @@ def plan(*args) log("plan#input:#{action.input[:message]}") pass(*args) end - end class Action < Dynflow::Action diff --git a/test/support/rescue_example.rb b/test/support/rescue_example.rb index 3705afd12..0387ce045 100644 --- a/test/support/rescue_example.rb +++ b/test/support/rescue_example.rb @@ -1,11 +1,10 @@ # frozen_string_literal: true + require 'logger' module Support module RescueExample - class ComplexActionWithSkip < Dynflow::Action - def plan(error_state) sequence do concurrence do @@ -20,20 +19,16 @@ def plan(error_state) def rescue_strategy_for_self Dynflow::Action::Rescue::Skip end - end class ComplexActionWithoutSkip < ComplexActionWithSkip - def rescue_strategy_for_planned_action(action) # enforce pause even when error on skipable action Dynflow::Action::Rescue::Pause end - end class AbstractAction < Dynflow::Action - def plan(identifier, desired_state) plan_self(identifier: identifier, desired_state: desired_state) end @@ -57,11 +52,9 @@ def finalize raise 'some error as you wish' end end - end class ActionWithSkip < AbstractAction - def run(event = nil) if event === Dynflow::Action::Skip output[:message] = "skipped because #{self.error.message}" @@ -74,19 +67,15 @@ def run(event = nil) def rescue_strategy_for_self Dynflow::Action::Rescue::Skip end - end class ActionWithFail < AbstractAction - def rescue_strategy_for_self Dynflow::Action::Rescue::Fail end - end class ComplexActionWithFail < ActionWithFail - def plan(error_state) sequence do concurrence do @@ -97,8 +86,6 @@ def plan(error_state) plan_action(ActionWithSkip, 6, :success) end end - end - end end diff --git a/test/support/test_execution_log.rb b/test/support/test_execution_log.rb index c4fc23914..528801222 100644 --- a/test/support/test_execution_log.rb +++ b/test/support/test_execution_log.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class TestExecutionLog +class TestExecutionLog include Enumerable def initialize @@ -38,5 +38,4 @@ def self.run def self.finalize @finalize || [] end - end diff --git a/test/test_helper.rb b/test/test_helper.rb index 3f683cd33..5cd8e5990 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'bundler/setup' require 'minitest/reporters' require 'minitest/autorun' @@ -13,7 +14,6 @@ require 'dynflow' require 'dynflow/testing' begin require 'pry'; rescue LoadError; nil end - require 'support/code_workflow_example' require 'support/middleware_example' require 'support/rescue_example' @@ -24,7 +24,6 @@ # To be able to stop a process in some step and perform assertions while paused class TestPause - def self.setup @pause = Concurrent::Promises.resolvable_future @ready = Concurrent::Promises.resolvable_future @@ -78,7 +77,6 @@ def delete_record(record) end module WorldFactory - def self.created_worlds @created_worlds ||= [] end @@ -129,7 +127,7 @@ def self.coordinator_adapter def self.clean_coordinator_records persistence_adapter = WorldFactory.persistence_adapter persistence_adapter.find_coordinator_records({}).each do |w| - warn "Unexpected coordinator record: #{ w }" + warn "Unexpected coordinator record: #{w}" persistence_adapter.delete_coordinator_record(w[:class], w[:id]) end end @@ -230,7 +228,7 @@ def assert_plan_reexecuted(plan) 'terminate execution', 'start execution', 'finish execution'], - plan.execution_history.map(&:name) + plan.execution_history.map(&:name) refute_equal plan.execution_history.first.world_id, plan.execution_history.to_a.last.world_id end end @@ -302,7 +300,6 @@ def teardown wait_method.bind(self).call(timeout || default_timeout) end end - end events_test.call @@ -331,7 +328,6 @@ def finish end module PlanAssertions - def inspect_flow(execution_plan, flow) out = "".dup inspect_subflow(out, execution_plan, flow, "".dup) diff --git a/test/testing_test.rb b/test/testing_test.rb index 9ea830777..e3b17aa7f 100644 --- a/test/testing_test.rb +++ b/test/testing_test.rb @@ -1,15 +1,14 @@ # frozen_string_literal: true + require_relative 'test_helper' module Dynflow - CWE = Support::CodeWorkflowExample describe Testing do include Testing describe 'testing' do - specify '#plan_action' do input = { 'input' => 'input' } action = create_and_plan_action Support::DummyExample::WeightedPolling, input @@ -63,20 +62,20 @@ module Dynflow _(action.run_progress).must_equal 0 3.times { progress_action_time action } - _(action.output).must_equal('task' => { 'progress' => 30, 'done' => false } , - 'poll_attempts' => {'total' => 2, 'failed'=> 0 }) + _(action.output).must_equal('task' => { 'progress' => 30, 'done' => false }, + 'poll_attempts' => { 'total' => 2, 'failed' => 0 }) _(action.run_progress).must_equal 0.3 run_action action, Dynflow::Action::Polling::Poll run_action action, Dynflow::Action::Polling::Poll _(action.output).must_equal('task' => { 'progress' => 50, 'done' => false }, - 'poll_attempts' => {'total' => 4, 'failed' => 0 }) + 'poll_attempts' => { 'total' => 4, 'failed' => 0 }) _(action.run_progress).must_equal 0.5 5.times { progress_action_time action } _(action.output).must_equal('task' => { 'progress' => 100, 'done' => true }, - 'poll_attempts' => {'total' => 9, 'failed' => 0 }) + 'poll_attempts' => { 'total' => 9, 'failed' => 0 }) _(action.run_progress).must_equal 1 end @@ -100,7 +99,6 @@ module Dynflow end describe 'testing examples' do - describe CWE::Commit do it 'plans' do action = create_and_plan_action CWE::Commit, sha = 'commit-sha' @@ -125,7 +123,7 @@ module Dynflow it 'plans' do _(planned_action.input).must_equal Utils.stringify_keys(input) - assert_run_phase planned_action, { commit: "sha", reviewer: "name", result: true} + assert_run_phase planned_action, { commit: "sha", reviewer: "name", result: true } refute_finalize_phase planned_action _(planned_action.execution_plan.planned_plan_steps).must_be_empty diff --git a/test/utils_test.rb b/test/utils_test.rb index 404ec0a32..599bd7cef 100644 --- a/test/utils_test.rb +++ b/test/utils_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' module Dynflow diff --git a/test/v2_sub_plans_test.rb b/test/v2_sub_plans_test.rb index b6c644e75..311b1c9df 100644 --- a/test/v2_sub_plans_test.rb +++ b/test/v2_sub_plans_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'mocha/minitest' diff --git a/test/web_console_test.rb b/test/web_console_test.rb index 965be0257..0a363e979 100644 --- a/test/web_console_test.rb +++ b/test/web_console_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' ENV['RACK_ENV'] = 'test' @@ -8,14 +9,13 @@ module Dynflow describe 'web console' do - include Rack::Test::Methods let(:world) { WorldFactory.create_world } let :execution_plan_id do - world.trigger(Support::CodeWorkflowExample::FastCommit, 'sha' => 'abc123'). - tap { |o| o.finished.wait }. - id + world.trigger(Support::CodeWorkflowExample::FastCommit, 'sha' => 'abc123') + .tap { |o| o.finished.wait } + .id end let :app do diff --git a/test/world_test.rb b/test/world_test.rb index d96914b73..e87135ad8 100644 --- a/test/world_test.rb +++ b/test/world_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'test_helper' require 'fileutils' @@ -14,7 +15,7 @@ module WorldTest registered_world.meta.delete('last_seen') _(registered_world.meta).must_equal('hostname' => Socket.gethostname, 'pid' => Process.pid, 'queues' => { 'default' => { 'pool_size' => 5 }, - 'slow' => { 'pool_size' => 1 }}) + 'slow' => { 'pool_size' => 1 } }) end it 'is configurable' do @@ -26,7 +27,7 @@ module WorldTest describe '#get_execution_status' do let(:base) do { :default => { :pool_size => 5, :free_workers => 5, :queue_size => 0 }, - :slow => { :pool_size=> 1, :free_workers=> 1, :queue_size => 0} } + :slow => { :pool_size => 1, :free_workers => 1, :queue_size => 0 } } end it 'retrieves correct execution items count' do @@ -34,7 +35,7 @@ module WorldTest id = 'something like uuid' expected = base.dup expected[:default][:queue_size] = 0 - expected[:slow][:queue_size] = 0 + expected[:slow][:queue_size] = 0 _(world.get_execution_status(world.id, id, 5).value!).must_equal(expected) end end