Test to verify connection to production database? - database

My team consistently deploys a new API server that's supposed to connect to a database, but only some of the times is that connection successful. We're trying to design a test that can catch that beforehand. However, I've never run a test that is essentially using prod credentials before actually going to prod, only testing in a lower environment. What exactly is this kind of test called?

Related

Port number change in sql server? Effect the application?

When we change the port number of SQL server, is any changes we have to done in the web application, to connect the database.
Probably not. There is a service that gets installed along with the database engine called SQL Browser that serves as a means to translate the instance name to a port. So, assuming that you didn't hard code the port number into the connection string, you should be good to go. Of course, you should test it first to make sure.

Connecting to Google Cloud SQL from Eclipse Not Using App Engine

We are trying to connect to Google Cloud SQL from Eclipse using the Database Development perspective. To do so I'm trying to add a new Database Connection, which I was able to do successfully for a local MySQL instance running on my machine.
The motivation for doing this is that we currently run our JUnit tests against the local instance. However, we are switching to Hibernate and want to make sure that all of our configuration files work with Cloud SQL. As a general guide I've been using:
https://developers.google.com/appengine/articles/using_hibernate
We're diverging slightly in that we're using hibernate.cfg.xml instead of persistence.xml, but I don't think this will actually have a bearing on the current issue of simply connecting to the database. From another answer as well as some Google documentation I'm aware that I can't use the com.google.appengine.api.rdbms.AppEngineDriver, because that needs to be run from an AppEngine instance. Instead I'm trying to follow the directions here:
https://developers.google.com/cloud-sql/docs/external
and am using com.mysql.jdbc.Driver.
I have assigned my Cloud SQL instance an ip address and have added my current ip address to the whitelist, as described here:
https://developers.google.com/cloud-sql/docs/access-control#appaccess
My driver is the Connector/J driver I've been using successfully with the local instance, and the url I'm using is:
jdbc:google:rdbms://my-app:my-cloud-sql-instance/myDatabase
which I got based on:
https://developers.google.com/appengine/articles/using_hibernate
After adding the connection and setting the information I click Test Connection, which worked successfully on my local instance. However, this throws the following error:
java.lang.Exception: Connection failed with unspecified error.
at org.eclipse.datatools.connectivity.DriverConnectionBase.internalCreateConnection(DriverConnectionBase.java:110)
at org.eclipse.datatools.connectivity.DriverConnectionBase.open(DriverConnectionBase.java:54)
at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.open(JDBCConnection.java:73)
at org.eclipse.datatools.enablement.internal.mysql.connection.JDBCMySQLConnectionFactory.createConnection(JDBCMySQLConnectionFactory.java:28)
at org.eclipse.datatools.connectivity.internal.ConnectionFactoryProvider.createConnection(ConnectionFactoryProvider.java:83)
at org.eclipse.datatools.connectivity.internal.ConnectionProfile.createConnection(ConnectionProfile.java:359)
at org.eclipse.datatools.connectivity.ui.PingJob.createTestConnection(PingJob.java:76)
at org.eclipse.datatools.connectivity.ui.PingJob.run(PingJob.java:59)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Obviously this isn't very helpful.
I've tried fiddling with the url, tried a number of users (none of which require passwords, so I'm leaving the password fields blank), and different versions of the driver for different versions of MySQL. Nothing has worked.
There are perhaps more deep-seated issues with doing it this way, such as how I will easily switch between test and deployment versions of my hibernate.cfg.xml, and I don't have good answers. I was just planning on editing them by hand back to the AppEngineDriver, which means I might run into further configuration issues at that point even if the JUnit tests are passing. Nevertheless, I think getting a connection set up to Cloud SQL that will allow JUnit testing will be a step in the right direction. I'd appreciate any input!
You should use jdbc:mysql://<cloudsql-instance-ip>:3306/<database-name> to connect from an external network. The connection string you are using is to connect from Google App Engine.

Storing Load test results in Database using Controller and Agents

I have a load test solution with one load test and one web test. I have created a Agent where the load test solution lies and a Controller which has a SQL server set up. So i am using the Controller to store the Load test results in database. While running the test case i am facing the below issue -
The load test results database could not be opened. Check that the load test results database specified by the connect string for your test controller (or local machine) specifies a database that contains the load test schema and that is currently available. For more information, see the Visual Studio help topic 'About the Load Test Results Store'. The connection error was: An error occurred while attempting to create the load test results repository schema: To create the database 'LoadTest2010' your user account must have the either the SQL Server 'sysadmin' role or both the 'serveradmin' and 'dbcreator' roles
Note - The same solution runs fine for two of my colleagues. So i think it is something to do with permissions. I have matched the permissions which i and my colleague share on controller, agent, database, they are exactly the same.
I am blocked from two days, it would be great if anyone can spend some time and help me.
Thanks in advance.
Load Test Repository is configured at Controller Level. So, if someone else can do Load Tests, configuration is ok.
Maybe, you are not using a remote Test Controller in your Test (Local Testing only).
You should create a remote test settings in VS and specify the remote test controller.

VSTS LoadTest, connection string and TFS2010

We have a couple of loadtests running on a build server and I've been having problems with persisting the results from the test in a resultstore database. It works fine when running locally and up and until a week ago, the test result got persisted when running on the build server (TFS2010). Note I have no test controller or test agents. Only a build controller and build agents. I've setup the connection string for the controller 'Local - No controller' and it is seemed to be saved correctly (can see the connection string on the build server too). But when running via the build server, the result is not saved in the database. Locally works fine. So what am I doing wrong here and where is the connection string saved? My guess is that it follows the test controller and hence I do not explicit have one, my guess is that it uses a default local test controller. Any thoughts on where the chain breaks?
A fixed the problem, by opening visual studio on each of the build servers and configuring the connection string - *sigh

Manage Test Data: Can you enlist all db connections into a single transaction?

We are currently using Watin to do UI testing on our web application. In effect we are doing integration testing from top to bottom since we are using a test database and not mocking.
In order to make sure the test database is in an expected state we have previously been using SQL Server's snapshot feature to rollback the database at the beginning of each test. This is fairly slow and also causes an error immediately after the snapshot is restored.
Since each the tests are invoking the UI and potentially using multiple db connections, we have no way of start a transaction on each connection.
I was wondering if it is possible to somehow attach all database connections to a single transaction and roll them back at a later point? This would probably have to happen at the db level itself.
If anyone has any other suggestions on how to reset our test data for each UI test I'd love to hear your ideas.
If you fire up, in process, an instance of the Visual Studio development web server, and then run your WatiN test, then you can wrap the test in a single block like so:
using (new TransactionScope())
{
var server = new Server(PORT_NUMBER, VIRTUAL_PATH, PHYSICAL_PATH);
server.Start();
try
{
using (var ie = new IE())
{
// TODO: perform necessary testing using ie object
}
}
finally
{
server.Stop();
}
}
and all your database connections will in theory enlist in a single distributed transaction and their changes will all be rolled back when the TransactionScope is disposed.
To run the dev web server in process, you will need to extract WebDev.WebHost.dll from the GAC and reference it in your project - this is the source of the Server class in the snippet above. Please let me know if you need more detailed instructions.
You'll need to make sure MSDTC is running, and if there are firewalls between you and the databases then depending on the port settings you may struggle. One added bonus of firing up the server in process is that WatiN tests can now contribute to measurements of code coverage.

Resources