Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-12-29 18:13:59 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-12-29 18:13:59 +0300
commit36c4308d16638c60fe2ccc251a2e06e25154ee6a (patch)
tree44e85bbfd2eaeee315b69f25e552a086f6dd4e24 /spec/models
parentd1fe6b3349f1e8cb8477630448f9933e364a1ca8 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/ci/runner_spec.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/models/ci/runner_spec.rb b/spec/models/ci/runner_spec.rb
index 1a989e757b6..8c4d5fef24d 100644
--- a/spec/models/ci/runner_spec.rb
+++ b/spec/models/ci/runner_spec.rb
@@ -1198,6 +1198,46 @@ RSpec.describe Ci::Runner, type: :model, feature_category: :runner do
end
end
+ describe '#clear_heartbeat', :freeze_time do
+ let!(:runner) { create(:ci_runner, :project, version: '15.0.0') }
+ let(:heartbeat_values) do
+ {
+ version: '15.0.1',
+ platform: 'darwin',
+ architecture: '18-bit',
+ ip_address: '1.1.1.1',
+ executor: 'shell',
+ revision: 'sha',
+ config: { 'gpus' => 'all' }
+ }
+ end
+
+ let(:expected_attributes) { heartbeat_values.except(:executor).merge(executor_type: 'shell') }
+ let(:expected_cleared_attributes) { expected_attributes.to_h { |key, _| [key, nil] }.merge(config: {}) }
+
+ it 'clears contacted at and other attributes' do
+ expect do
+ runner.heartbeat(heartbeat_values)
+ end.to change { runner.reload.contacted_at }.from(nil).to(Time.current)
+ .and change { runner.reload.uncached_contacted_at }.from(nil).to(Time.current)
+
+ expected_attributes.each do |key, value|
+ expect(runner.public_send(key)).to eq(value)
+ expect(runner.read_attribute(key)).to eq(value)
+ end
+
+ expect do
+ runner.clear_heartbeat
+ end.to change { runner.reload.contacted_at }.from(Time.current).to(nil)
+ .and change { runner.reload.uncached_contacted_at }.from(Time.current).to(nil)
+
+ expected_cleared_attributes.each do |key, value|
+ expect(runner.public_send(key)).to eq(value)
+ expect(runner.read_attribute(key)).to eq(value)
+ end
+ end
+ end
+
describe '#destroy' do
let(:runner) { create(:ci_runner) }