test_mysql.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. import logging
  2. import pytest
  3. from flexmock import flexmock
  4. from borgmatic.hooks import mysql as module
  5. def test_database_names_to_dump_passes_through_name():
  6. extra_environment = flexmock()
  7. log_prefix = ''
  8. names = module.database_names_to_dump(
  9. {'name': 'foo'}, extra_environment, log_prefix, dry_run=False
  10. )
  11. assert names == ('foo',)
  12. def test_database_names_to_dump_bails_for_dry_run():
  13. extra_environment = flexmock()
  14. log_prefix = ''
  15. flexmock(module).should_receive('execute_command_and_capture_output').never()
  16. names = module.database_names_to_dump(
  17. {'name': 'all'}, extra_environment, log_prefix, dry_run=True
  18. )
  19. assert names == ()
  20. def test_database_names_to_dump_queries_mysql_for_database_names():
  21. extra_environment = flexmock()
  22. log_prefix = ''
  23. flexmock(module).should_receive('execute_command_and_capture_output').with_args(
  24. ('mysql', '--skip-column-names', '--batch', '--execute', 'show schemas'),
  25. extra_environment=extra_environment,
  26. ).and_return('foo\nbar\nmysql\n').once()
  27. names = module.database_names_to_dump(
  28. {'name': 'all'}, extra_environment, log_prefix, dry_run=False
  29. )
  30. assert names == ('foo', 'bar')
  31. def test_use_streaming_true_for_any_databases():
  32. assert module.use_streaming(
  33. databases=[flexmock(), flexmock()], config=flexmock(), log_prefix=flexmock()
  34. )
  35. def test_use_streaming_false_for_no_databases():
  36. assert not module.use_streaming(databases=[], config=flexmock(), log_prefix=flexmock())
  37. def test_dump_data_sources_dumps_each_database():
  38. databases = [{'name': 'foo'}, {'name': 'bar'}]
  39. processes = [flexmock(), flexmock()]
  40. flexmock(module).should_receive('make_dump_path').and_return('')
  41. flexmock(module).should_receive('database_names_to_dump').and_return(('foo',)).and_return(
  42. ('bar',)
  43. )
  44. for name, process in zip(('foo', 'bar'), processes):
  45. flexmock(module).should_receive('execute_dump_command').with_args(
  46. database={'name': name},
  47. log_prefix=object,
  48. dump_path=object,
  49. database_names=(name,),
  50. extra_environment=object,
  51. dry_run=object,
  52. dry_run_label=object,
  53. ).and_return(process).once()
  54. assert (
  55. module.dump_data_sources(
  56. databases, {}, 'test.yaml', borgmatic_runtime_directory='/run/borgmatic', dry_run=False
  57. )
  58. == processes
  59. )
  60. def test_dump_data_sources_dumps_with_password():
  61. database = {'name': 'foo', 'username': 'root', 'password': 'trustsome1'}
  62. process = flexmock()
  63. flexmock(module).should_receive('make_dump_path').and_return('')
  64. flexmock(module).should_receive('database_names_to_dump').and_return(('foo',)).and_return(
  65. ('bar',)
  66. )
  67. flexmock(module).should_receive('execute_dump_command').with_args(
  68. database=database,
  69. log_prefix=object,
  70. dump_path=object,
  71. database_names=('foo',),
  72. extra_environment={'MYSQL_PWD': 'trustsome1'},
  73. dry_run=object,
  74. dry_run_label=object,
  75. ).and_return(process).once()
  76. assert module.dump_data_sources(
  77. [database], {}, 'test.yaml', borgmatic_runtime_directory='/run/borgmatic', dry_run=False
  78. ) == [process]
  79. def test_dump_data_sources_dumps_all_databases_at_once():
  80. databases = [{'name': 'all'}]
  81. process = flexmock()
  82. flexmock(module).should_receive('make_dump_path').and_return('')
  83. flexmock(module).should_receive('database_names_to_dump').and_return(('foo', 'bar'))
  84. flexmock(module).should_receive('execute_dump_command').with_args(
  85. database={'name': 'all'},
  86. log_prefix=object,
  87. dump_path=object,
  88. database_names=('foo', 'bar'),
  89. extra_environment=object,
  90. dry_run=object,
  91. dry_run_label=object,
  92. ).and_return(process).once()
  93. assert module.dump_data_sources(
  94. databases, {}, 'test.yaml', borgmatic_runtime_directory='/run/borgmatic', dry_run=False
  95. ) == [process]
  96. def test_dump_data_sources_dumps_all_databases_separately_when_format_configured():
  97. databases = [{'name': 'all', 'format': 'sql'}]
  98. processes = [flexmock(), flexmock()]
  99. flexmock(module).should_receive('make_dump_path').and_return('')
  100. flexmock(module).should_receive('database_names_to_dump').and_return(('foo', 'bar'))
  101. for name, process in zip(('foo', 'bar'), processes):
  102. flexmock(module).should_receive('execute_dump_command').with_args(
  103. database={'name': name, 'format': 'sql'},
  104. log_prefix=object,
  105. dump_path=object,
  106. database_names=(name,),
  107. extra_environment=object,
  108. dry_run=object,
  109. dry_run_label=object,
  110. ).and_return(process).once()
  111. assert (
  112. module.dump_data_sources(
  113. databases, {}, 'test.yaml', borgmatic_runtime_directory='/run/borgmatic', dry_run=False
  114. )
  115. == processes
  116. )
  117. def test_database_names_to_dump_runs_mysql_with_list_options():
  118. database = {'name': 'all', 'list_options': '--defaults-extra-file=my.cnf'}
  119. flexmock(module).should_receive('execute_command_and_capture_output').with_args(
  120. (
  121. 'mysql',
  122. '--defaults-extra-file=my.cnf',
  123. '--skip-column-names',
  124. '--batch',
  125. '--execute',
  126. 'show schemas',
  127. ),
  128. extra_environment=None,
  129. ).and_return(('foo\nbar')).once()
  130. assert module.database_names_to_dump(database, None, 'test.yaml', '') == ('foo', 'bar')
  131. def test_database_names_to_dump_runs_non_default_mysql_with_list_options():
  132. database = {
  133. 'name': 'all',
  134. 'list_options': '--defaults-extra-file=my.cnf',
  135. 'mysql_command': 'custom_mysql',
  136. }
  137. flexmock(module).should_receive('execute_command_and_capture_output').with_args(
  138. extra_environment=None,
  139. full_command=(
  140. 'custom_mysql', # Custom MySQL command
  141. '--defaults-extra-file=my.cnf',
  142. '--skip-column-names',
  143. '--batch',
  144. '--execute',
  145. 'show schemas',
  146. ),
  147. ).and_return(('foo\nbar')).once()
  148. assert module.database_names_to_dump(database, None, 'test.yaml', '') == ('foo', 'bar')
  149. def test_execute_dump_command_runs_mysqldump():
  150. process = flexmock()
  151. flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return('dump')
  152. flexmock(module.os.path).should_receive('exists').and_return(False)
  153. flexmock(module.dump).should_receive('create_named_pipe_for_dump')
  154. flexmock(module).should_receive('execute_command').with_args(
  155. (
  156. 'mysqldump',
  157. '--add-drop-database',
  158. '--databases',
  159. 'foo',
  160. '--result-file',
  161. 'dump',
  162. ),
  163. extra_environment=None,
  164. run_to_completion=False,
  165. ).and_return(process).once()
  166. assert (
  167. module.execute_dump_command(
  168. database={'name': 'foo'},
  169. log_prefix='log',
  170. dump_path=flexmock(),
  171. database_names=('foo',),
  172. extra_environment=None,
  173. dry_run=False,
  174. dry_run_label='',
  175. )
  176. == process
  177. )
  178. def test_execute_dump_command_runs_mysqldump_without_add_drop_database():
  179. process = flexmock()
  180. flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return('dump')
  181. flexmock(module.os.path).should_receive('exists').and_return(False)
  182. flexmock(module.dump).should_receive('create_named_pipe_for_dump')
  183. flexmock(module).should_receive('execute_command').with_args(
  184. (
  185. 'mysqldump',
  186. '--databases',
  187. 'foo',
  188. '--result-file',
  189. 'dump',
  190. ),
  191. extra_environment=None,
  192. run_to_completion=False,
  193. ).and_return(process).once()
  194. assert (
  195. module.execute_dump_command(
  196. database={'name': 'foo', 'add_drop_database': False},
  197. log_prefix='log',
  198. dump_path=flexmock(),
  199. database_names=('foo',),
  200. extra_environment=None,
  201. dry_run=False,
  202. dry_run_label='',
  203. )
  204. == process
  205. )
  206. def test_execute_dump_command_runs_mysqldump_with_hostname_and_port():
  207. process = flexmock()
  208. flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return('dump')
  209. flexmock(module.os.path).should_receive('exists').and_return(False)
  210. flexmock(module.dump).should_receive('create_named_pipe_for_dump')
  211. flexmock(module).should_receive('execute_command').with_args(
  212. (
  213. 'mysqldump',
  214. '--add-drop-database',
  215. '--host',
  216. 'database.example.org',
  217. '--port',
  218. '5433',
  219. '--protocol',
  220. 'tcp',
  221. '--databases',
  222. 'foo',
  223. '--result-file',
  224. 'dump',
  225. ),
  226. extra_environment=None,
  227. run_to_completion=False,
  228. ).and_return(process).once()
  229. assert (
  230. module.execute_dump_command(
  231. database={'name': 'foo', 'hostname': 'database.example.org', 'port': 5433},
  232. log_prefix='log',
  233. dump_path=flexmock(),
  234. database_names=('foo',),
  235. extra_environment=None,
  236. dry_run=False,
  237. dry_run_label='',
  238. )
  239. == process
  240. )
  241. def test_execute_dump_command_runs_mysqldump_with_username_and_password():
  242. process = flexmock()
  243. flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return('dump')
  244. flexmock(module.os.path).should_receive('exists').and_return(False)
  245. flexmock(module.dump).should_receive('create_named_pipe_for_dump')
  246. flexmock(module).should_receive('execute_command').with_args(
  247. (
  248. 'mysqldump',
  249. '--add-drop-database',
  250. '--user',
  251. 'root',
  252. '--databases',
  253. 'foo',
  254. '--result-file',
  255. 'dump',
  256. ),
  257. extra_environment={'MYSQL_PWD': 'trustsome1'},
  258. run_to_completion=False,
  259. ).and_return(process).once()
  260. assert (
  261. module.execute_dump_command(
  262. database={'name': 'foo', 'username': 'root', 'password': 'trustsome1'},
  263. log_prefix='log',
  264. dump_path=flexmock(),
  265. database_names=('foo',),
  266. extra_environment={'MYSQL_PWD': 'trustsome1'},
  267. dry_run=False,
  268. dry_run_label='',
  269. )
  270. == process
  271. )
  272. def test_execute_dump_command_runs_mysqldump_with_options():
  273. process = flexmock()
  274. flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return('dump')
  275. flexmock(module.os.path).should_receive('exists').and_return(False)
  276. flexmock(module.dump).should_receive('create_named_pipe_for_dump')
  277. flexmock(module).should_receive('execute_command').with_args(
  278. (
  279. 'mysqldump',
  280. '--stuff=such',
  281. '--add-drop-database',
  282. '--databases',
  283. 'foo',
  284. '--result-file',
  285. 'dump',
  286. ),
  287. extra_environment=None,
  288. run_to_completion=False,
  289. ).and_return(process).once()
  290. assert (
  291. module.execute_dump_command(
  292. database={'name': 'foo', 'options': '--stuff=such'},
  293. log_prefix='log',
  294. dump_path=flexmock(),
  295. database_names=('foo',),
  296. extra_environment=None,
  297. dry_run=False,
  298. dry_run_label='',
  299. )
  300. == process
  301. )
  302. def test_execute_dump_command_runs_non_default_mysqldump():
  303. process = flexmock()
  304. flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return('dump')
  305. flexmock(module.os.path).should_receive('exists').and_return(False)
  306. flexmock(module.dump).should_receive('create_named_pipe_for_dump')
  307. flexmock(module).should_receive('execute_command').with_args(
  308. (
  309. 'custom_mysqldump', # Custom MySQL dump command
  310. '--add-drop-database',
  311. '--databases',
  312. 'foo',
  313. '--result-file',
  314. 'dump',
  315. ),
  316. extra_environment=None,
  317. run_to_completion=False,
  318. ).and_return(process).once()
  319. assert (
  320. module.execute_dump_command(
  321. database={
  322. 'name': 'foo',
  323. 'mysql_dump_command': 'custom_mysqldump',
  324. }, # Custom MySQL dump command specified
  325. log_prefix='log',
  326. dump_path=flexmock(),
  327. database_names=('foo',),
  328. extra_environment=None,
  329. dry_run=False,
  330. dry_run_label='',
  331. )
  332. == process
  333. )
  334. def test_execute_dump_command_with_duplicate_dump_skips_mysqldump():
  335. flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return('dump')
  336. flexmock(module.os.path).should_receive('exists').and_return(True)
  337. flexmock(module.dump).should_receive('create_named_pipe_for_dump').never()
  338. flexmock(module).should_receive('execute_command').never()
  339. assert (
  340. module.execute_dump_command(
  341. database={'name': 'foo'},
  342. log_prefix='log',
  343. dump_path=flexmock(),
  344. database_names=('foo',),
  345. extra_environment=None,
  346. dry_run=True,
  347. dry_run_label='SO DRY',
  348. )
  349. is None
  350. )
  351. def test_execute_dump_command_with_dry_run_skips_mysqldump():
  352. flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return('dump')
  353. flexmock(module.os.path).should_receive('exists').and_return(False)
  354. flexmock(module.dump).should_receive('create_named_pipe_for_dump')
  355. flexmock(module).should_receive('execute_command').never()
  356. assert (
  357. module.execute_dump_command(
  358. database={'name': 'foo'},
  359. log_prefix='log',
  360. dump_path=flexmock(),
  361. database_names=('foo',),
  362. extra_environment=None,
  363. dry_run=True,
  364. dry_run_label='SO DRY',
  365. )
  366. is None
  367. )
  368. def test_dump_data_sources_errors_for_missing_all_databases():
  369. databases = [{'name': 'all'}]
  370. flexmock(module).should_receive('make_dump_path').and_return('')
  371. flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return(
  372. 'databases/localhost/all'
  373. )
  374. flexmock(module).should_receive('database_names_to_dump').and_return(())
  375. with pytest.raises(ValueError):
  376. assert module.dump_data_sources(
  377. databases, {}, 'test.yaml', borgmatic_runtime_directory='/run/borgmatic', dry_run=False
  378. )
  379. def test_dump_data_sources_does_not_error_for_missing_all_databases_with_dry_run():
  380. databases = [{'name': 'all'}]
  381. flexmock(module).should_receive('make_dump_path').and_return('')
  382. flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return(
  383. 'databases/localhost/all'
  384. )
  385. flexmock(module).should_receive('database_names_to_dump').and_return(())
  386. assert (
  387. module.dump_data_sources(
  388. databases, {}, 'test.yaml', borgmatic_runtime_directory='/run/borgmatic', dry_run=True
  389. )
  390. == []
  391. )
  392. def test_restore_data_source_dump_runs_mysql_to_restore():
  393. hook_config = [{'name': 'foo'}, {'name': 'bar'}]
  394. extract_process = flexmock(stdout=flexmock())
  395. flexmock(module).should_receive('execute_command_with_processes').with_args(
  396. ('mysql', '--batch'),
  397. processes=[extract_process],
  398. output_log_level=logging.DEBUG,
  399. input_file=extract_process.stdout,
  400. extra_environment=None,
  401. ).once()
  402. module.restore_data_source_dump(
  403. hook_config,
  404. {},
  405. 'test.yaml',
  406. data_source={'name': 'foo'},
  407. dry_run=False,
  408. extract_process=extract_process,
  409. connection_params={
  410. 'hostname': None,
  411. 'port': None,
  412. 'username': None,
  413. 'password': None,
  414. },
  415. )
  416. def test_restore_data_source_dump_runs_mysql_with_options():
  417. hook_config = [{'name': 'foo', 'restore_options': '--harder'}]
  418. extract_process = flexmock(stdout=flexmock())
  419. flexmock(module).should_receive('execute_command_with_processes').with_args(
  420. ('mysql', '--batch', '--harder'),
  421. processes=[extract_process],
  422. output_log_level=logging.DEBUG,
  423. input_file=extract_process.stdout,
  424. extra_environment=None,
  425. ).once()
  426. module.restore_data_source_dump(
  427. hook_config,
  428. {},
  429. 'test.yaml',
  430. data_source=hook_config[0],
  431. dry_run=False,
  432. extract_process=extract_process,
  433. connection_params={
  434. 'hostname': None,
  435. 'port': None,
  436. 'username': None,
  437. 'password': None,
  438. },
  439. )
  440. def test_restore_data_source_dump_runs_non_default_mysql_with_options():
  441. hook_config = [{'name': 'foo', 'mysql_command': 'custom_mysql', 'restore_options': '--harder'}]
  442. extract_process = flexmock(stdout=flexmock())
  443. flexmock(module).should_receive('execute_command_with_processes').with_args(
  444. ('custom_mysql', '--batch', '--harder'),
  445. processes=[extract_process],
  446. output_log_level=logging.DEBUG,
  447. input_file=extract_process.stdout,
  448. extra_environment=None,
  449. ).once()
  450. module.restore_data_source_dump(
  451. hook_config,
  452. {},
  453. 'test.yaml',
  454. data_source=hook_config[0],
  455. dry_run=False,
  456. extract_process=extract_process,
  457. connection_params={
  458. 'hostname': None,
  459. 'port': None,
  460. 'username': None,
  461. 'password': None,
  462. },
  463. )
  464. def test_restore_data_source_dump_runs_mysql_with_hostname_and_port():
  465. hook_config = [{'name': 'foo', 'hostname': 'database.example.org', 'port': 5433}]
  466. extract_process = flexmock(stdout=flexmock())
  467. flexmock(module).should_receive('execute_command_with_processes').with_args(
  468. (
  469. 'mysql',
  470. '--batch',
  471. '--host',
  472. 'database.example.org',
  473. '--port',
  474. '5433',
  475. '--protocol',
  476. 'tcp',
  477. ),
  478. processes=[extract_process],
  479. output_log_level=logging.DEBUG,
  480. input_file=extract_process.stdout,
  481. extra_environment=None,
  482. ).once()
  483. module.restore_data_source_dump(
  484. hook_config,
  485. {},
  486. 'test.yaml',
  487. data_source=hook_config[0],
  488. dry_run=False,
  489. extract_process=extract_process,
  490. connection_params={
  491. 'hostname': None,
  492. 'port': None,
  493. 'username': None,
  494. 'password': None,
  495. },
  496. )
  497. def test_restore_data_source_dump_runs_mysql_with_username_and_password():
  498. hook_config = [{'name': 'foo', 'username': 'root', 'password': 'trustsome1'}]
  499. extract_process = flexmock(stdout=flexmock())
  500. flexmock(module).should_receive('execute_command_with_processes').with_args(
  501. ('mysql', '--batch', '--user', 'root'),
  502. processes=[extract_process],
  503. output_log_level=logging.DEBUG,
  504. input_file=extract_process.stdout,
  505. extra_environment={'MYSQL_PWD': 'trustsome1'},
  506. ).once()
  507. module.restore_data_source_dump(
  508. hook_config,
  509. {},
  510. 'test.yaml',
  511. data_source=hook_config[0],
  512. dry_run=False,
  513. extract_process=extract_process,
  514. connection_params={
  515. 'hostname': None,
  516. 'port': None,
  517. 'username': None,
  518. 'password': None,
  519. },
  520. )
  521. def test_restore_data_source_dump_with_connection_params_uses_connection_params_for_restore():
  522. hook_config = [
  523. {
  524. 'name': 'foo',
  525. 'username': 'root',
  526. 'password': 'trustsome1',
  527. 'restore_hostname': 'restorehost',
  528. 'restore_port': 'restoreport',
  529. 'restore_username': 'restoreusername',
  530. 'restore_password': 'restorepassword',
  531. }
  532. ]
  533. extract_process = flexmock(stdout=flexmock())
  534. flexmock(module).should_receive('execute_command_with_processes').with_args(
  535. (
  536. 'mysql',
  537. '--batch',
  538. '--host',
  539. 'clihost',
  540. '--port',
  541. 'cliport',
  542. '--protocol',
  543. 'tcp',
  544. '--user',
  545. 'cliusername',
  546. ),
  547. processes=[extract_process],
  548. output_log_level=logging.DEBUG,
  549. input_file=extract_process.stdout,
  550. extra_environment={'MYSQL_PWD': 'clipassword'},
  551. ).once()
  552. module.restore_data_source_dump(
  553. hook_config,
  554. {},
  555. 'test.yaml',
  556. data_source={'name': 'foo'},
  557. dry_run=False,
  558. extract_process=extract_process,
  559. connection_params={
  560. 'hostname': 'clihost',
  561. 'port': 'cliport',
  562. 'username': 'cliusername',
  563. 'password': 'clipassword',
  564. },
  565. )
  566. def test_restore_data_source_dump_without_connection_params_uses_restore_params_in_config_for_restore():
  567. hook_config = [
  568. {
  569. 'name': 'foo',
  570. 'username': 'root',
  571. 'password': 'trustsome1',
  572. 'hostname': 'dbhost',
  573. 'port': 'dbport',
  574. 'restore_username': 'restoreuser',
  575. 'restore_password': 'restorepass',
  576. 'restore_hostname': 'restorehost',
  577. 'restore_port': 'restoreport',
  578. }
  579. ]
  580. extract_process = flexmock(stdout=flexmock())
  581. flexmock(module).should_receive('execute_command_with_processes').with_args(
  582. (
  583. 'mysql',
  584. '--batch',
  585. '--host',
  586. 'restorehost',
  587. '--port',
  588. 'restoreport',
  589. '--protocol',
  590. 'tcp',
  591. '--user',
  592. 'restoreuser',
  593. ),
  594. processes=[extract_process],
  595. output_log_level=logging.DEBUG,
  596. input_file=extract_process.stdout,
  597. extra_environment={'MYSQL_PWD': 'restorepass'},
  598. ).once()
  599. module.restore_data_source_dump(
  600. hook_config,
  601. {},
  602. 'test.yaml',
  603. data_source=hook_config[0],
  604. dry_run=False,
  605. extract_process=extract_process,
  606. connection_params={
  607. 'hostname': None,
  608. 'port': None,
  609. 'username': None,
  610. 'password': None,
  611. },
  612. )
  613. def test_restore_data_source_dump_with_dry_run_skips_restore():
  614. hook_config = [{'name': 'foo'}]
  615. flexmock(module).should_receive('execute_command_with_processes').never()
  616. module.restore_data_source_dump(
  617. hook_config,
  618. {},
  619. 'test.yaml',
  620. data_source={'name': 'foo'},
  621. dry_run=True,
  622. extract_process=flexmock(),
  623. connection_params={
  624. 'hostname': None,
  625. 'port': None,
  626. 'username': None,
  627. 'password': None,
  628. },
  629. )