contribute.dox 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. // Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this
  5. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
  6. /**
  7. @page contributorGuide Kea Contributor's Guide
  8. So you found a bug in Kea or plan to develop an extension and want to
  9. send us a patch? Great! This page will explain how to contribute your
  10. changes smoothly.
  11. @section contributorGuideWritePatch Writing a patch
  12. Before you start working on a patch or a new feature, it is a good
  13. idea to discuss it first with Kea developers. You can post your
  14. questions to the \c kea-dev mailing list
  15. (https://lists.isc.org/mailman/listinfo/kea-dev) or kea-users
  16. (https://lists.isc.org/mailman/listinfo/kea-users). The kea-users list
  17. is intended for users who are not interested in the internal workings
  18. or development details of Kea: it is OK to ask for feedback regarding new
  19. design or the best proposed solution to a certain problem, but all
  20. the internal details should be discussed on kea-dev and not posted
  21. to kea-users.
  22. The first step in writing the patch or new feature should be to get
  23. the source code from our Git repository. The procedure is very easy and
  24. is explained here: http://kea.isc.org/wiki/GitGuidelines. While it is
  25. possible to provide a patch against the latest stable release, it makes
  26. the review process much easier if it is for latest code from the Git \c
  27. master branch.
  28. OK, so you have written a patch? Great! Before you submit it, make sure
  29. that your code compiles. This may seem obvious, but there's more to
  30. it. You have surely checked that it compiles on your system, but Kea
  31. is portable software. Besides Linux, it is compiled and used on
  32. relatively uncommon systems like OpenBSD. Will your code
  33. compile and work there? What about endianess? It is likely that you used
  34. a regular x86 architecture machine to write your patch, but the software
  35. is expected to run on many other architectures. You may take a look at
  36. system specific build notes (http://kea.isc.org/wiki/Install).
  37. For a complete list of systems we build on, you may take a look at the
  38. following build farm report: https://jenkins.isc.org/view/Kea_BuildFarm/ .
  39. Does your patch conform to Kea coding guidelines
  40. (http://kea.isc.org/wiki/CodingGuidelines)? You can submit a
  41. patch that does not adhere to them, but that will reduce its chances of
  42. being accepted. If the deviations are minor, one of the Kea engineers who
  43. does the review will likely fix the issues. However, if there are lots
  44. of issues, the reviewer may simply reject the patch and ask you to fix
  45. it before re-submitting.
  46. @section contributorGuideUnittests Running unit-tests
  47. One of the ground rules in Kea development is that every piece of
  48. code has to be tested. We now have an extensive set of unit-tests for
  49. almost every line of code. Even if you are fixing something small,
  50. like a single line fix, you are encouraged to write unit-tests for that
  51. change. That is even more true for new code: if you write a new
  52. function, method or a class, you definitely should write unit-tests
  53. for it.
  54. To ensure that everything is tested, ISC uses a development method
  55. called Test Driven Development (TDD). In TDD, a feature is developed
  56. alongside the tests, with the tests being written first. In detail,
  57. a test is written for a small piece of functionality and run against
  58. the existing code. (In the case where the test is a unit test for
  59. a function, it would be run against an empty (unimplemented)
  60. function.) The test should fail. A minimal amount of code is then
  61. written, just enough to get the test to pass. Then the process is
  62. repeated for the next small piece of functionality. This continues
  63. until all the functionality has been implemented.
  64. This approach has two advantages:
  65. - By writing a test first and then only enough code to pass the
  66. test, that code is fully tested. By repeating this process until
  67. the feature is fully implemented, all the code gets test coverage.
  68. You avoid the situation where not enough tests have been written
  69. to check all the code.
  70. - By running the test before the code implementing the function is
  71. written and observing the test fail, you can detect the situation
  72. where a bug in the test code will cause it to pass regardless of
  73. the code being tested.
  74. Initially, some people unfamiliar with that approach react with "but
  75. my change is simple and I tested that it works". That approach
  76. is both insufficient and short-sighted. It is insufficient, because
  77. manual testing is by definition laborious and can't really be done
  78. on the multitude of systems we run Kea on. It is short-sighted, because
  79. even with your best intentions you will not be able to dedicate
  80. any significant amount of time for repeated testing of your improved
  81. code. The old ISC DHCP has two decades of history behind it and we
  82. hope to make Kea last similar time span. Over such long periods,
  83. code tends to be refactored several times. The change you
  84. made may be affected by some other change or by the code that
  85. hasn't been written yet.
  86. See @ref unitTests for instructions on how to run unit-tests. If you
  87. happen to touch any database related code, make sure you compile
  88. your code with @c --with-dhcp-mysql, @c --with-dhcp-pgsql and/or
  89. @c --with-cql as needed. For example, if you change something
  90. substantial, make sure the other compilation options still work.
  91. If you happen to add new files or have modified any \c Makefile.am
  92. files, it is also a good idea to check if you haven't broken the
  93. distribution process:
  94. @code
  95. make distcheck
  96. @endcode
  97. There are other useful switches which can be passed to configure. It is
  98. always a good idea to use \c --enable-logger-checks, which does sanity
  99. checks on logger parameters. Use \c --enable-debug to enable various
  100. additional consistency checks that reduce performance but help during
  101. development. If you happen to modify anything in the
  102. documentation, use \c --enable-generate-docs. If you are modifying DHCP
  103. code, you are likely to be interested in enabling a non-default database
  104. backends for DHCP. Note that if the backend is not enabled,
  105. the database-specific unit-tests are skipped. To enable the MySQL backend,
  106. use the switch \c --with-dhcp-mysql; for PostgreSQL, use \c --with-dhcp-pgsql.
  107. A complete list of all switches can be obtained with the command:
  108. @code
  109. ./configure --help
  110. @endcode
  111. @section contributorGuideSendPatch Sending the patch
  112. There are several ways how you can send your changes. They are listed
  113. here from most to least preferred.
  114. - Send pull request (PR) on github. This is by far the most convenient way for
  115. everyone. See the excellent documentation on github:
  116. https://help.github.com/articles/creating-a-pull-request/ for details. In
  117. essence, you need github account (spam/hassle free, takes one minute to set
  118. up). Then you can fork the Kea repository, commit changes to your repo and ask us to pull
  119. your changes into official Kea repository. This has a number of advantages. First, it is
  120. made against a specific code version, which can be easily checked with git log
  121. command. Second, this request pops up instantly on our list of open pull
  122. requests and will stay there. The third benefit is that the pull request mechanism is
  123. very flexible. Kea engineers (and other users, too) can comment on it, attach
  124. links, mention other users etc. You as a submitter can augment the patch by
  125. commiting extra changes to your repository. Those extra commits will appear instantly
  126. in the pull request. This is really useful during the review. Finally, ISC engineers can
  127. better assess all open pull requests and add labels to them, such as "enhancement", "bug", or
  128. "unit-tests missing". This makes our life easier. Oh, and your commits will later
  129. be shown as yours in github history. If you care for that kind of things, once the
  130. patch is merged, you'll be automatically listed as contributor and Kea will be
  131. listed as project you have contributed to.
  132. - Create a ticket in the Kea trac and attach your patch to it. Sending a patch has a
  133. number of disadvantages. First, if you don't specify the base version against
  134. which it was created, one of ISC engineers will have to guess that or go through
  135. a series of trials and errors to find that out. If the code doesn't compile, the
  136. reviewer will not know if the patch is broken or maybe it was applied to
  137. incorrect base code. Another frequent problem is that it may be possible that
  138. the patch didn't include any new files you have added. If we happen to have any
  139. comments that you as submitter are expected to address (and in the overwhelming majority
  140. of cases, we have), you will be asked to send an updated patch. It is not
  141. uncommon to see several rounds of such reviews, so this can get very complicated
  142. very quickly. Please make sure your ticket is created in the default milestone
  143. "kea-proposed". ISC engineers review new tickets once a week and assign them to
  144. specific milestones. Please do not add tickets to working milestones directly.
  145. Having a ticket in trac ensures that the patch will never be forgotten and it
  146. will show up on our trac reports. It's not required, but much appreciated if
  147. you send a short note to the kea-dev mailing list explaining what you did with the code
  148. and announce the ticket number.
  149. - Send a patch to the kea-dev list. This is the third preferred method, if you
  150. can't or don't want to use github and trac for whatever reason. If you
  151. send a patch to a mailing list in a wrong time, e.g. shortly before a release,
  152. ISC engineers may miss it or perhaps they will see it and then forget about
  153. it. Nevertheless, it is still doable and we successfully accepted patches that
  154. way. It just takes more time from everyone involved, so it's a slower process in
  155. general.
  156. - Send a tarball with your modified code. This is really the worst way one
  157. can contribute a patch. It has a number of disadvantages. In particular, someone
  158. will need to find out which version the code was based on and generate the
  159. patch. It's not a rocket science, but it may be a very mundane thing to do
  160. if the ISC engineer does not know the version in advance. The mailing list
  161. has a limit on the message size (for good reasons), so you'll likely need to
  162. upload it somewhere first. ISC engineers often don't pick up new tickets
  163. instantly, so it may have to wait weeks before the tarball is looked at.
  164. The tarball does not benefit from most of the advantages mentioned for github,
  165. like the ability to easily update the code, have a meaningful discussion
  166. or see what the exact scope of changes are. Nevertheless, if we given a choice
  167. of getting a tarball or not getting a patch at all, we prefer tarballs. Just
  168. keep in mind that processing a tarball is really cumbersome for ISC
  169. engineers, so it may take sigificantly longer than other ways.
  170. @section contributorGuideReview Going through a review
  171. Once you let us submitted a patch using one of the ways above, the action
  172. is on one of the ISC engineers. First, we will need either a trac ticket
  173. or PR on github. We prefer the original submitter fill them as he or she
  174. has the best understanding of the purpose of the change and may have
  175. any extra information, e.g. "this patch fixes compilation issue on
  176. FreeBSD 10.1". If there there is no PR and no trac ticket, we will create
  177. one. Depending on the subjective importance and urgency as perceived by
  178. the ISC engineer, the ticket or PR will be assigned to one of the
  179. milestones.
  180. Sooner or later, one of ISC engineers will do the review. Here's the tricky
  181. part. One of Kea developers will review your patch, but it may not happen
  182. immediately. Unfortunately, developers are usually working under a tight
  183. schedule, so any extra unplanned review work may take a while sometimes. Having
  184. said that, we value external contributions very much and will do whatever we can
  185. to review patches in a timely manner. Don't get discouraged if your patch is not
  186. accepted after first review. To keep the code quality high, we use the same
  187. review processes for external patches as we do for internal code. It may take
  188. some cycles of review/updated patch submissions before the code is finally
  189. accepted. The nature of the review process is that it emphasizes areas that need
  190. improvement. If you are not used to the review process, you may get the
  191. impression that the feedback is negative. It is not: even the Kea developers
  192. seldom see reviews that say "All OK please merge".
  193. Once the process is almost complete, the developer will likely ask you how you
  194. would like to be credited. The typical answers are by first and last name, by
  195. nickname, by company name or anonymously. Typically we will add a note to the \c
  196. ChangeLog and also set you as the author of the commit applying the patch and
  197. update the contributors section in the AUTHORS file. If the contributed feature
  198. is big or critical for whatever reason, it may also be mentioned in release
  199. notes.
  200. Sadly, we sometimes see patches that are submitted and then the submitter never
  201. responds to our comments or requests for an updated patch. Depending on the
  202. nature of the patch, we may either fix the outstanding issues on our own and get
  203. another ISC engineer to review them or the ticket may end up in our "Outstanding
  204. Tasks" milestone. When a new release is started, we go through the tickets in
  205. Outstanding Tasks, select a small number of them and move them to whatever the
  206. current milestone is. Keep that in mind if you plan to submit a patch and forget
  207. about it. We may accept it eventually, but it's much, much faster process if you
  208. participate in it.
  209. @section contributorGuideExtra Extra steps
  210. If you are interested in knowing the results of more in-depth testing, you are
  211. welcome to visit the ISC Jenkins page: https://jenkins.isc.org This is a live
  212. result page with all tests being run on various systems. Besides basic
  213. unit-tests, we also have reports from valgrind (memory debugger), cppcheck and
  214. clang-analyzer (static code analyzers), Lettuce system tests and more. Although
  215. it is not possible for non ISC employees to run tests on that farm, it is
  216. possible that your contributed patch will end up there sooner or later. We also
  217. have ISC Forge tests running, but currently the test results are not publicly
  218. available.
  219. */