update_engine: Fix splitting and merging of operation.

As previously implemented, these features retained the original
operation type, thus potentially violating an invariant of the delta
format by which an operation must have the minimum possible size. This
could take form in either direction; in one case, we've seen this fail
payload verification when a large REPLACE_BZ was split into small
operations and the compressed blob of one was larger than the size of
the written blocks (i.e. compression was disadvantageous).

Instead, when splitting and merging operations we now choose an optimal
operation type among REPLACE and REPLACE_BZ. This means that every
split/merged data blob is compressed and its size compared to its
uncompressed form, storing the smaller of the two and setting the
operation type accordingly.

This also refactors unit tests and adds more test cases to ensure that
operation types are chosen optimally and that the conversion is correct
in both directions.

Finally, this re-enables the splitting of REPLACE_BZ operations, which
was disabled (CL:270581) to prevent payload breakages.

BUG=chromium:487595
TEST=Unit tests

Change-Id: Ib348b76a96eba6dd612cafa412e1231c43389f96
Reviewed-on: https://chromium-review.googlesource.com/271277
Trybot-Ready: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
3 files changed
tree: 4204498d276d91248008b532d08ca7090bbd1315
  1. dbus_bindings/
  2. init/
  3. payload_generator/
  4. update_manager/
  5. .gitignore
  6. action.h
  7. action_pipe.h
  8. action_pipe_unittest.cc
  9. action_processor.cc
  10. action_processor.h
  11. action_processor_unittest.cc
  12. action_unittest.cc
  13. bzip.cc
  14. bzip.h
  15. bzip_extent_writer.cc
  16. bzip_extent_writer.h
  17. bzip_extent_writer_unittest.cc
  18. certificate_checker.cc
  19. certificate_checker.h
  20. certificate_checker_unittest.cc
  21. chrome_browser_proxy_resolver.cc
  22. chrome_browser_proxy_resolver.h
  23. chrome_browser_proxy_resolver_unittest.cc
  24. clock.cc
  25. clock.h
  26. clock_interface.h
  27. connection_manager.cc
  28. connection_manager.h
  29. connection_manager_unittest.cc
  30. constants.cc
  31. constants.h
  32. dbus_constants.h
  33. dbus_service.cc
  34. dbus_service.h
  35. dbus_wrapper_interface.h
  36. delta_performer.cc
  37. delta_performer.h
  38. delta_performer_unittest.cc
  39. download_action.cc
  40. download_action.h
  41. download_action_unittest.cc
  42. error_code.h
  43. extent_ranges.cc
  44. extent_ranges.h
  45. extent_ranges_unittest.cc
  46. extent_writer.cc
  47. extent_writer.h
  48. extent_writer_unittest.cc
  49. fake_clock.h
  50. fake_file_writer.h
  51. fake_hardware.h
  52. fake_p2p_manager.h
  53. fake_p2p_manager_configuration.h
  54. fake_prefs.cc
  55. fake_prefs.h
  56. fake_system_state.cc
  57. fake_system_state.h
  58. file_descriptor.cc
  59. file_descriptor.h
  60. file_writer.cc
  61. file_writer.h
  62. file_writer_unittest.cc
  63. filesystem_verifier_action.cc
  64. filesystem_verifier_action.h
  65. filesystem_verifier_action_unittest.cc
  66. glib_utils.cc
  67. glib_utils.h
  68. hardware.cc
  69. hardware.h
  70. hardware_interface.h
  71. http_common.cc
  72. http_common.h
  73. http_fetcher.cc
  74. http_fetcher.h
  75. http_fetcher_unittest.cc
  76. hwid_override.cc
  77. hwid_override.h
  78. hwid_override_unittest.cc
  79. install_plan.cc
  80. install_plan.h
  81. libcurl_http_fetcher.cc
  82. libcurl_http_fetcher.h
  83. local_coverage_rate
  84. main.cc
  85. metrics.cc
  86. metrics.h
  87. mock_action.h
  88. mock_action_processor.h
  89. mock_certificate_checker.h
  90. mock_connection_manager.h
  91. mock_dbus_wrapper.h
  92. mock_file_writer.h
  93. mock_hardware.h
  94. mock_http_fetcher.cc
  95. mock_http_fetcher.h
  96. mock_omaha_request_params.h
  97. mock_p2p_manager.h
  98. mock_payload_state.h
  99. mock_prefs.h
  100. mock_update_attempter.h
  101. mtd_file_descriptor.cc
  102. mtd_file_descriptor.h
  103. multi_range_http_fetcher.cc
  104. multi_range_http_fetcher.h
  105. omaha_hash_calculator.cc
  106. omaha_hash_calculator.h
  107. omaha_hash_calculator_unittest.cc
  108. omaha_request_action.cc
  109. omaha_request_action.h
  110. omaha_request_action_unittest.cc
  111. omaha_request_params.cc
  112. omaha_request_params.h
  113. omaha_request_params_unittest.cc
  114. omaha_response.h
  115. omaha_response_handler_action.cc
  116. omaha_response_handler_action.h
  117. omaha_response_handler_action_unittest.cc
  118. OWNERS
  119. p2p_manager.cc
  120. p2p_manager.h
  121. p2p_manager_unittest.cc
  122. payload_constants.cc
  123. payload_constants.h
  124. payload_state.cc
  125. payload_state.h
  126. payload_state_interface.h
  127. payload_state_unittest.cc
  128. payload_verifier.cc
  129. payload_verifier.h
  130. postinstall_runner_action.cc
  131. postinstall_runner_action.h
  132. postinstall_runner_action_unittest.cc
  133. prefs.cc
  134. prefs.h
  135. prefs_interface.h
  136. prefs_unittest.cc
  137. proxy_resolver.cc
  138. proxy_resolver.h
  139. real_dbus_wrapper.h
  140. real_system_state.cc
  141. real_system_state.h
  142. run_unittests
  143. sample_omaha_v3_response.xml
  144. subprocess.cc
  145. subprocess.h
  146. subprocess_unittest.cc
  147. system_state.h
  148. terminator.cc
  149. terminator.h
  150. terminator_unittest.cc
  151. test_http_server.cc
  152. test_utils.cc
  153. test_utils.h
  154. test_utils_unittest.cc
  155. testrunner.cc
  156. unittest_key.pem
  157. unittest_key2.pem
  158. update_attempter.cc
  159. update_attempter.h
  160. update_attempter_unittest.cc
  161. update_engine.conf
  162. update_engine.gyp
  163. update_engine_client.cc
  164. update_metadata.proto
  165. UpdateEngine.conf
  166. utils.cc
  167. utils.h
  168. utils_unittest.cc
  169. WATCHLISTS
  170. zip_unittest.cc