Commit ed61c068 authored by Robert May's avatar Robert May Committed by Peter Leitzen

Make Elastic::ProcessBookkeepingService specs work on Redis 4

The service itself doesn't use ZPOPMIN and friends, but the spec did.
Changing this to the slightly less convenient ZRANGE ensures that the
specs will run on Redis 4, which is our minimum supported version.
parent 2ca202df
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
services: services:
- name: postgres:11.6 - name: postgres:11.6
command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"] command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
- name: redis:alpine - name: redis:4.0-alpine
variables: variables:
POSTGRES_HOST_AUTH_METHOD: trust POSTGRES_HOST_AUTH_METHOD: trust
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
services: services:
- name: postgres:12 - name: postgres:12
command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"] command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
- name: redis:alpine - name: redis:4.0-alpine
variables: variables:
POSTGRES_HOST_AUTH_METHOD: trust POSTGRES_HOST_AUTH_METHOD: trust
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
services: services:
- name: postgres:11.6 - name: postgres:11.6
command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"] command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
- name: redis:alpine - name: redis:4.0-alpine
- name: elasticsearch:6.4.2 - name: elasticsearch:6.4.2
variables: variables:
POSTGRES_HOST_AUTH_METHOD: trust POSTGRES_HOST_AUTH_METHOD: trust
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
services: services:
- name: postgres:12 - name: postgres:12
command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"] command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
- name: redis:alpine - name: redis:4.0-alpine
- name: elasticsearch:6.4.2 - name: elasticsearch:6.4.2
variables: variables:
POSTGRES_HOST_AUTH_METHOD: trust POSTGRES_HOST_AUTH_METHOD: trust
......
...@@ -585,7 +585,7 @@ that are scoped to a single [configuration parameter](../ci/yaml/README.md#confi ...@@ -585,7 +585,7 @@ that are scoped to a single [configuration parameter](../ci/yaml/README.md#confi
| `.static-analysis-cache` | Allows a job to use a default `cache` definition suitable for static analysis tasks. | | `.static-analysis-cache` | Allows a job to use a default `cache` definition suitable for static analysis tasks. |
| `.yarn-cache` | Allows a job to use a default `cache` definition suitable for frontend jobs that do a `yarn install`. | | `.yarn-cache` | Allows a job to use a default `cache` definition suitable for frontend jobs that do a `yarn install`. |
| `.assets-compile-cache` | Allows a job to use a default `cache` definition suitable for frontend jobs that compile assets. | | `.assets-compile-cache` | Allows a job to use a default `cache` definition suitable for frontend jobs that compile assets. |
| `.use-pg11` | Allows a job to use the `postgres:11.6` and `redis:alpine` services. | | `.use-pg11` | Allows a job to use the `postgres:11.6` and `redis:4.0-alpine` services. |
| `.use-pg11-ee` | Same as `.use-pg11` but also use the `docker.elastic.co/elasticsearch/elasticsearch:6.4.2` services. | | `.use-pg11-ee` | Same as `.use-pg11` but also use the `docker.elastic.co/elasticsearch/elasticsearch:6.4.2` services. |
| `.use-kaniko` | Allows a job to use the `kaniko` tool to build Docker images. | | `.use-kaniko` | Allows a job to use the `kaniko` tool to build Docker images. |
| `.as-if-foss` | Simulate the FOSS project by setting the `FOSS_ONLY='1'` environment variable. | | `.as-if-foss` | Simulate the FOSS project by setting the `FOSS_ONLY='1'` environment variable. |
......
...@@ -22,7 +22,7 @@ RSpec.describe Elastic::ProcessBookkeepingService, :clean_gitlab_redis_shared_st ...@@ -22,7 +22,7 @@ RSpec.describe Elastic::ProcessBookkeepingService, :clean_gitlab_redis_shared_st
it 'enqueues a record' do it 'enqueues a record' do
described_class.track!(issue) described_class.track!(issue)
spec, score = redis.zpopmin(zset) spec, score = redis.zrange(zset, 0, 0, with_scores: true).first
expect(spec).to eq(issue_spec) expect(spec).to eq(issue_spec)
expect(score).to eq(1.0) expect(score).to eq(1.0)
...@@ -33,8 +33,7 @@ RSpec.describe Elastic::ProcessBookkeepingService, :clean_gitlab_redis_shared_st ...@@ -33,8 +33,7 @@ RSpec.describe Elastic::ProcessBookkeepingService, :clean_gitlab_redis_shared_st
expect(described_class.queue_size).to eq(fake_refs.size) expect(described_class.queue_size).to eq(fake_refs.size)
spec1, score1 = redis.zpopmin(zset) (spec1, score1), (_, score2), _ = redis.zrange(zset, 0, -1, with_scores: true)
_, score2 = redis.zpopmin(zset)
expect(score1).to be < score2 expect(score1).to be < score2
expect(spec1).to eq(issue_spec) expect(spec1).to eq(issue_spec)
...@@ -61,7 +60,7 @@ RSpec.describe Elastic::ProcessBookkeepingService, :clean_gitlab_redis_shared_st ...@@ -61,7 +60,7 @@ RSpec.describe Elastic::ProcessBookkeepingService, :clean_gitlab_redis_shared_st
expect(described_class.queue_size).to eq(fake_refs.size) expect(described_class.queue_size).to eq(fake_refs.size)
expect { redis.zpopmin(zset) }.to change(described_class, :queue_size).by(-1) expect { redis.zadd(zset, 0, 'foo') }.to change(described_class, :queue_size).by(1)
end end
end end
...@@ -116,7 +115,8 @@ RSpec.describe Elastic::ProcessBookkeepingService, :clean_gitlab_redis_shared_st ...@@ -116,7 +115,8 @@ RSpec.describe Elastic::ProcessBookkeepingService, :clean_gitlab_redis_shared_st
expect { described_class.new.execute }.to change(described_class, :queue_size).by(-limit + 1) expect { described_class.new.execute }.to change(described_class, :queue_size).by(-limit + 1)
serialized, _ = redis.zpopmax(zset) serialized = redis.zrange(zset, -1, -1).first
expect(ref_class.deserialize(serialized)).to eq(failed) expect(ref_class.deserialize(serialized)).to eq(failed)
end end
......
...@@ -25,8 +25,8 @@ RSpec.describe Gitlab::Instrumentation::RedisInterceptor, :clean_gitlab_redis_sh ...@@ -25,8 +25,8 @@ RSpec.describe Gitlab::Instrumentation::RedisInterceptor, :clean_gitlab_redis_sh
# Exercise counting of a bulk reply # Exercise counting of a bulk reply
[[:set, 'foo', 'bar' * 100]] | [:get, 'foo'] | 3 + 3 | 3 * 100 [[:set, 'foo', 'bar' * 100]] | [:get, 'foo'] | 3 + 3 | 3 * 100
# Nested array response: ['123456-89', ['foo', 'bar']] # Nested array response: [['foo', 0], ['bar', 1]]
[[:xadd, 'mystream', '123456-89', 'foo', 'bar']] | [:xrange, 'mystream', '-', '+'] | 6 + 8 + 1 + 1 | 9 + 3 + 3 [[:zadd, 'myset', 0, 'foo'], [:zadd, 'myset', 1, 'bar']] | [:zrange, 'myset', 0, -1, 'withscores'] | 6 + 5 + 1 + 2 + 10 | 3 + 1 + 3 + 1
end end
with_them do with_them do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment