首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >循环CI 2.0 Rails Redis Resque - Rspec Redis Server未找到错误

循环CI 2.0 Rails Redis Resque - Rspec Redis Server未找到错误
EN

Stack Overflow用户
提问于 2017-12-15 06:00:24
回答 2查看 790关注 0票数 3

当我们的测试套件运行时,我们会得到以下有关redis-server的问题。不管我们尝试了什么,似乎没有什么能克服这个错误。我们已经通过dockerize验证了容器是通过等待来激活的,如下所示,但是这个错误仍然发生。

任何想法都将不胜感激!

Resque初始化器

代码语言:javascript
复制
require 'resque'
require 'redis'
require 'yaml'

# Resque Plugins
require 'resque/plugins/retry'
require 'resque-retry'
require 'resque-retry/server'
require 'resque-lock-timeout'
require 'resque-scheduler'
require 'resque/failure/multiple'
require 'resque/failure/redis'
require 'resque-job-stats/server'
require 'resque/rollbar'

if AppUnsecure.settings[:active_db_services].include?('redis')
  uri = URI.parse(ENV["REDIS_URL"])
  config = {
    host: uri.host,
    port: uri.port,
    password: uri.password
  }
  Resque::Failure::Multiple.classes = [ Resque::Failure::Redis, Resque::Failure::Rollbar ]
  Resque::Failure.backend = Resque::Failure::Multiple
  Resque.redis = Redis.new(config)
elsif AppUnsecure.settings[:active_db_services].include?('redis-continous-integration')
  Resque::Failure::MultipleWithRetrySuppression.classes = [Resque::Failure::Redis]
  Resque.redis = Redis.new(host: 'redis://localhost', port: 6391)
else
  Resque::Failure::MultipleWithRetrySuppression.classes = [Resque::Failure::Redis]
  Resque.redis = Redis.new
end

Resque.redis.namespace = 'resque:GathrlySmartforms'

# Ignores Resque when processing jobs if activated!
Resque.inline = true if AppUnsecure.settings[:process_redis_inline]

# Setup Scheduler
# https://github.com/resque/resque-scheduler/issues/118
# https://github.com/resque/resque-scheduler/issues/581
Resque::Scheduler.configure do |c|
  c.quiet = false
  c.verbose = false
  c.logfile = File.join(Rails.root, 'log', "#{Rails.env}_resque_scheduler.log")
  c.logformat = 'text'
end
Resque::Scheduler.dynamic = true

schedules = {}
global = YAML.load_file("#{Rails.root}/config/resque_schedule.yml")
schedules.merge!(global) if global
# http://stackoverflow.com/questions/12158226/how-do-i-skip-loading-of-rails-initializers-when-running-a-rake-task
unless defined?(is_running_migration?) && is_running_migration?
  Resque.schedule = schedules if schedules.present?
end

Resque::Server.class_eval do
  use Rack::Auth::Basic do |username, password|
    [username, password] == [Rails.application.secrets.my_resque_username, Rails.application.secrets.my_resque_password]
  end
end

圆组态

代码语言:javascript
复制
version: 2
jobs:
  build:
    working_directory: ~/DIR_NAME
    docker:
      - image: circleci/ruby:2.4.1-node
        environment:
          RAILS_ENV: continous_integration
          PGHOST: 127.0.0.1
          PGUSER: rails_test_user

      - image: circleci/postgres:9.6.3-alpine
        environment:
          POSTGRES_USER: rails_test_user
          POSTGRES_PASSWORD: ""
          POSTGRES_DB: continous_integration

      - image: redis:4.0.6

    steps:
      - checkout

      - run:
          name: Dockerize v0.6.0
          command: |
            wget https://github.com/jwilder/dockerize/releases/download/v0.6.0/dockerize-linux-amd64-v0.6.0.tar.gz
            sudo rm -rf /usr/local/bin/dockerize
            sudo tar -C /usr/local/bin -xzvf dockerize-linux-amd64-v0.6.0.tar.gz
            rm dockerize-linux-amd64-v0.6.0.tar.gz

      - run:
          name: Wait for PG
          command: dockerize -wait tcp://localhost:5432 -timeout 2m

      - run:
          name: Wait for Redis
          command: |
            dockerize -wait tcp://localhost:6379 -timeout 2m

      - restore_cache:
          keys:
            - DIR_NAME-{{ checksum "Gemfile.lock" }}
            - DIR_NAME-

      - save_cache:
          key: rails-demo-{{ checksum "Gemfile.lock" }}
          paths:
            - vendor/bundle

      - run:
          name: Setup Bundler and Gems
          command: |
            gem install bundler
            gem update bundler
            gem install brakeman
            gem install rubocop
            gem install rubocop-rspec
            gem install scss_lint
            gem install eslint-rails
            gem install execjs
            bundle config without development:test
            bundle check --path=vendor/bundle || bundle install --without development test --path=vendor/bundle --jobs 4 --retry 3

      - run:
          name: Install Phantom Js
          command: |
            sudo curl --output /tmp/phantomjs https://s3.amazonaws.com/circle-downloads/phantomjs-2.1.1
            sudo chmod ugo+x /tmp/phantomjs
            sudo ln -sf /tmp/phantomjs /usr/local/bin/phantomjs

      - run:
          name: Install Postgres Tools
          command: |
            sudo apt-get update
            sudo apt-get install postgresql-client

      - run:
          name: Install Redis Tools
          command: |
            sudo apt-get install redis-tools ; while ! redis-cli ping 2>/dev/null ; do sleep 1 ; done

      - run:
          name: Build Rails Database Yaml
          command: |
            cp config/database_example.yml config/database.yml

      - run:
          name: Setup Rails Database
          command: |
            bundle exec rake db:drop
            bundle exec rake db:setup

      - run:
          name: Run Rspec
          timeout: 60
          command: |
            RAILS_ENV=continous_integration bundle exec rspec --format RspecJunitFormatter -o /tmp/test-results/rspec.xml

      - run:
          name: Run Brakeman
          command: |
            brakeman -z

      - run:
          name: Run Rubocop
          command: |
            bundle exec rubocop --format fuubar --require rubocop-rspec --config .rubocop.yml

      - run:
          name: Run the SCSS Linter
          command: |
            bundle exec scss-lint --config=config/scsslint.yml

      - run:
          name: Run the Eslint Linter for JS
          command: |
            bundle exec rake eslint:run_all


      - store_test_results:
          path: /tmp/test-results

更新

在不同的测试运行中,它可能偶尔会出现work...however,错误仍然是相同的,这一定是原因.

EN

回答 2

Stack Overflow用户

发布于 2017-12-19 19:56:57

我不知道Postgres和redis的关系到底意味着什么。postgres的用户喜欢通过redis-cli?Postgres不是直接连接的吧?(外文数据包装--读一下这篇文章.我甚至不知道你能做到,哇)。算了,这是个切线.

一些小小的洞察力,我不能很容易地测试整个事情.PID文件不是那样的,可能是因为它就快死了。kill: invalid argument Q可能来自于做kill -QUIT的东西。这可能是瑞迪斯的剧本之类的。我敢打赌这个过程已经死了,而杀死只是错误的错误。我认为杀戮真的想要PID存在。虽然我刚刚测试了这个,但这不是它的工作方式。也许圆环安装了非GNU核心功能什么的?

我认为POSTGRES_USER不应该出现在红色图像中。参见这个示例:https://discuss.circleci.com/t/circleci-bug-for-builds-with-redis/13124看起来好像随着2.0而发生了变化。

如果gist已经更新为一个全新的配置,那么也要更新错误消息和问题,除非是相同的。

票数 0
EN

Stack Overflow用户

发布于 2017-12-20 01:37:19

根据我们从这里可以看出的,您的配置似乎是在引用测试中不存在的redis进程。

而且你没有经过测试就捆绑在一起。不知道为什么。

你能发布你的Redis配置文件吗?<-仍然需要这个。

您需要将REDIS_URL配置为坞映像。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47826623

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档