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:
authorStan Hu <stanhu@gmail.com>2018-08-06 19:16:09 +0300
committerStan Hu <stanhu@gmail.com>2018-08-06 19:16:09 +0300
commit964d9f431f64754f171c5c523309417447c2ee71 (patch)
treed9d06c1ba2397ce9717a8ce0b01deb96d2bcce6b /spec/models
parentb4415c01740430cef58baf9bb0cbda2fb1055edb (diff)
parent1e5192cc8c2ebd3e0d740f3a044b7f5e4c086730 (diff)
Merge branch 'background-migrations-system-load' into 'master'
Respond to DB health in background migrations See merge request gitlab-org/gitlab-ce!20720
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/postgresql/replication_slot_spec.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/models/postgresql/replication_slot_spec.rb b/spec/models/postgresql/replication_slot_spec.rb
new file mode 100644
index 00000000000..919a7526803
--- /dev/null
+++ b/spec/models/postgresql/replication_slot_spec.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Postgresql::ReplicationSlot, :postgresql do
+ describe '.lag_too_great?' do
+ it 'returns true when replication lag is too great' do
+ expect(described_class)
+ .to receive(:pluck)
+ .and_return([125.megabytes])
+
+ expect(described_class.lag_too_great?).to eq(true)
+ end
+
+ it 'returns false when more than one replicas is up to date enough' do
+ expect(described_class)
+ .to receive(:pluck)
+ .and_return([125.megabytes, 0.megabytes, 0.megabytes])
+
+ expect(described_class.lag_too_great?).to eq(false)
+ end
+
+ it 'returns false when replication lag is not too great' do
+ expect(described_class)
+ .to receive(:pluck)
+ .and_return([0.megabytes])
+
+ expect(described_class.lag_too_great?).to eq(false)
+ end
+ end
+end