Dear All:
I have done my test for 2 actions do simultaneously for the same
command. Here is my approvement.
------------------------
Window DOS 1
------------------------
F:\ruby\tiesto> ruby test/unit/item_test.rb
Loaded suite test/unit/item_test
Started
.
Finished in 42.078 seconds.
1 tests, 0 assertions, 0 failures, 0 errors
------------------------
Windows DOS 2
------------------------
F:\ruby\tiesto>ruby test/unit/item_test.rb
Loaded suite test/unit/item_test
Started
.
Finished in 42.125 seconds.
1 tests, 0 assertions, 0 failures, 0 errors
---------------------
SCRIPT item_test.rb
---------------------
require File.dirname( __FILE__) + ''/../test_helper''
class ItemTest < Test::Unit:: TestCase
def test_what
CD = item.find(:first)
Item.transaction do
CD.modification
end
end
end
------------------------------------
SCRIPT in Item.rb (Active Record)
------------------------
class Item < ActiveRecord: :Base
def modification
#delaying process
for z in 1..100000000
end
update_attributes( :stock => stock-1)
end
------------------------
TABLE BEFORE TESTS RUN
------------------------
-----------------
ID | ITEM | QTY |
-----------------
1 | HEAVEN | 10 |
-----------------
After 2 Windows Run TEST TOGETHER.
----------------------
TABLE AFTER EXECUTIONS
----------------------
-------------------
ID | ITEM | QTY |
-------------------
1 | HEAVEN | 9 |
-------------------
It is not what i expected, it should be 10 - 1 -1 = 8, NOT 9. In other
case i did put Item.transaction do there.
What is your suggestion about it ???
Thank you,
Reinhart
http://teapoci.blogspot.com
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
CORRECTION TABLE : ----------------- ID | ITEM | STOCK | ----------------- 1 | HEAVEN | 10 | ----------------- After 2 Windows Run TEST TOGETHER. ---------------------- TABLE AFTER EXECUTIONS ---------------------- ------------------- ID | ITEM | STOCK | ------------------- 1 | HEAVEN | 9 | ------------------- REGARDS, Reinhart http://teapoci.blogspot.com -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On May 8, 5:05 pm, Rails Terrorist <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> It is not what i expected, it should be 10 - 1 -1 = 8, NOT 9. In other > case i did put Item.transaction do there. > > What is your suggestion about it ???You need locking, not transactions. the problem is that both scripts load the initial version (ie with quantity = 10). when the second one completes it ignores the changes made by the first one. Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks my bro, fred. Here is my second experiment
---------------------
SCRIPT item_test.rb
---------------------
require File.dirname( __FILE__) + ''/../test_helper''
class ItemTest < Test::Unit:: TestCase
def test_what
Item.transaction do
CD = item.find(:first, :lock=>true)
CD.modification
end
end
end
--------------
DOS in WINDOW 1
--------------
F:\ruby\project_dev>ruby test/unit/barang_terpesan_test.rb
Loaded suite test/unit/barang_terpesan_test
Started
.
Finished in 39.734 seconds.
1 tests, 0 assertions, 0 failures, 0 errors
--------------
DOS in WINDOW 2
--------------
F:\ruby\project_dev>ruby test/unit/barang_terpesan_test.rb
Loaded suite test/unit/barang_terpesan_test
Started
.
Finished in 40.703 seconds.
1 tests, 0 assertions, 0 failures, 0 errors
And No Changes.
**************************
TABLE BEFORE EXECUTIONS
**************************
-----------------
ID | ITEM | STOCK |
-----------------
1 | HEAVEN | 10 |
-----------------
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
TABLE AFTER EXECUTIONS
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-------------------
ID | ITEM | STOCK |
-------------------
1 | HEAVEN | 9 |
-------------------
I have done too with :
ActiveRecord::Base.transaction do
CD = item.find(:first, :lock=>true)
CD.modification
end
And no changes, the result still the same.
Reinhart
http://teapoci.blogspot.com
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On May 8, 5:30 pm, Rails Terrorist <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Thanks my bro, fred. Here is my second experiment >Are you tables MyISAM? MyISAM tables don''t support transactions or row level locks (AR''s optimistic locking is probably a better fit for this anyway) so this would be entirely surprising (but using transactions is necessary for pessimistic locking; the lock is held for the duration of the current transaction Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Yes it is ENGINE=MyISAM :(( How I can move it? I use SQLYOG and XAMP, it says ENGINE=MyISAM, MySQL GUI v5.14. Thank you, Reinhart -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On May 8, 6:22 pm, Rails Terrorist <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Yes it is ENGINE=MyISAM :(( > > How I can move it? I use SQLYOG and XAMP, it says ENGINE=MyISAM, MySQL > GUI v5.14. >set it to innodb. No idea what SQLYOG or XAMP are. Also I noticed that for some reason you''re doing this from unit tests which (normally) destroy and reload the test database each time you run them Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
What is the best way to test it out of unit test? Thank you. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I cant find to convert MyISAM to InnoDB fast and safety. I have lot of table tobe converted, any suggestion? Thanks, Reinhart -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Thu, May 8, 2008 at 10:44 AM, Rails Terrorist <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I cant find to convert MyISAM to InnoDB fast and safety.See the MySQL doc for ALTER TABLE -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ALTER TABLE items ENGINE=INNODB Not work, I use phpMyAdmin at XAMP and SQLYOG -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On May 8, 6:37 pm, Rails Terrorist <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> What is the best way to test it out of unit test? Thank you.script/runner for example or just require boot.rb and environment.rb Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---