Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chris Aniszczyk EclipseSource aniszczyk.org Paul VanderLei Band XI International tinyurl.com/paul-vanderlei.

Similar presentations


Presentation on theme: "Chris Aniszczyk EclipseSource aniszczyk.org Paul VanderLei Band XI International tinyurl.com/paul-vanderlei."— Presentation transcript:

1 Chris Aniszczyk EclipseSource aniszczyk.org Paul VanderLei Band XI International tinyurl.com/paul-vanderlei

2  T elematics -On-A-STick  Sample from upcoming book equinoxosgi.org equinoxosgi.org  Example project in EclipseRT wiki.eclipse.org/Toast wiki.eclipse.org/Toast 2 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0

3 3 Emergency Monitor Emergency Servlet GPS Channel Airbag Log

4 log Emergency Servlet HTTP Channel send GPS get location Emergency Monitor notify 4 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Airbag

5  Versioning  Evolving API  Tools  Issues  Summary 5 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0

6  “Software versioning is the process of assigning either unique version names or unique version numbers to unique states of computer software.”  Versioning is relative though… 6 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0

7  State of versioning is a bit ridiculous…  Java 1.0.3, 1.1.2, 1.4.2, 1.5.0, 1.6.0 (why leave the 1.?)  Windows 3.1, 2000, XP, ME, 7 (wtf?)  Netscape 4, 5, 6 (skipping versions due to IE6 competition)  Linux 2.3, 2.4.0, 2.6.8, 2.6.8.1 (odd – dev, even – stable)  SmallEiffel -0.87… -0.79… -0.74… counting down to 0… 7 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0

8 8  Versioning is a marketing thing…  User’s don’t really care about versions…  Users just want to know if the version of the software they are running is current…  e.g., Ubuntu Feisty Fawn – 7.04 Gutsy Gibbon – 7.10 Hardy Heron – 8.04

9 9 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0  Version numbers are like dog tags*  Primarily used in an event of emergency… *http://www.codinghorror.com/blog/archives/000793.htm l

10  Dependencies are defined on the module and package level Import-Package Require-Bundle  Ranges allow for flexibility Import-Package: org.easymock;version=[2.4.0,3.0.0) 10 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0

11  major.minor.micro.qualifier major – An incompatible update; breaking API minor – A backward compatible update; API stable micro – A bug fix; no API changes qualifier – build date; lexigraphic  Versions should encode compatibility* at the bundle and package level 11 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 *http://wiki.eclipse.org/Version_Numbering

12 12 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Notice how the version numbers don’t necessarily match the 3.6 release?

13 13 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 GPS – 1.0.0 getHeading() getLatitude() getLongitude() getSpeed()  Let’s evolve our GPS API…

14 GPS – 1.1.0 getHeading() getLatitude() getLongitude() getSpeed() getHeight() 14 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0  Toast on a plane… we add height…

15 GPS – 1.2.0 getHeading() getLatitude() getLongitude() getSpeed() getHeight() 15 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Altimeter – 1.0.0 getHeight()  Management now wants an altimeter!

16 GPS – 2.0.0 getHeading() getLatitude() getLongitude() getSpeed() 16 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Altimeter – 1.0.0 getHeight()  We broke API, need to fix versions!

17  Managing versions is important and painful  At Eclipse, we learned this lesson and have many experiences in dealing with maintaining and evolving API  Other projects eventually learn the importance of versioning… 17 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0

18 18 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 “I still believe a an official compatibility statement are in order. It includes a definition of the API and a separate definition of the SPI, and possible a third definition of the Configuration. I bet everyone would back such statement, would clarify the "unbreakable“ parts, and what is "features of your own risk" and so on.”

19 19 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 “Commons collections 3.0 is binary compatible with version 2.1 and 2.0 except for certain methods on one class. As the release was a major version, this is permitted, however it was unintentional and an error… the chosen solution is to provide a work around by releasing v2.1.1 and v3.1.” http://commons.apache.org/collections/compatibility.html

20 20 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0

21  Users need to understand the contract when using your software…  Good fences make for good neighbors!  Binary compatibility is important 21 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0

22  Binary compatibility is important  Maintaining binary compatibility is complex  Eclipse puts API on an altar…  Since Eclipse 3.4, Eclipse uses tools to manage and evolve API… 22 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 *http://java.sun.com/docs/books/jls/second_edition/html/binaryComp.doc.ht ml

23  Assists developers in API maintenance by reporting API defects such as binary incompatibilities, incorrect bundle version numbers and API usage.  Let’s revisit the GPS example… 23 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0

24 24 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 We need height!

25 25 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0  Version number problems and quickfixes…

26 26 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0  Let’s unknowingly break API…

27 27 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0  Never break API again unless you want to!

28 28 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0

29 29 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0  Understand API changes…

30 30 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Understand who uses your API given a set of bundles

31 31 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 22 GPS API References

32 32 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 API Reference Details

33  Getting proper version ranges correct is difficult if there’s no consistent semantics e.g., log4j case… [1.2.0,1.3.0) or [1.2.0,2.0.0) ?  Not all bundles are versioned properly in repositories  Tooling doesn’t cover packages yet… 33 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0

34  OSGi versions encode compatibility!  Don’t treat bundle versions like a marketing number  Scope your version ranges properly 34 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0

35  Good Practices  Sample Application  Unit Testing  System Testing  Remaining Issues 35 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0

36  Write your application as POJOs (plain-old-java-objects) No Service Trackers! Whiteboard Pattern is tricky Pay attention to dependencies Unit testing depends on getting this right 36 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0

37  Use Junit  Use mock objects (EasyMock, jMock...)  Minimize delays  No human interaction  Do TDD 37 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 “…I think that developers who can’t cope with any level of TDD shouldn’t be coding at all…”

38  Terminology Unit under test (UUT) Test harness  Test each POJO on its own (no OSGi)  Mock each dependency 38 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0

39 Log log Emergency Servlet HTTP Channel send GPS get location Emergency Monitor notify 39 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Airbag

40 Log test harness UUT 40 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Emergency Servlet GPS Channel Airbag Mock GPS Mock Channel send get location Emergency Monitor notify Mock Airbag

41  Keep the test case in a separate project But POJO is not visible Solution: 41 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0

42 42 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0  Dependencies Junit & EasyMock dependency interfaces

43 43 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 create UUT create mock GPS

44 44 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 create mock airbag

45 45 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 create mock channel

46 46 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 run the test

47 47 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0

48  Test as much of system as possible  OSGi is present  Test full system flow  Test bundles coming and going 48 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0

49 Log Mock Log test harness UUT log Emergency Servlet HTTP Channel send GPS get location Emergency Monitor notify 49 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Airbag Mock Airbag deploy verify Test Case

50 50 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0  Normal Plug-in Project declares 3 components

51 51 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 hook for testing

52 52 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 hook for testing

53  PDE Junit test infrastructure uses Equinox extensions  Declarative Services uses OSGi services 53 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0

54  Junit instantiates the test case as usual setup() testEmergency()  Problem: no way to obtain: bundle context mock airbag mock log 54 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0

55  Instantiates the test case as a component  DS dependency injection setAirbag( ) setLog( ) startup()  Problem: This instance is never used by Junit! 55 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0

56 56 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 DS invokes these instances share these ready to run test case

57 57 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 stop GPS bundle normal test wait until DS has activated start GPS bundle

58 58 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0

59  Still very tricky  Not well-supported by PDE tooling  Validation by logging is fragile 59 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0

60  Get the slides: tinyurl.com/osgiVTtinyurl.com/osgiVT  Get the code: wiki.eclipse.org/Toastwiki.eclipse.org/Toast  Get the book: equinoxosgi.orgequinoxosgi.org 60 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0


Download ppt "Chris Aniszczyk EclipseSource aniszczyk.org Paul VanderLei Band XI International tinyurl.com/paul-vanderlei."

Similar presentations


Ads by Google