Skip to content

Commit

Permalink
Fail fast when trying to skip staging or enrich in stream enrich mode (
Browse files Browse the repository at this point in the history
  • Loading branch information
chuwy authored and peel committed May 25, 2020
1 parent cc263d4 commit f133b8a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
13 changes: 12 additions & 1 deletion 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
24 changes: 22 additions & 2 deletions spec/snowplow-emr-etl-runner/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,29 @@ 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

it 'should reject --skip archive_raw in stream enrich mode' do
a[:skip] = [ 'archive_raw' ]
expect {
Cli.validate_and_coalesce(a, s)
}.to raise_exception(ConfigError, "cannot skip nor resume from archive_raw in stream enrich mode")
end
end
end
1 change: 1 addition & 0 deletions spec/snowplow-emr-etl-runner/resources/stream_config.yml
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 f133b8a

Please sign in to comment.