Skip to content
Snippets Groups Projects
Commit 5a887531 authored by Joe Libipl's avatar Joe Libipl
Browse files

Scenario: Allow connection if server in Running mode

parent 1b55e025
No related branches found
No related tags found
1 merge request!3Connect.feature implementation
@kill_server_after
Feature: Connection to server Feature: Connection to server
@kill_server_after @WIP
Scenario: Disallow connection if server in Starting mode Scenario: Disallow connection if server in Starting mode
Given I use the production database as-is Given I use the "production" database as-is
When the server executable is started When the server executable is started
And I do not allow time for the server to complete startup And I do not allow time for the server to complete startup
Then I can not connect to the server via telnet Then I can not connect to the server via telnet
@WIP @WIP
Scenario: Allow connection if server in Running mode Scenario: Allow connection if server in Running mode
Given the server is running Given I use the "minimal" database as-is
When the server executable is started
And I allow time for the server to complete startup
Then I can connect to the server via telnet Then I can connect to the server via telnet
@WIP @WIP
Scenario: Allow connection if server in Locked mode Scenario: Allow connection if server in Locked mode
Given the server is running Given I use the "minimal" database as-is
When the server executable is started
And I allow time for the server to complete startup
When I log on using a developer account When I log on using a developer account
And I enter the chat And I enter the chat
And I issue the "/lockserver" command And I issue the "/lockserver" command
......
require 'tiny_tds'
require 'Nokogiri'
def load_db_if_absent(server_database)
connect_hash = {username: ENV['DB_USERNAME'], password: ENV['DB_PASSWORD'],
dataserver: ENV['DB_DATASERVER'], database: server_database}
puts "Connecting to #{ENV['DB_DATASERVER']} database #{server_database}..."
begin
client = TinyTds::Client.new(connect_hash)
rescue TinyTds::Error => e
puts e.inspect
# Reset the database
result = %x[sqlcmd -S "#{ENV['DB_DATASERVER']}" -U "#{ENV['DB_USERNAME']}" \
-P "#{ENV['DB_PASSWORD']}" -i EntireDB-#{server_database}.sql \
-o EntireDB-#{server_database}.out -v MYDATABASE = "#{server_database}"]
puts "Result of sqlcmd: #{result}"
end
end
def set_db_in_config(server_database)
filename = "test_env/test001/DragSpinExp.exe.config"
doc = File.open(filename) { |f| Nokogiri::XML(f) }
sql_connection = doc.at_xpath("//appSettings//add[@key='SQL_CONNECTION']")
sql_connection['value'] = "User ID='#{ENV['DB_USERNAME']}';Password='#{ENV['DB_PASSWORD']}';" +
"Initial Catalog='#{server_database}';Data Source='#{ENV['DB_DATASERVER']}';Connect Timeout=15"
File.write(filename, doc.to_xml)
end
def ensure_developer_account_exists(acct_name, acct_password)
raise "pending"
end
\ No newline at end of file
require 'Nokogiri'
def start_server() def start_server()
# Start up the server - we don't wait for it to come up in this method # Start up the server - we don't wait for it to come up in this method
...@@ -40,28 +39,3 @@ def log_contains_immediate(message) ...@@ -40,28 +39,3 @@ def log_contains_immediate(message)
rows_affected = result.do rows_affected = result.do
rows_affected > 0 rows_affected > 0
end end
def load_db_if_absent(server_database)
connect_hash = {username: ENV['DB_USERNAME'], password: ENV['DB_PASSWORD'],
dataserver: ENV['DB_DATASERVER'], database: server_database}
puts "Connecting to #{ENV['DB_DATASERVER']} database #{server_database}..."
begin
client = TinyTds::Client.new(connect_hash)
rescue TinyTds::Error => e
puts e.inspect
# Reset the database
result = %x[sqlcmd -S "#{ENV['DB_DATASERVER']}" -U "#{ENV['DB_USERNAME']}" \
-P "#{ENV['DB_PASSWORD']}" -i EntireDB-#{server_database}.sql \
-o EntireDB-#{server_database}.out -v MYDATABASE = "#{server_database}"]
puts "Result of sqlcmd: #{result}"
end
end
def set_db_in_config(server_database)
filename = "test_env/test02/DragSpinExp.exe.config"
doc = File.open(filename) { |f| Nokogiri::XML(f) }
sql_connection = doc.at_xpath("//appSettings//add[@key='SQL_CONNECTION']")
sql_connection['value'] = "User ID='#{ENV['DB_USERNAME']}';Password='#{ENV['DB_PASSWORD']}';" +
"Initial Catalog='#{server_database}';Data Source='#{ENV['DB_DATASERVER']}';Connect Timeout=15"
File.write(filename, doc.to_xml)
end
...@@ -135,6 +135,19 @@ When(/^I create an account to verify that race "([^"]*)" has the following stat ...@@ -135,6 +135,19 @@ When(/^I create an account to verify that race "([^"]*)" has the following stat
end end
Then(/^I can connect to the server via telnet$/) do
expect(create_telnet_connection()).to be_truthy
end
Then(/^I can not connect to the server via telnet$/) do Then(/^I can not connect to the server via telnet$/) do
expect(create_telnet_connection()).to be_falsy expect(create_telnet_connection()).to be_falsy
end end
When(/^I log on using a developer account$/) do
@user = { acct_name: "dev01", acct_password: "devpass01" }
ensure_developer_account_exists(@user[:acct_name], @user[:acct_password])
@connection = create_telnet_connection
telnet_command(@connection, "", /Login\: /, {"Timeout" => 120})
telnet_commands(@connection, [[@user[:acct_name], /Password\: /],
[@user[:acct_password], /Command\: /]])
end
require 'rspec' require 'rspec'
Given(/^I use the production database as-is$/) do Given(/^I use the "([^"]*)" database as\-is$/) do |database_name|
# Kill the server if it's already running # Kill the server if it's already running
result = %x[taskkill /F /T /IM DragSpinExp.exe"] result = %x[taskkill /F /T /IM DragSpinExp.exe"]
puts "Result of taskkill: #{result}" puts "Result of taskkill: #{result}"
@server_database = "production" @server_database = database_name
load_db_if_absent(@server_database) load_db_if_absent(@server_database)
set_db_in_config(@server_database) set_db_in_config(@server_database)
end end
...@@ -13,7 +13,11 @@ Given(/^the server executable is started$/) do ...@@ -13,7 +13,11 @@ Given(/^the server executable is started$/) do
expect(start_server()).to be_truthy expect(start_server()).to be_truthy
end end
And(/^I allow time for the server to complete startup$/) do
expect(log_contains('Starting main game loop.')).to be_truthy
end
And(/^I do not allow time for the server to complete startup$/) do And(/^I do not allow time for the server to complete startup$/) do
expect(log_contains_immediate('Starting main game loop.')).to be_falsy expect(log_contains_immediate('Starting main game loop.')).to be_falsy
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment