Skip to content

Commit

Permalink
fix docker build and add concurrency test
Browse files Browse the repository at this point in the history
  • Loading branch information
wr0ngway committed Oct 24, 2023
1 parent 369118d commit e8a3fc8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ coverage
.dockerignore
.rspec_status
local
.env
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ COPY Gemfile* $APP_DIR/
RUN bundle config --local without 'development test' && \
bundle install --jobs=4

RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing kubectl
RUN apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community kubectl

COPY . $APP_DIR/

Expand Down
32 changes: 32 additions & 0 deletions spec/kubetruth/etl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,38 @@ class ForceExit < Exception; end

etl.apply()
end

it "honors concurrency limit" do
sleep_val = 1
allow(etl).to receive(:load_config).and_yield(@ns, config)

# causes 4 executions of kube_apply
allow(collection).to receive(:names).and_return(["foo", "bar"])

run_count = 0
allow(etl).to receive(:kube_apply) do
run_count += 1
sleep sleep_val
nil
end

etl.instance_variable_set(:@async_concurrency, 2)
duration1 = Benchmark.measure do
etl.apply()
end
expect(run_count).to eq(4)
expect(duration1.real).to be > (sleep_val + 0.1)
expect(duration1.real).to be > (run_count / 2 * sleep_val)

run_count = 0
etl.instance_variable_set(:@async_concurrency, 10)
duration2 = Benchmark.measure do
etl.apply()
end
expect(run_count).to eq(4)
expect(duration2.real).to be < (sleep_val + 0.1)
end

end

describe "default templates" do
Expand Down

0 comments on commit e8a3fc8

Please sign in to comment.