0

The selected file was generated by mysqldump and cannot be restored by this application.

Posted by admin on Jul 20, 2010 in SQL, code, tips
MySQL Logo

MYSQL

How to fix the-selected-file-was-generated-by-mysqldump-and-cannot-be-restored-by-this-application error.

This post is here more of a reminder to myself. However I’m hoping that others will find it useful also.

I was testing out a piece of code which needed a new MYSQL InnoDB restored.

I had a slight issue ad when I attempted to restore the DB via the MySQL Administrator tool I got the following error message.

“The selected file was generated by mysqldump and cannot be restored by this application.”

This error is given usually when the Backup was taken via a batch job (or just a user who is using the command line).

Becuase of this the only way to restore the DB is again via the command line.

So carry out the following steps.

Firstly find the MySQL.exe file, (this will usually be stored in the installation bin folder)

then run the following using the command line.

C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql.exe -uusername -ppassword < “C:\DB Backups\nameofbackupfile.sql”

The -uusername should be something like -uroot

and the -ppassword should be something like -psecret

Hope it helps.

Martin H


 
0

Verifying that the Text from a DataSource Exists in a WebTest Response VSTS

Posted by admin on Jul 5, 2010 in Testing, VSTS, code, productivity, tips, tools
Visual Studio VSTS Logo

Visual Studio Webtest Logo

I use Visual Studio Team Testers Edition everyday at work and one of the things that seemed really strange to me was that Microsoft had missed so many tricks when they decided to release it.

Maybe they just decided to build in reasons for users to upgrade,  knowing that there will always be another version of VSTS around the corner.

One of the things which is sorely missing is the ability to verify HTML source code against a datasource. Sure you can load a data source and then verify what is returned on the page when that row of the data-source is called however there is no functionality to check that the value of the row that you have submitted is returned somewhere in the HTML source (known as the response in VSTS).

So as per usual when you need something doing then, do it yourself, and hence I wrote a small piece of code that looks at the source code and then checks the value of the datasource row to make sure that the item you are submitting is returned in the HTML response.

All the data is dynamic from your source so you can’t just hard code validation rules, as there could be thousands of rows.

For an example take a Google search test. Imagine I want to check that my datasource of 10,000 records is retuned on every response.

So if I search for “System Testers” as a parameter value

“Parameter Name = q” and

“Parameter Value = Google DataSource.Directory_03062010#csv.SearchParams”

In the above QueryString Parameter you can see

the Datasource is called  “Google DataSource”

the Actual FileName is “Directory_03062010″ (and it’s a CSV file)

the Column name is SearchParams

I’ve commented my code to make it easier to understand however if you need any help just ask.

Code Below.

‘———————————————————————
‘Author  = Martin Hall
‘Purpose = To load text from a DataSource and then to compare that text
‘           against the source code on the page your testing.
‘Date = 07th June 2010
‘———————————————————————

Imports System
Imports System.ComponentModel
Imports Microsoft.VisualStudio.TestTools.WebTesting

Namespace RegressionSampleWebTestRules
Public Class RegressionAllHeadingLocationsRule
Inherits Microsoft.VisualStudio.TestTools.WebTesting.ValidationRule

‘———————————————————————
‘ Specify a name for use in the user interface.
‘ The user sees this name in the Add Validation dialog box.
‘———————————————————————
Public Overrides ReadOnly Property RuleName() As String
Get
Return “RegressionAllHeadingLocationsRule”
End Get
End Property
‘———————————————————————
‘ Specify a description for use in the user interface.
‘ The user sees this description in the Add Validation dialog box.
‘———————————————————————
Public Overrides ReadOnly Property RuleDescription() As String
Get
Return “This should Compare text from a datasource parameter in a CSV file against the page sourcecode.”
End Get
End Property

‘ The name of the expected string
Private ExpectedStringValue As String

Public Property ExpectedString() As String
Get
Return ExpectedStringValue
End Get
Set(ByVal value As String)
ExpectedStringValue = value
End Set
End Property

‘———————————————————————
‘ Validate is called with the test case Context and the request context.
‘ These allow the rule to examine both the request and the response.
‘———————————————————————
Public Overrides Sub Validate(ByVal sender As Object, ByVal e As ValidationEventArgs)
Try

Dim result2 As String
‘———————————————————————
‘we only want request2 to match the source code on the returned web page.
‘the SourceCode could be different on the other pages.
‘———————————————————————
result2 = (e.WebTest.Context(“Google DataSource.Directory_03062010#csv.SearchParams”).ToString())

‘———————————————————————
‘This should check the response for text
‘The text in question is the ParamValue we are supplying as new fake
‘parameter name and value
‘———————————————————————

If e.Response.BodyString.ToLower.Contains(result2) = False Then
e.IsValid = False
e.Message = (“fail – - “) & result2
End If

If e.Response.BodyString.ToLower.Contains(result2) Then
e.IsValid = True
e.Message = (“pass – - “) & result2
End If

Catch ex As Exception
End Try
End Sub

End Class

End Namespace

/End Code.

The above script is in Visual Basic.Net and it should work for you and if you need any help in how to install and run it then either send an email or reply in the comments.

One last thing to mention is that the values from the data source are loaded in a fake Parameter Name (Just make one up) which will be ignored by the Website however it will show as a Context Name in the Visual Studio Web Test, so we are really just comparing two Context Names

Good Luck

Martin H

 
0

MySQL Search for text inside all Stored Procedures

Posted by admin on May 10, 2010 in SQL, code, productivity, tips
MySQL Logo

MySQL Logo

This little piece of MySQL Code I wrote a month or so ago.

I had a defect and was trying to provide some decent feedback to the developer  on Test-Track (our defect logging system).

I knew that the defect was in a stored procedure and to attempt to run profiler in Mysql can be a bit of a pain so I figured that I’d work out a way to search in every Stroed Proc for the bit of code causing the error.

I knew that the error was caused by the peice of code calling “Videos”.

I looked around on the net but I couldn’t find anything that suited.  I did find one other piece of sample code but I found that that only search inside the first 256 chars of the Stored Procedure and I needed something that would search inside the whole of the procedure no matter how long it was.

Once again it’s a nice and simple piece of code.

– Author : Martin Hall
– Date 09th April 2010
– Search for Text inside a MySQL Stored Proc
– MYSQL Version
– See the Like Query for an example of Use.

SELECT * FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE “%video%”
Order by Routine_Name;

Hope you find it useful.

any issues then let me know.

Martin H

 
0

MYSQL Search for Table or Column names in a Database

Posted by admin on Apr 12, 2010 in SQL, code, productivity, tips
mysql logo

mysql logo

You may remember that about three weeks ago I posted a handy script to search for the names of Tables and Columns in a Microsoft SQL database.

Well now today it’s the turn of MySql.

Just a nice and simple script as before however this time there are two seperate scripts one for tables and one for columns names.

– Author : Martin Hall
– Date 09th April 2010
– Search Table or Column for text
– MYSQL Version
– Top query for Table Names and bottom query for column names

SELECT * FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME like ‘%users%’
Order by table_name asc;

SELECT * FROM INFORMATION_SCHEMA.COLUMNS
WHERE Column_NAME like ‘%video%’
Order by column_name asc;

Enjoy.

Martin H

 
0

Search Stored Procedures for string/text

Posted by admin on Mar 30, 2010 in SQL, code, tips
SQL Code

SQL Code

OK so just like the post below about searching for columns or table names. This post is all about how to search inside Stored Procedures for strings / text.

This can be really useful especially if you know a piece of code is called but your not sure which stored proc calls it.

As before we are going to use the ‘users’ string to keep consistency.

I had searched high and low for this code on the internet but couldn’t find anything. All of the examples I found only searched in the first 255 characters of stored procedure which is OK if its a declaration your looking for however not too good if your stored proc has unions and has declarations half way down the procedure. So I decided to write my own.

Anyway on with the script. (really nice and simple)

– Author : Martin Hall
– Date 17th February 2010
– Search Stored Procedures for Text. (see Definition like)

SELECT Name
FROM sys.procedures
WHERE OBJECT_DEFINITION(object_id) LIKE ‘%users%’

Hope you Enjoy

 
0

Increase All Data in an SQL DateTime Column by a Year.

Posted by admin on Mar 16, 2010 in SQL, Testing, code, tips

I was recently testing a rarely used piece of functionality on one of the sites which belong to the company I work for. The test DB was very old as releases for this part of the system come very few and far between.

The system is written in such a way that data is only returned to the end user for data for a the last 12 months , (1 Year). The database in question had not been updated for about 18 months and it would have taken about 5 days for me to get a decent backup from the live system restored to test.

The data in the Test Database was valid it was just a little too old to be returned via the front User Interface (GUI).

What I needed was a nice and easy way to bring the date column in the database forward by year.

Obviously for good practice I also requested the live DB dump to be sent over just to completeness of testing. But to test this piece of functionality it wasn’t needed.

The following is the SQL query (Transact-SQL) I cobbled together to get the job done.

It will do a select first to see if you have any data in a particular financial year (2009 and 2010).

It will then update all 2009 data to read 2010. So 01-Feb-2009 becomes 01-Feb-2010 and 23rd June 2009 becomes 23rd June 2010.

It will then carry out the same select query it did before. If all has gone well the 2009 data should be blank and the 2010 field should be populated.

In any update script I write I always input a select before the update and the same select after the update. This way I and any other users using my script can see if the update has worked.

Now the code.

SELECT     YEAR(ColumnName) AS ColumnNameYear
FROM         TableName
GROUP BY YEAR(ColumnName)
HAVING      (YEAR(ColumnName) = 2010) OR
(YEAR(ColumnName) = 2009)

UPDATE    TableName
Set  ColumnName = dateadd(yy,1, ColumnName)
WHERE     DATEPART(year, ColumnName) = ’2009′

SELECT     YEAR(ColumnName) AS ColumnNameYear
FROM         TableName
GROUP BY YEAR(ColumnName)
HAVING      (YEAR(ColumnName) = 2010) OR
(YEAR(ColumnName) = 2009)

Hope you find it useful.

And I’m sure there are many more ways of coding this much simplier but I’m a tester and not a coder and for me it works.

 
1

Lets Break Something

Posted by admin on Jun 26, 2009 in Testing, code
Lets Break some code

Lets Break some code

The title is a little misleading as the one thing I think that testers do not do, is to break developers code.

Instead we should working with them to help find as many potential issues before our customers do.

(think of it as a department that carries out a specialised peer review)

However as a tester you need to have a few tricks up your sleeve which enable you to quickly punish an application.

The following strings will usually cause most web-enabled applications to perform strange functions or just plain fall over in a heap.

Each separate line is a separate test.

I have created a bespoke parameter fuzzer which I load my list into and 99% of the time I get a fail in a web-application.

You can also use my URL Encoder / Decoder to look a little deeper into the char-sets being used.

Read more…

 
2

Bookmarklets for a Web-Tester

Posted by admin on Feb 12, 2009 in Testing, code, productivity, tools
Code

Code

In this post I want to give people a nice heads up to some of the tools I use in my daily role.

These are bookmarklets which is just another word for bookmarks which contain javascript.

I use these with firefox although IE and Opera should also fine fine for them also. In Firefox just add them to the bookmark toolbar and you’ll have them at your fingertips.

Zap Cookies! This will clear out any stored cookies for the current page/site

Edit Cookies! This will allow you to edit and stored cookies for the current page/site

View Cookies! This does exactly what it states, it allows you to view and stored cookies for the current page/site

Edit Page

Allows you to edit any page you use this on. All changes are temporary of course and only visible to you.  (will you ever trust a web page screen shot again?). Not yet sure how this fits into the testing arena, however I though I would include it as someone may make decent use out of it.

Find Redirects! This should list any redirects for the current page, however its currently a tiny bit hit and miss and is does not work 100% of the time, it should however suffice for now and I’ll most likely have to rewrite this at some point in the near future.

remove redirects Lets see what happens if we now remove those redirects we just found using the above Bookmarklet.

Wikipedia lookup This allows you to select any text on a page and once clicked it will lookup that text on Wikipedia

Yahoo site search This allows you to select any text on a page and once clicked it will search on Yahoo for more links from that domain with the same text.

MSN IP Search Firstly I should thank Robert Hansen (RSnake) for this one. Once clicked it will carry out an IP search which can help you detect a wider network for your testing.

numbered list One of my favourites this one. It allows you to make a nice numbered list of all parameters on the page which contain numbers.

show hiddens This and Zap Cookies are my most used Bookmarklets. this one will display all hidden fields on a webpage and also allow you to edit them.

remove maxlength This will remove all the max lenghts from all input fields (think buffer overflows and code boundary issues)

undisable Who says you can’t click that button :-) . This Bookmarklet will enable any disabled objects on the page.

up This will take you up one directory level in the site structure

top This will take you to the top of the domain.

decrement If your URL ends in a number it will reduce it by one every click

increment As above but the opposite

check images This will check the current page for broken images.

view variables This will list all variable types found on the page. This is more for Developers than testers however its still a useful one to have.

view scripts Like above however it will list all scripts what can be called on the current page.

zap images This should clear all of the images from the page. Works about 98% of the time. This script may need a little tweaking if I ever get the time.

full urls as link text Very useful if you want to see where a link is pointing to.

Enjoy

Martin H

Tags: , , ,

Copyright © 2010 The Test Manager Blog All rights reserved. Theme by Laptop Geek.