diff --git a/.dockerignore b/.dockerignore index 729f08b..0874bc7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -11,3 +11,4 @@ coverage .dockerignore .rspec_status local +.env diff --git a/Dockerfile b/Dockerfile index 5eb77e9..8382b2c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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/ diff --git a/spec/kubetruth/etl_spec.rb b/spec/kubetruth/etl_spec.rb index aaf0d27..ad5d0d0 100644 --- a/spec/kubetruth/etl_spec.rb +++ b/spec/kubetruth/etl_spec.rb @@ -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