Skip to content

Commit

Permalink
EmrEtlRunner: fail fast when trying to skip staging or enrich in stre…
Browse files Browse the repository at this point in the history
…am enrich mode (close #3726)
  • Loading branch information
chuwy committed Apr 17, 2018
1 parent 1c0e333 commit 1d2cd2c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
13 changes: 12 additions & 1 deletion 3-enrich/emr-etl-runner/lib/snowplow-emr-etl-runner/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,20 @@ def self.validate_and_coalesce(args, config)
raise ConfigError, 'resume-from and skip are mutually exclusive'
end

if args[:resume_from] == "staging_stream_enrich" && config[:aws][:s3][:buckets][:enriched][:stream].nil?
if args[:resume_from] == "staging_stream_enrich" && config.dig(:aws, :s3, :buckets, :enriched, :stream).nil?
raise ConfigError, 'staging_stream_enrich is invalid step to resume from without aws.s3.buckets.enriched.stream settings'
end
unless config.dig(:aws, :s3, :buckets, :enriched, :stream).nil?
if args[:resume_from] == "enrich"
raise ConfigError, 'cannot resume from enrich in stream enrich mode'
end
if args[:skip].include?('staging') || args[:skip].include?('enrich')
raise ConfigError, 'cannot skip staging nor enrich in stream enrich mode. Either skip staging_stream_enrich or resume from shred'
end
if args[:skip].include?('archive_raw') || args[:resume_from] == "archive_raw"
raise ConfigError, 'cannot skip nor resume from archive_raw in stream enrich mode'
end
end

args[:include].each { |opt|
unless INCLUDES.include?(opt)
Expand Down
17 changes: 15 additions & 2 deletions 3-enrich/emr-etl-runner/spec/snowplow-emr-etl-runner/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,22 @@ def resource(name)
Cli.validate_and_coalesce(a, c)
end

it 'should accept stream-mode config' do
it 'should accept stream enrich mode config' do
Cli.validate_and_coalesce(a, s)
end
end

it 'should reject --skip staging in stream enrich mode' do
a[:skip] = [ 'staging' ]
expect {
Cli.validate_and_coalesce(a, s)
}.to raise_exception( ConfigError, "cannot skip staging nor enrich in stream enrich mode. Either skip staging_stream_enrich or resume from shred")
end

it 'should reject --resume-from enrich in stream enrich mode' do
a[:resume_from] = 'enrich'
expect {
Cli.validate_and_coalesce(a, s)
}.to raise_exception( ConfigError, "cannot resume from enrich in stream enrich mode")
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ aws:
enriched:
good: eg # e.g. s3://my-out-bucket/enriched/good
archive: ea # Where to archive enriched events to, e.g. s3://my-out-bucket/enriched/archive
stream: es # Where to archive enriched events to, e.g. s3://my-out-bucket/enriched/archive
shredded:
good: sg # e.g. s3://my-out-bucket/shredded/good
bad: sb # e.g. s3://my-out-bucket/shredded/bad
Expand Down

0 comments on commit 1d2cd2c

Please sign in to comment.