• Like
Test Failed, Then...
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Test Failed, Then...

  • 1,295 views
Published

Pycon APAC presentation on optimizing inter-component communication and inter-engineer communication.

Pycon APAC presentation on optimizing inter-component communication and inter-engineer communication.

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,295
On SlideShare
0
From Embeds
0
Number of Embeds
13

Actions

Shares
Downloads
3
Comments
0
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Test Failed, Then...
 Optimizing communication between people Toru Furukawa" @torufurukawa"
  • 2. Agenda •  Introduction
 Web app syncing with live TV show" •  Loose coupling" •  Testable components" •  Efficient communication"
  • 3. Agile App Development 
 on Concrete Backend Services HTML App" App Server Backend Service(s)" Project  dependent Common
  • 4. Because... •  Requirements keep changing" •  Not only Web, but also TV" •  Not only TV, but also Web" •  Spiky access traffic" •  Common fundamental features" ▼" •  Easy to change application" •  Well tested platform"
  • 5. Ended up with… HTML App" App Server Counter" Messenger"
  • 6. High Communication Cost "Communication overheads increase as the number of people increases." F. Brooks"
  • 7. Minimal and Effective Communication
  • 8. Optimize Communication •  Between Components" •  Between People
  • 9. How to Simplify Dependency? HTML App" App Server Counter" Messenger"
  • 10. PHP •  IMPORTANT: PHP is fine" •  Cannot be combined with Python component in language layer easily
  • 11. Loose Coupling "Write small services that speak HTTP and bridge them together with another application."" Armin Ronacher (@mitsuhiko)" http://lucumr.pocoo.org/2010/12/24/common-mistakes-as-web-developer/
  • 12. Loose Coupling HTML App" (JavaScript) App Server" (whatever) Counter" (Python) Messenger" (Node.js) HTTP
  • 13. Assign Engineer for Component HTML App" (JavaScript) App Server" (whatever) Counter" (Python) Messenger" (Node.js) HTTP
  • 14. Communication Paths
  • 15. 2 Projects Running
  • 16. Wrap Engineers' Communication •  New layers to simplify inter-component communication" •  Assign new roles to simplify inter-people communication
  • 17. HTML App" (JavaScript) App Server" (whatever) Counter" (Python) Messenger" (Node.js) Server/Server Communication" (Python) Client/Server Communication
  • 18. If a servicewise feature does not work, how to identify the cause?" •  Ask developer to check logs?" •  Ask developer to check DB?" ▼" Make component diagnosable" Instrument Components
  • 19. Log with fluentd App Server" (whatever) Counter" (Python) Messenger" (Node.js) fluentd Mongo  DB Web App
  • 20. Define CRUD APIs •  Make DB accessible from test and admin •  REST /objects/:id" •  /get_objects
 /get_object, /set_object, /delete_object" ▼" •  Diagnose 1-layer deeper from outside"
  • 21. "requests" package 
 for Web API Access >>>  r  =  requests.get(url,  auth=(...),  ...)   >>>  r  =  requests.post(url,  data={...},  ...)   >>>  r.status_code   200   >>>  r.content   u'{"foo":"bar","x":true}'   >>>  r.json()   {u'foo':  u'bar',  'x':  True}  
  • 22. Library for Productivity •  Use testing libraries to increase productivity 
 i.e. how many test you write per hour" •  setup and teardown" – unittest" – nose" – py.test" – testfixtures" – etc.
  • 23. Translate Test Report Traceback  (most  recent  call  last):      File  "mytest.py",  line  7,  in  test          assert  result  ==  expected   AssertionError   ▼" •  How do YOU determine what is wrong?" •  How do you tell OTHERS what is wrong?" ▼" •  Need better way to communicate
  • 24. Library for Readability class  MyTest(unittest.TestCase):          def  test(self):                  expected  =  {...}                  result  =  {...}                  self.assertEqual(x,  y)   " "
  • 25. Traceback  (most  recent  call  last):      File  "mytest.py",  line  7,  in  test          self.assertEqual(x,  y)   AssertionError:  {'items':  ['spam',  'spam'],   'foo':  'bar'}  !=  {'items':  ['spam',  'ham'],   'foo':  'bar'}   -­‐  {'foo':  'bar',  'items':  ['spam',  'spam']}   ?                                                                      ^^     +  {'foo':  'bar',  'items':  ['spam',  'ham']}   ?                                                                      ^
  • 26. Python vs HTTP Python HTTP Test Fast Loosely Couple Develop Fast
  • 27. If I stick to Python too much,
 my communication is
 tightly coupled
  • 28. Convert requests function to curl >>>  import  curledrequests  as  requests   >>>  requests.debug  =  True   >>>  r  =  requests.get(   ...      'http://www.google.com/',   ...      params={'q':'python'})   ...   $  curl  “http://www.google.com/?q=python”  -­‐w   'n%{http_code}n'   <!doctype  html><html  itemscope=""   itemtype="http://schema.org/WebPage"><head><me   ...   200   h5p://goo.gl/hO579O  
  • 29. Loosely Couple
 Components and Engineers
  • 30. Share Your Practice @torufurukawa or grab me"