conftest.py 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. from __future__ import absolute_import
  2. from __future__ import unicode_literals
  3. import pytest
  4. import tests.acceptance.cli_test
  5. # FIXME Skipping all the acceptance tests when in `--conformity`
  6. non_conformity_tests = [
  7. "test_build_failed",
  8. "test_build_failed_forcerm",
  9. "test_build_log_level",
  10. "test_build_memory_build_option",
  11. "test_build_no_cache",
  12. "test_build_no_cache_pull",
  13. "test_build_override_dir",
  14. "test_build_override_dir_invalid_path",
  15. "test_build_parallel",
  16. "test_build_plain",
  17. "test_build_pull",
  18. "test_build_rm",
  19. "test_build_shm_size_build_option",
  20. "test_build_with_buildarg_cli_override",
  21. "test_build_with_buildarg_from_compose_file",
  22. "test_build_with_buildarg_old_api_version",
  23. "test_config_compatibility_mode",
  24. "test_config_compatibility_mode_from_env",
  25. "test_config_compatibility_mode_from_env_and_option_precedence",
  26. "test_config_default",
  27. "test_config_external_network",
  28. "test_config_external_network_v3_5",
  29. "test_config_external_volume_v2",
  30. "test_config_external_volume_v2_x",
  31. "test_config_external_volume_v3_4",
  32. "test_config_external_volume_v3_x",
  33. "test_config_list_services",
  34. "test_config_list_volumes",
  35. "test_config_quiet",
  36. "test_config_quiet_with_error",
  37. "test_config_restart",
  38. "test_config_stdin",
  39. "test_config_v1",
  40. "test_config_v3",
  41. "test_config_with_dot_env",
  42. "test_config_with_dot_env_and_override_dir",
  43. "test_config_with_env_file",
  44. "test_config_with_hash_option",
  45. "test_create",
  46. "test_create_with_force_recreate",
  47. "test_create_with_force_recreate_and_no_recreate",
  48. "test_create_with_no_recreate",
  49. "test_down",
  50. "test_down_invalid_rmi_flag",
  51. "test_down_signal",
  52. "test_down_timeout",
  53. "test_env_file_relative_to_compose_file",
  54. "test_events_human_readable",
  55. "test_events_json",
  56. "test_exec_custom_user",
  57. "test_exec_detach_long_form",
  58. "test_exec_novalue_var_dotenv_file",
  59. "test_exec_service_with_environment_overridden",
  60. "test_exec_without_tty",
  61. "test_exec_workdir",
  62. "test_exit_code_from_signal_stop",
  63. "test_expanded_port",
  64. "test_forward_exitval",
  65. "test_help",
  66. "test_help_nonexistent",
  67. "test_home_and_env_var_in_volume_path",
  68. "test_host_not_reachable",
  69. "test_host_not_reachable_volumes_from_container",
  70. "test_host_not_reachable_volumes_from_container",
  71. "test_images",
  72. "test_images_default_composefile",
  73. "test_images_tagless_image",
  74. "test_images_use_service_tag",
  75. "test_kill",
  76. "test_kill_signal_sigstop",
  77. "test_kill_stopped_service",
  78. "test_logs_default",
  79. "test_logs_follow",
  80. "test_logs_follow_logs_from_new_containers",
  81. "test_logs_follow_logs_from_restarted_containers",
  82. "test_logs_invalid_service_name",
  83. "test_logs_on_stopped_containers_exits",
  84. "test_logs_tail",
  85. "test_logs_timestamps",
  86. "test_pause_no_containers",
  87. "test_pause_unpause",
  88. "test_port",
  89. "test_port_with_scale",
  90. "test_ps",
  91. "test_ps_all",
  92. "test_ps_alternate_composefile",
  93. "test_ps_default_composefile",
  94. "test_ps_services_filter_option",
  95. "test_ps_services_filter_status",
  96. "test_pull",
  97. "test_pull_can_build",
  98. "test_pull_with_digest",
  99. "test_pull_with_ignore_pull_failures",
  100. "test_pull_with_include_deps",
  101. "test_pull_with_no_deps",
  102. "test_pull_with_parallel_failure",
  103. "test_pull_with_quiet",
  104. "test_quiet_build",
  105. "test_restart",
  106. "test_restart_no_containers",
  107. "test_restart_stopped_container",
  108. "test_rm",
  109. "test_rm_all",
  110. "test_rm_stop",
  111. "test_run_detached_connects_to_network",
  112. "test_run_does_not_recreate_linked_containers",
  113. "test_run_env_values_from_system",
  114. "test_run_handles_sighup",
  115. "test_run_handles_sigint",
  116. "test_run_handles_sigterm",
  117. "test_run_interactive_connects_to_network",
  118. "test_run_label_flag",
  119. "test_run_one_off_with_multiple_volumes",
  120. "test_run_one_off_with_volume",
  121. "test_run_one_off_with_volume_merge",
  122. "test_run_rm",
  123. "test_run_service_with_compose_file_entrypoint",
  124. "test_run_service_with_compose_file_entrypoint_and_command_overridden",
  125. "test_run_service_with_compose_file_entrypoint_and_empty_string_command",
  126. "test_run_service_with_compose_file_entrypoint_overridden",
  127. "test_run_service_with_dependencies",
  128. "test_run_service_with_dockerfile_entrypoint",
  129. "test_run_service_with_dockerfile_entrypoint_and_command_overridden",
  130. "test_run_service_with_dockerfile_entrypoint_overridden",
  131. "test_run_service_with_environment_overridden",
  132. "test_run_service_with_explicitly_mapped_ip_ports",
  133. "test_run_service_with_explicitly_mapped_ports",
  134. "test_run_service_with_links",
  135. "test_run_service_with_map_ports",
  136. "test_run_service_with_scaled_dependencies",
  137. "test_run_service_with_unset_entrypoint",
  138. "test_run_service_with_use_aliases",
  139. "test_run_service_with_user_overridden",
  140. "test_run_service_with_user_overridden_short_form",
  141. "test_run_service_with_workdir_overridden",
  142. "test_run_service_with_workdir_overridden_short_form",
  143. "test_run_service_without_links",
  144. "test_run_service_without_map_ports",
  145. "test_run_unicode_env_values_from_system",
  146. "test_run_with_custom_name",
  147. "test_run_with_expose_ports",
  148. "test_run_with_no_deps",
  149. "test_run_without_command",
  150. "test_scale",
  151. "test_scale_v2_2",
  152. "test_shorthand_host_opt",
  153. "test_shorthand_host_opt_interactive",
  154. "test_start_no_containers",
  155. "test_stop",
  156. "test_stop_signal",
  157. "test_top_processes_running",
  158. "test_top_services_not_running",
  159. "test_top_services_running",
  160. "test_unpause_no_containers",
  161. "test_up",
  162. "test_up_attached",
  163. "test_up_detached",
  164. "test_up_detached_long_form",
  165. "test_up_external_networks",
  166. "test_up_handles_abort_on_container_exit",
  167. "test_up_handles_abort_on_container_exit_code",
  168. "test_up_handles_aborted_dependencies",
  169. "test_up_handles_force_shutdown",
  170. "test_up_handles_sigint",
  171. "test_up_handles_sigterm",
  172. "test_up_logging",
  173. "test_up_logging_legacy",
  174. "test_up_missing_network",
  175. "test_up_no_ansi",
  176. "test_up_no_services",
  177. "test_up_no_start",
  178. "test_up_no_start_remove_orphans",
  179. "test_up_scale_reset",
  180. "test_up_scale_scale_down",
  181. "test_up_scale_scale_up",
  182. "test_up_scale_to_zero",
  183. "test_up_with_attach_dependencies",
  184. "test_up_with_default_network_config",
  185. "test_up_with_default_override_file",
  186. "test_up_with_duplicate_override_yaml_files",
  187. "test_up_with_extends",
  188. "test_up_with_external_default_network",
  189. "test_up_with_force_recreate",
  190. "test_up_with_force_recreate_and_no_recreate",
  191. "test_up_with_healthcheck",
  192. "test_up_with_ignore_remove_orphans",
  193. "test_up_with_links_v1",
  194. "test_up_with_multiple_files",
  195. "test_up_with_net_is_invalid",
  196. "test_up_with_net_v1",
  197. "test_up_with_network_aliases",
  198. "test_up_with_network_internal",
  199. "test_up_with_network_labels",
  200. "test_up_with_network_mode",
  201. "test_up_with_network_static_addresses",
  202. "test_up_with_networks",
  203. "test_up_with_no_deps",
  204. "test_up_with_no_recreate",
  205. "test_up_with_override_yaml",
  206. "test_up_with_pid_mode",
  207. "test_up_with_timeout",
  208. "test_up_with_volume_labels",
  209. "test_fail_on_both_host_and_context_opt",
  210. "test_fail_run_on_inexistent_context",
  211. ]
  212. def pytest_addoption(parser):
  213. parser.addoption(
  214. "--conformity",
  215. action="store_true",
  216. default=False,
  217. help="Only runs tests that are not black listed as non conformity test. "
  218. "The conformity tests check for compatibility with the Compose spec."
  219. )
  220. parser.addoption(
  221. "--binary",
  222. default=tests.acceptance.cli_test.DOCKER_COMPOSE_EXECUTABLE,
  223. help="Forces the execution of a binary in the PATH. Default is `docker-compose`."
  224. )
  225. def pytest_collection_modifyitems(config, items):
  226. if not config.getoption("--conformity"):
  227. return
  228. if config.getoption("--binary"):
  229. tests.acceptance.cli_test.DOCKER_COMPOSE_EXECUTABLE = config.getoption("--binary")
  230. print("Binary -> {}".format(tests.acceptance.cli_test.DOCKER_COMPOSE_EXECUTABLE))
  231. skip_non_conformity = pytest.mark.skip(reason="skipping because that's not a conformity test")
  232. for item in items:
  233. if item.name in non_conformity_tests:
  234. print("Skipping '{}' when running in compatibility mode".format(item.name))
  235. item.add_marker(skip_non_conformity)