Commit c87eeb0b authored by Max Woolf's avatar Max Woolf
Browse files

Try redis service

parent 5defef2e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ ruby-versions:
    - name: redis:7-alpine
      alias: redis
  variables:
    LABKIT_TEST_REDIS_URL: redis://redis:6379/0
    LABKIT_TEST_REDIS_URL: redis://redis
  parallel:
    matrix:
      - RUBY_VERSION: ["3.4"]
@@ -47,7 +47,7 @@ legacy-ruby-versions:
    - name: redis:7-alpine
      alias: redis
  variables:
    LABKIT_TEST_REDIS_URL: redis://redis:6379/0
    LABKIT_TEST_REDIS_URL: redis://redis
  parallel:
    matrix:
      - RUBY_VERSION: ["3.3"]
+18 −20
Original line number Diff line number Diff line
@@ -2,11 +2,9 @@
<project version="4">
  <component name="ChangeListManager">
    <list default="true" id="eda9ef7d-e18e-4c0a-8966-bb3f714359b9" name="Changes" comment="">
      <change afterPath="$PROJECT_DIR$/docker-compose.yml" afterDir="false" />
      <change afterPath="$PROJECT_DIR$/spec/support/test_redis.rb" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/.gitlab-ci.yml" beforeDir="false" afterPath="$PROJECT_DIR$/.gitlab-ci.yml" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/spec/labkit/rate_limit_spec.rb" beforeDir="false" afterPath="$PROJECT_DIR$/spec/labkit/rate_limit_spec.rb" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/spec/support/test_redis.rb" beforeDir="false" afterPath="$PROJECT_DIR$/spec/support/test_redis.rb" afterDir="false" />
    </list>
    <option name="SHOW_DIALOG" value="false" />
    <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -34,23 +32,23 @@
    <option name="hideEmptyMiddlePackages" value="true" />
    <option name="showLibraryContents" value="true" />
  </component>
  <component name="PropertiesComponent"><![CDATA[{
  "keyToString": {
    "ModuleVcsDetector.initialDetectionPerformed": "true",
    "RSpec.Labkit::RateLimit::Rule.executor": "Run",
    "RunOnceActivity.ShowReadmeOnStart": "true",
    "RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
    "RunOnceActivity.git.unshallow": "true",
    "RunOnceActivity.typescript.service.memoryLimit.init": "true",
    "com.intellij.lang.ruby.rbs.tools.collection.workspace.sync.RbsCollectionUpdateProjectActivity#LAST_UPDATE_TIMESTAMP": "1777386083040",
    "git-widget-placeholder": "Rebasing testing/docker-compose-redis-autostart",
    "last_opened_file_path": "/Users/maxwoolf/labkit-ruby",
    "nodejs_package_manager_path": "npm",
    "ruby.structure.view.model.defaults.configured": "true",
    "settings.editor.selected.configurable": "preferences.pluginManager",
    "vue.rearranger.settings.migration": "true"
  <component name="PropertiesComponent">{
  &quot;keyToString&quot;: {
    &quot;ModuleVcsDetector.initialDetectionPerformed&quot;: &quot;true&quot;,
    &quot;RSpec.Labkit::RateLimit::Rule.executor&quot;: &quot;Run&quot;,
    &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
    &quot;RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252&quot;: &quot;true&quot;,
    &quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
    &quot;RunOnceActivity.typescript.service.memoryLimit.init&quot;: &quot;true&quot;,
    &quot;com.intellij.lang.ruby.rbs.tools.collection.workspace.sync.RbsCollectionUpdateProjectActivity#LAST_UPDATE_TIMESTAMP&quot;: &quot;1777386083040&quot;,
    &quot;git-widget-placeholder&quot;: &quot;testing/docker-compose-redis-autostart&quot;,
    &quot;last_opened_file_path&quot;: &quot;/Users/maxwoolf/labkit-ruby&quot;,
    &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
    &quot;ruby.structure.view.model.defaults.configured&quot;: &quot;true&quot;,
    &quot;settings.editor.selected.configurable&quot;: &quot;preferences.pluginManager&quot;,
    &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
  }
}]]></component>
}</component>
  <component name="RunManager">
    <configuration name="Labkit::RateLimit::Rule" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true" nameIsGenerated="true">
      <module name="labkit-ruby" />
+6 −6
Original line number Diff line number Diff line
@@ -5,8 +5,8 @@ require "open3"

# Shared Redis client for specs that hit a real Redis instance.
#
# On the first call to `reset!`, probes the configured URL and  when running
# locally  spawns a redis container via `docker compose up -d redis` if no
# On the first call to `reset!`, probes the configured URL and - when running
# locally - spawns a redis container via `docker compose up -d redis` if no
# instance is already reachable. Autostart is disabled in CI and when
# LABKIT_TEST_REDIS_URL is explicitly set (assume the caller knows what they're
# pointing at).
@@ -49,7 +49,7 @@ module TestRedis
    cmd = compose_command
    raise_autostart_failed!("neither `docker compose` nor `docker-compose` found") if cmd.nil?

    warn "TestRedis: starting Redis via `#{cmd.join(" ")} up -d redis`..."
    warn "TestRedis: starting Redis via `#{cmd.join(' ')} up -d redis`..."
    output, status = Open3.capture2e(*cmd, "up", "-d", "redis", chdir: COMPOSE_DIR)
    raise_autostart_failed!(output) unless status.success?

@@ -79,7 +79,7 @@ module TestRedis
    cmd = compose_command
    return unless cmd

    warn "TestRedis: stopping Redis via `#{cmd.join(" ")} down`..."
    warn "TestRedis: stopping Redis via `#{cmd.join(' ')} down`..."
    Open3.capture2e(*cmd, "down", chdir: COMPOSE_DIR)
  end

@@ -92,9 +92,9 @@ module TestRedis
  end

  def self.wait_until_reachable!
    deadline = Time.now + AUTOSTART_TIMEOUT
    deadline = Time.zone.now + AUTOSTART_TIMEOUT
    until reachable?
      raise "TestRedis: Redis at #{URL} not reachable within #{AUTOSTART_TIMEOUT}s of `docker compose up`" if Time.now > deadline
      raise "TestRedis: Redis at #{URL} not reachable within #{AUTOSTART_TIMEOUT}s of `docker compose up`" if Time.zone.now > deadline

      sleep 0.2
    end