Skip to content

Commit

Permalink
fix toxiproxy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bvogelzang committed Jun 24, 2022
1 parent a7abba6 commit b83445c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 32 deletions.
38 changes: 24 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ jobs:
# Primary container image where all commands run
- image: cimg/ruby:<< parameters.ruby_version >>
environment:
TESTOPTS: '-v'
TINYTDS_UNIT_DATASERVER: sqlserver
TINYTDS_UNIT_HOST: sqlserver
SA_PASSWORD: super01S3cUr3
TOXIPROXY_HOST: toxiproxy
TOXIPROXY_HOST: localhost

# Service container image
- image: mcr.microsoft.com/mssql/server:2019-latest
Expand All @@ -30,14 +28,26 @@ jobs:
# tests based on toxiproxy are broken, last working on
# v2.1.4 (2019). This is pinned to the closest older
# version until those tests can be fixed
- image: ghcr.io/shopify/toxiproxy:2.1.5
name: toxiproxy
# - image: ghcr.io/shopify/toxiproxy:2.1.5
# name: toxiproxy

working_directory: ~/repo

steps:
- checkout

- run:
name: install toxiproxy
command: |
wget -O toxiproxy-2.1.4.deb https://github.com/Shopify/toxiproxy/releases/download/v2.1.4/toxiproxy_2.1.4_amd64.deb
sudo dpkg -i toxiproxy-2.1.4.deb
- run:
name: start toxiproxy
background: true
command: |
sudo toxiproxy-server -port 8474 -host localhost
- run:
name: install sql prereqs
command: |
Expand Down Expand Up @@ -200,14 +210,14 @@ workflows:
matrix:
parameters:
ruby_version:
- '2.5'
- '2.6'
# - '2.5'
# - '2.6'
- '2.7'

- test_windows:
matrix:
parameters:
ruby_version:
- '2.5'
- '2.6'
- '2.7'
# - test_windows:
# matrix:
# parameters:
# ruby_version:
# - '2.5'
# - '2.6'
# - '2.7'
25 changes: 12 additions & 13 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@ services:
networks:
- main-network

cimgruby:
image: cimg/ruby:2.7.0
environment:
TESTOPTS: "-v"
TINYTDS_UNIT_DATASERVER: sqlserver
TINYTDS_UNIT_HOST: sqlserver
SA_PASSWORD: super01S3cUr3
TOXIPROXY_HOST: toxiproxy.tiny_tds_main-network
command: tail -F anything
volumes:
- .:/home/circleci/repo
networks:
- main-network
# cimgruby:
# image: cimg/ruby:2.7.0
# environment:
# TESTOPTS: "-v"
# TINYTDS_UNIT_HOST: sqlserver
# SA_PASSWORD: super01S3cUr3
# TOXIPROXY_HOST: toxiproxy
# command: tail -F anything
# volumes:
# - .:/home/circleci/repo
# networks:
# - main-network
3 changes: 0 additions & 3 deletions test/client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ class ClientTest < TinyTds::TestCase
end

it 'raises TinyTds exception with tcp socket network failure' do
skip if ENV['CI'] # disabled in CI until toxiproxy tests are fixed
begin
client = new_connection timeout: 2, port: 1234, host: ENV['TOXIPROXY_HOST']
assert_client_works(client)
Expand All @@ -155,7 +154,6 @@ class ClientTest < TinyTds::TestCase
end

it 'raises TinyTds exception with dead connection network failure' do
skip if ENV['CI'] # disabled in CI until toxiproxy tests are fixed
begin
client = new_connection timeout: 2, port: 1234, host: ENV['TOXIPROXY_HOST']
assert_client_works(client)
Expand All @@ -177,7 +175,6 @@ class ClientTest < TinyTds::TestCase
end

it 'raises TinyTds exception with login timeout' do
skip if ENV['CI'] # disabled in CI until toxiproxy tests are fixed
begin
action = lambda do
Toxiproxy[:sqlserver_test].toxic(:timeout, timeout: 0).apply do
Expand Down
5 changes: 3 additions & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@ def rollback_transaction(client)
end

def init_toxiproxy
return if ENV['CI'] # disabled in CI until toxiproxy tests are fixed

# In order for toxiproxy to work for local docker instances of mssql, the containers must be on the same network
# and the host used below must match the mssql container name so toxiproxy knows where to proxy to.
# localhost from the perspective of toxiproxy's container is its own container an *not* the mssql container it needs to proxy to.
Expand All @@ -262,6 +260,9 @@ def init_toxiproxy
env_host = ENV['TINYTDS_UNIT_HOST_TEST'] || ENV['TINYTDS_UNIT_HOST'] || 'localhost'
host = ['localhost', '127.0.0.1', '0.0.0.0'].include?(env_host) ? 'sqlserver' : env_host
port = ENV['TINYTDS_UNIT_PORT'] || 1433
puts '-------------------------'
puts "Toxiproxy upstream: #{host}:#{port}"
puts '-------------------------'
Toxiproxy.populate([
{
name: "sqlserver_test",
Expand Down

0 comments on commit b83445c

Please sign in to comment.