473,654 Members | 3,129 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Massive unit test vs MySQL

I don't know if this is really a Python question of a MySQL question,
but i am hopen that there is enough overlap that someone can help me ;-)

I have a unit test suite for our server that loads a clean database
image for many of the tests. I use

p = os.popen('mysql -u uid -ppassword mydatabase', 'w')
p.write(sql_com mands)

to load the database.

While the tests are running, I find that mysql has a growing number of
"Sleeping" threads in the 'show processlist' table. Towards the end of
the test suite, the database loads start to fail with a MySQL error of
"ERROR 1040: Too many connections".

So my question would be, is there any way to shut down the child process
so that MySQL notices and cleans up after itself before it runs out of
threads?

TIA,

--

- rmgw

<http://www.trustedmedi anetworks.com/>

----------------------------------------------------------------------------
Richard Wesley Trusted Media Networks, Inc.

"If we're not careful, we could have a farce on our hands!"
- Tom Stoppard, _On The Razzle_
Jul 18 '05 #1
5 3009
"Richard Wesley" <ha******@trust edmedianetworks .com> schrieb:
I don't know if this is really a Python question of a MySQL question,
but i am hopen that there is enough overlap that someone can help me ;-)

I have a unit test suite for our server that loads a clean database
image for many of the tests. I use

p = os.popen('mysql -u uid -ppassword mydatabase', 'w')
p.write(sql_com mands)
Do you p.close() when you are finished? Otherwise the connection opend by
mysql will stay open.
to load the database.

While the tests are running, I find that mysql has a growing number of
"Sleeping" threads in the 'show processlist' table. Towards the end of
the test suite, the database loads start to fail with a MySQL error of
"ERROR 1040: Too many connections".

So my question would be, is there any way to shut down the child process
so that MySQL notices and cleans up after itself before it runs out of
threads?

Jul 18 '05 #2
On Thursday 04 September 2003 20:35, Richard Wesley wrote:
I have a unit test suite for our server that loads a clean database
image for many of the tests. I use

p = os.popen('mysql -u uid -ppassword mydatabase', 'w')
p.write(sql_com mands)
Your pipe is still open at this point, and therefore you have a
connection to the database open.
So my question would be, is there any way to shut down the child
process so that MySQL notices and cleans up after itself before it
runs out of threads?


p.close()

-- Neil
Jul 18 '05 #3
In article <bj**********@n ntp0.reith.bbc. co.uk>,
Neil Padgen <ne*********@mo n.bbc.co.uk> wrote:
On Thursday 04 September 2003 20:35, Richard Wesley wrote:
I have a unit test suite for our server that loads a clean database
image for many of the tests. I use

p = os.popen('mysql -u uid -ppassword mydatabase', 'w')
p.write(sql_com mands)


Your pipe is still open at this point, and therefore you have a
connection to the database open.
So my question would be, is there any way to shut down the child
process so that MySQL notices and cleans up after itself before it
runs out of threads?


p.close()


Yeah, I tried this, but it had no effect.

The odd thing is that the process list cleans up _immediately_ when the
script terminates. Maybe this is some sort of gc problem?

--

- rmgw

<http://www.trustedmedi anetworks.com/>

----------------------------------------------------------------------------
Richard Wesley Trusted Media Networks, Inc.

"You're confusing boredom with motivation."
- Sherman in "Sherman's Lagoon"
Jul 18 '05 #4
In article <ha************ *************** *@spectator.sj. sys.us.xo.net>,
Richard Wesley <ha******@trust edmedianetworks .com> wrote:
In article <bj**********@n ntp0.reith.bbc. co.uk>,
Neil Padgen <ne*********@mo n.bbc.co.uk> wrote:
On Monday 08 September 2003 22:28, Richard Wesley wrote:
In article <bj**********@n ntp0.reith.bbc. co.uk>,
Neil Padgen <ne*********@mo n.bbc.co.uk> wrote:

I doubt it - it is generated by mysqldump. And there is no problem
from the command line.


I use exactly the same approach to set up my unit tests, but I have a
different way to get the mysqldump data into the database:

os.system('mysq l database_name < dumpfile')


Sadly, this did not work, nor did garbage collection (gc.collect()).

For some reason, mysql is holding onto a whole lot of connections from
my script until the script terminates.


OK, I'm an idiot. It had nothing to do with the reload script. The
connections were from the TestCase subclass I have that instantiates a
connection management object. It appears that the unittest module does
not dispose of the objects it instantiates until the end of the run, so
you need to REALLY clean up in the tearDown method. I discovered this
by making a persistent connection for the reload operation and noticing
that the number of connections still increased.

Thanks to all who responded.

--
Best regards,

Richard Wesley
Co-President, Electric Fish, Inc.
<http://www.electricfis h.com/>
(v) +1-206-493-1690x210
(f) +1-206-493-1697
(h) +1-206-632-4536
(m) +1-206-409-4536
Jul 18 '05 #5
>>>>> "Richard" == Richard Wesley <ha******@trust edmedianetworks .com> writes:

Richard> OK, I'm an idiot. It had nothing to do with the reload
Richard> script. The connections were from the TestCase subclass
Richard> I have that instantiates a connection management object.
Richard> It appears that the unittest module does not dispose of
Richard> the objects it instantiates until the end of the run, so
Richard> you need to REALLY clean up in the tearDown method. I
Richard> discovered this by making a persistent connection for the
Richard> reload operation and noticing that the number of
Richard> connections still increased.

Doh! I should have thought of this, as I've had exactly the same
problem in the past.

Thanks for posting your solution.

-- Neil
Jul 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
2738
by: | last post by:
Hi! I'm looking for unit-testing tools for .NET. Somthing like Java has --> http://www.junit.org regards, gicio
1
1802
by: | last post by:
Hi- I was curious if anyone has had good luck using one of the commercial .NET FTP client libraries to perform massive LIST commands. I have tried various free libraries with no/little success, either they time out or throw an error about the list being too long. There are easily hundreds of thousands of files spread over 100 different directories. I need to download a complete listing of all files and modified dates in order to...
72
5230
by: Jacob | last post by:
I have compiled a set og unit testing recommendations based on my own experience on the concept. Feedback and suggestions for improvements are appreciated: http://geosoft.no/development/unittesting.html Thanks.
5
6515
by: shuisheng | last post by:
Dear All, I was told that unit test is a powerful tool for progamming. If I am writing a GUI code, is it possible to still using unit test? I have a little experience in using unittest++. But I can not work out a way to use it to test GUI code. Thanks a lot!
176
8331
by: nw | last post by:
Hi, I previously asked for suggestions on teaching testing in C++. Based on some of the replies I received I decided that best way to proceed would be to teach the students how they might write their own unit test framework, and then in a lab session see if I can get them to write their own. To give them an example I've created the following UTF class (with a simple test program following). I would welcome and suggestions on how anybody...
1
1794
by: rich_sposato | last post by:
I released version 2.0 of C++ Unit Test Library. You can download it from SourceForget.Net at http://sourceforge.net/projects/cppunittest/ .. I wrote this unit test library because other unit test frameworks always lacked features I considered important. Some only provided output in certain formats, and I had no easy way to choose my own format. Most provided no protection against exceptions. Only a few were useful for unit-testing...
6
5683
by: Vyacheslav Maslov | last post by:
Hi all! I have many many many python unit test, which are used for testing some remote web service. The most important issue here is logging of test execution process and result. I strongly need following: 1. start/end timestamp for each test case (most important) 2. immediate report about exceptions (stacktrace) 3. it will be nice to use logging module for output
27
2542
by: brad | last post by:
Does anyone else feel that unittesting is too much work? Not in general, just the official unittest module for small to medium sized projects? It seems easier to write some quick methods that are used when needed rather than building a program with integrated unittesting. I see the value of it (the official unittest that is)... especially when there's a lot of source code. But this... if len(x) != y: sys.exit('...')
5
2240
by: Ben Finney | last post by:
Howdy all, PEP 299 <URL:http://www.python.org/dev/peps/pep-0299details an enhancement for entry points to Python programs: a module attribute (named '__main__') that will be automatically called if the module is run as a program. The PEP has status "Rejected", citing backward-compatibility issues, and Guido's pronouncement that "It's not worth the change (in docs, user habits, etc.) and there's nothing particularly broken."
0
8285
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8814
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8475
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8591
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7304
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5621
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2709
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.