test_mariadb.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. import logging
  2. import pytest
  3. from flexmock import flexmock
  4. from borgmatic.hooks import mariadb 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_mariadb_for_database_names():
  21. extra_environment = flexmock()
  22. log_prefix = ''
  23. flexmock(module).should_receive('execute_command_and_capture_output').with_args(
  24. ('mariadb', '--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_mariadb_with_list_options():
  118. database = {'name': 'all', 'list_options': '--defaults-extra-file=mariadb.cnf'}
  119. flexmock(module).should_receive('execute_command_and_capture_output').with_args(
  120. (
  121. 'mariadb',
  122. '--defaults-extra-file=mariadb.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_mariadb_with_list_options():
  132. database = {
  133. 'name': 'all',
  134. 'list_options': '--defaults-extra-file=mariadb.cnf',
  135. 'mariadb_command': 'custom_mariadb',
  136. }
  137. flexmock(module).should_receive('execute_command_and_capture_output').with_args(
  138. extra_environment=None,
  139. full_command=(
  140. 'custom_mariadb', # Custom MariaDB command
  141. '--defaults-extra-file=mariadb.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_mariadb_dump():
  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. 'mariadb-dump',
  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_mariadb_dump_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. 'mariadb-dump',
  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_mariadb_dump_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. 'mariadb-dump',
  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_mariadb_dump_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. 'mariadb-dump',
  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_mariadb_dump_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. 'mariadb-dump',
  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_mariadb_dump_with_options():
  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_mariadb_dump', # Custom MariaDB dump command
  310. '--stuff=such',
  311. '--add-drop-database',
  312. '--databases',
  313. 'foo',
  314. '--result-file',
  315. 'dump',
  316. ),
  317. extra_environment=None,
  318. run_to_completion=False,
  319. ).and_return(process).once()
  320. assert (
  321. module.execute_dump_command(
  322. database={
  323. 'name': 'foo',
  324. 'mariadb_dump_command': 'custom_mariadb_dump',
  325. 'options': '--stuff=such',
  326. }, # Custom MariaDB dump command specified
  327. log_prefix='log',
  328. dump_path=flexmock(),
  329. database_names=('foo',),
  330. extra_environment=None,
  331. dry_run=False,
  332. dry_run_label='',
  333. )
  334. == process
  335. )
  336. def test_execute_dump_command_with_duplicate_dump_skips_mariadb_dump():
  337. flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return('dump')
  338. flexmock(module.os.path).should_receive('exists').and_return(True)
  339. flexmock(module.dump).should_receive('create_named_pipe_for_dump').never()
  340. flexmock(module).should_receive('execute_command').never()
  341. assert (
  342. module.execute_dump_command(
  343. database={'name': 'foo'},
  344. log_prefix='log',
  345. dump_path=flexmock(),
  346. database_names=('foo',),
  347. extra_environment=None,
  348. dry_run=True,
  349. dry_run_label='SO DRY',
  350. )
  351. is None
  352. )
  353. def test_execute_dump_command_with_dry_run_skips_mariadb_dump():
  354. flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return('dump')
  355. flexmock(module.os.path).should_receive('exists').and_return(False)
  356. flexmock(module.dump).should_receive('create_named_pipe_for_dump')
  357. flexmock(module).should_receive('execute_command').never()
  358. assert (
  359. module.execute_dump_command(
  360. database={'name': 'foo'},
  361. log_prefix='log',
  362. dump_path=flexmock(),
  363. database_names=('foo',),
  364. extra_environment=None,
  365. dry_run=True,
  366. dry_run_label='SO DRY',
  367. )
  368. is None
  369. )
  370. def test_dump_data_sources_errors_for_missing_all_databases():
  371. databases = [{'name': 'all'}]
  372. flexmock(module).should_receive('make_dump_path').and_return('')
  373. flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return(
  374. 'databases/localhost/all'
  375. )
  376. flexmock(module).should_receive('database_names_to_dump').and_return(())
  377. with pytest.raises(ValueError):
  378. assert module.dump_data_sources(
  379. databases, {}, 'test.yaml', borgmatic_runtime_directory='/run/borgmatic', dry_run=False
  380. )
  381. def test_dump_data_sources_does_not_error_for_missing_all_databases_with_dry_run():
  382. databases = [{'name': 'all'}]
  383. flexmock(module).should_receive('make_dump_path').and_return('')
  384. flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return(
  385. 'databases/localhost/all'
  386. )
  387. flexmock(module).should_receive('database_names_to_dump').and_return(())
  388. assert (
  389. module.dump_data_sources(
  390. databases, {}, 'test.yaml', borgmatic_runtime_directory='/run/borgmatic', dry_run=True
  391. )
  392. == []
  393. )
  394. def test_restore_data_source_dump_runs_mariadb_to_restore():
  395. hook_config = [{'name': 'foo'}, {'name': 'bar'}]
  396. extract_process = flexmock(stdout=flexmock())
  397. flexmock(module).should_receive('execute_command_with_processes').with_args(
  398. ('mariadb', '--batch'),
  399. processes=[extract_process],
  400. output_log_level=logging.DEBUG,
  401. input_file=extract_process.stdout,
  402. extra_environment=None,
  403. ).once()
  404. module.restore_data_source_dump(
  405. hook_config,
  406. {},
  407. 'test.yaml',
  408. data_source={'name': 'foo'},
  409. dry_run=False,
  410. extract_process=extract_process,
  411. connection_params={
  412. 'hostname': None,
  413. 'port': None,
  414. 'username': None,
  415. 'password': None,
  416. },
  417. )
  418. def test_restore_data_source_dump_runs_mariadb_with_options():
  419. hook_config = [{'name': 'foo', 'restore_options': '--harder'}]
  420. extract_process = flexmock(stdout=flexmock())
  421. flexmock(module).should_receive('execute_command_with_processes').with_args(
  422. ('mariadb', '--batch', '--harder'),
  423. processes=[extract_process],
  424. output_log_level=logging.DEBUG,
  425. input_file=extract_process.stdout,
  426. extra_environment=None,
  427. ).once()
  428. module.restore_data_source_dump(
  429. hook_config,
  430. {},
  431. 'test.yaml',
  432. data_source=hook_config[0],
  433. dry_run=False,
  434. extract_process=extract_process,
  435. connection_params={
  436. 'hostname': None,
  437. 'port': None,
  438. 'username': None,
  439. 'password': None,
  440. },
  441. )
  442. def test_restore_data_source_dump_runs_non_default_mariadb_with_options():
  443. hook_config = [
  444. {'name': 'foo', 'restore_options': '--harder', 'mariadb_command': 'custom_mariadb'}
  445. ]
  446. extract_process = flexmock(stdout=flexmock())
  447. flexmock(module).should_receive('execute_command_with_processes').with_args(
  448. ('custom_mariadb', '--batch', '--harder'),
  449. processes=[extract_process],
  450. output_log_level=logging.DEBUG,
  451. input_file=extract_process.stdout,
  452. extra_environment=None,
  453. ).once()
  454. module.restore_data_source_dump(
  455. hook_config,
  456. {},
  457. 'test.yaml',
  458. data_source=hook_config[0],
  459. dry_run=False,
  460. extract_process=extract_process,
  461. connection_params={
  462. 'hostname': None,
  463. 'port': None,
  464. 'username': None,
  465. 'password': None,
  466. },
  467. )
  468. def test_restore_data_source_dump_runs_mariadb_with_hostname_and_port():
  469. hook_config = [{'name': 'foo', 'hostname': 'database.example.org', 'port': 5433}]
  470. extract_process = flexmock(stdout=flexmock())
  471. flexmock(module).should_receive('execute_command_with_processes').with_args(
  472. (
  473. 'mariadb',
  474. '--batch',
  475. '--host',
  476. 'database.example.org',
  477. '--port',
  478. '5433',
  479. '--protocol',
  480. 'tcp',
  481. ),
  482. processes=[extract_process],
  483. output_log_level=logging.DEBUG,
  484. input_file=extract_process.stdout,
  485. extra_environment=None,
  486. ).once()
  487. module.restore_data_source_dump(
  488. hook_config,
  489. {},
  490. 'test.yaml',
  491. data_source=hook_config[0],
  492. dry_run=False,
  493. extract_process=extract_process,
  494. connection_params={
  495. 'hostname': None,
  496. 'port': None,
  497. 'username': None,
  498. 'password': None,
  499. },
  500. )
  501. def test_restore_data_source_dump_runs_mariadb_with_username_and_password():
  502. hook_config = [{'name': 'foo', 'username': 'root', 'password': 'trustsome1'}]
  503. extract_process = flexmock(stdout=flexmock())
  504. flexmock(module).should_receive('execute_command_with_processes').with_args(
  505. ('mariadb', '--batch', '--user', 'root'),
  506. processes=[extract_process],
  507. output_log_level=logging.DEBUG,
  508. input_file=extract_process.stdout,
  509. extra_environment={'MYSQL_PWD': 'trustsome1'},
  510. ).once()
  511. module.restore_data_source_dump(
  512. hook_config,
  513. {},
  514. 'test.yaml',
  515. data_source=hook_config[0],
  516. dry_run=False,
  517. extract_process=extract_process,
  518. connection_params={
  519. 'hostname': None,
  520. 'port': None,
  521. 'username': None,
  522. 'password': None,
  523. },
  524. )
  525. def test_restore_data_source_dump_with_connection_params_uses_connection_params_for_restore():
  526. hook_config = [
  527. {
  528. 'name': 'foo',
  529. 'username': 'root',
  530. 'password': 'trustsome1',
  531. 'restore_hostname': 'restorehost',
  532. 'restore_port': 'restoreport',
  533. 'restore_username': 'restoreusername',
  534. 'restore_password': 'restorepassword',
  535. }
  536. ]
  537. extract_process = flexmock(stdout=flexmock())
  538. flexmock(module).should_receive('execute_command_with_processes').with_args(
  539. (
  540. 'mariadb',
  541. '--batch',
  542. '--host',
  543. 'clihost',
  544. '--port',
  545. 'cliport',
  546. '--protocol',
  547. 'tcp',
  548. '--user',
  549. 'cliusername',
  550. ),
  551. processes=[extract_process],
  552. output_log_level=logging.DEBUG,
  553. input_file=extract_process.stdout,
  554. extra_environment={'MYSQL_PWD': 'clipassword'},
  555. ).once()
  556. module.restore_data_source_dump(
  557. hook_config,
  558. {},
  559. 'test.yaml',
  560. data_source=hook_config[0],
  561. dry_run=False,
  562. extract_process=extract_process,
  563. connection_params={
  564. 'hostname': 'clihost',
  565. 'port': 'cliport',
  566. 'username': 'cliusername',
  567. 'password': 'clipassword',
  568. },
  569. )
  570. def test_restore_data_source_dump_without_connection_params_uses_restore_params_in_config_for_restore():
  571. hook_config = [
  572. {
  573. 'name': 'foo',
  574. 'username': 'root',
  575. 'password': 'trustsome1',
  576. 'hostname': 'dbhost',
  577. 'port': 'dbport',
  578. 'restore_username': 'restoreuser',
  579. 'restore_password': 'restorepass',
  580. 'restore_hostname': 'restorehost',
  581. 'restore_port': 'restoreport',
  582. }
  583. ]
  584. extract_process = flexmock(stdout=flexmock())
  585. flexmock(module).should_receive('execute_command_with_processes').with_args(
  586. (
  587. 'mariadb',
  588. '--batch',
  589. '--host',
  590. 'restorehost',
  591. '--port',
  592. 'restoreport',
  593. '--protocol',
  594. 'tcp',
  595. '--user',
  596. 'restoreuser',
  597. ),
  598. processes=[extract_process],
  599. output_log_level=logging.DEBUG,
  600. input_file=extract_process.stdout,
  601. extra_environment={'MYSQL_PWD': 'restorepass'},
  602. ).once()
  603. module.restore_data_source_dump(
  604. hook_config,
  605. {},
  606. 'test.yaml',
  607. data_source=hook_config[0],
  608. dry_run=False,
  609. extract_process=extract_process,
  610. connection_params={
  611. 'hostname': None,
  612. 'port': None,
  613. 'username': None,
  614. 'password': None,
  615. },
  616. )
  617. def test_restore_data_source_dump_with_dry_run_skips_restore():
  618. hook_config = [{'name': 'foo'}]
  619. flexmock(module).should_receive('execute_command_with_processes').never()
  620. module.restore_data_source_dump(
  621. hook_config,
  622. {},
  623. 'test.yaml',
  624. data_source={'name': 'foo'},
  625. dry_run=True,
  626. extract_process=flexmock(),
  627. connection_params={
  628. 'hostname': None,
  629. 'port': None,
  630. 'username': None,
  631. 'password': None,
  632. },
  633. )