Sha256: 9c6262c0772a44e5c39ec42244b1f29491f0756c1f0ed6b580adca836740532c

Contents?: true

Size: 862 Bytes

Versions: 1

Compression:

Stored size: 862 Bytes

Contents

# frozen_string_literal: true
require_relative "../integration_helper"
class WithKillableQueries < Minitest::Test
  def test_with_queries_to_be_killed
    puts "testing with long running queries..."

    $mysql_master.connection.query("set GLOBAL READ_ONLY=0")
    $mysql_slave.connection.query("set GLOBAL READ_ONLY=1")

    thread = Thread.new {
      begin
        $mysql_master.connection.query("update flexmaster_test.users set name=sleep(600)")
        assert false, "Query did not get killed!  Bad."
        exit 1
      rescue StandardError => e
        puts e
      end
    }

    system "#{master_cut_script} 127.0.0.1:#{$mysql_master.port} 127.0.0.1:#{$mysql_slave.port} root -p ''"

    thread.join

    $mysql_master.reconnect!
    assert_ro($mysql_master.connection, 'master', true)
    assert_ro($mysql_slave.connection, 'slave', false)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ar_mysql_flexmaster-1.0.3 test/integration/with_queries_to_be_killed_test.rb