forked from scylladb/scylla-cluster-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmgmt_cli_test.py
More file actions
1397 lines (1209 loc) · 69.1 KB
/
mgmt_cli_test.py
File metadata and controls
1397 lines (1209 loc) · 69.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See LICENSE for more details.
#
# Copyright (c) 2016 ScyllaDB
import random
import threading
import time
from datetime import timedelta
from sdcm import mgmt
from sdcm.argus_results import (
send_manager_benchmark_results_to_argus,
send_manager_snapshot_details_to_argus,
ManagerRestoreBenchmarkResult,
ManagerOneOneRestoreBenchmarkResult,
)
from sdcm.mgmt import ScyllaManagerError, TaskStatus, HostStatus, HostSsl, HostRestStatus
from sdcm.mgmt.argus_report import report_to_argus, ManagerReportType
from sdcm.mgmt.cli import RestoreTask
from sdcm.mgmt.common import (
reconfigure_scylla_manager,
get_persistent_snapshots,
get_backup_size,
ObjectStorageUploadMode,
)
from sdcm.provision.helpers.certificate import TLSAssets
from sdcm.nemesis.monkey import MgmtRepair
from sdcm.utils.adaptive_timeouts import adaptive_timeout, Operations
from sdcm.utils.alternator.table_setup import alternator_backuped_tables
from sdcm.utils.aws_utils import AwsIAM
from sdcm.utils.features import is_tablets_feature_enabled
from sdcm.utils.common import reach_enospc_on_node, clean_enospc_on_node
from sdcm.utils.time_utils import ExecutionTimer
from sdcm.mgmt.operations import ManagerTestFunctionsMixIn, SnapshotData
from sdcm.sct_events.system import InfoEvent
from sdcm.sct_events.group_common_events import ignore_no_space_errors, ignore_stream_mutation_fragments_errors
from sdcm.utils.tablets.common import TabletsConfiguration
class ManagerRestoreTests(ManagerTestFunctionsMixIn):
def test_restore_multiple_backup_snapshots(self): # noqa: PLR0914
mgr_cluster = self.db_cluster.get_cluster_manager()
cluster_backend = self.params.get("cluster_backend")
if cluster_backend != "aws":
self.log.error("Test supports only AWS ATM")
return
persistent_manager_snapshots_dict = get_persistent_snapshots()
region = next(iter(self.params.region_names), "")
target_bucket = persistent_manager_snapshots_dict[cluster_backend]["bucket"].format(region=region)
backup_bucket_backend = self.params.get("backup_bucket_backend")
location_list = [f"{backup_bucket_backend}:{target_bucket}"]
confirmation_stress_template = persistent_manager_snapshots_dict[cluster_backend][
"confirmation_stress_template"
]
read_stress_list = []
snapshot_sizes = persistent_manager_snapshots_dict[cluster_backend]["snapshots_sizes"]
for size in snapshot_sizes:
number_of_rows = persistent_manager_snapshots_dict[cluster_backend]["snapshots_sizes"][size][
"number_of_rows"
]
expected_timeout = persistent_manager_snapshots_dict[cluster_backend]["snapshots_sizes"][size][
"expected_timeout"
]
snapshot_dict = persistent_manager_snapshots_dict[cluster_backend]["snapshots_sizes"][size]["snapshots"]
snapshot_tag = random.choice(list(snapshot_dict.keys()))
keyspace_name = snapshot_dict[snapshot_tag]["keyspace_name"]
self.restore_backup_with_task(
mgr_cluster=mgr_cluster,
snapshot_tag=snapshot_tag,
timeout=180,
restore_schema=True,
location_list=location_list,
)
self.restore_backup_with_task(
mgr_cluster=mgr_cluster,
snapshot_tag=snapshot_tag,
timeout=expected_timeout,
restore_data=True,
location_list=location_list,
)
stress_command = confirmation_stress_template.format(
num_of_rows=number_of_rows, keyspace_name=keyspace_name, sequence_start=1, sequence_end=number_of_rows
)
read_stress_list.append(stress_command)
for stress in read_stress_list:
read_thread = self.run_stress_thread(stress_cmd=stress, round_robin=False)
self.verify_stress_thread(read_thread)
def test_restore_backup_with_task(self, ks_names: list = None):
self.log.info("starting test_restore_backup_with_task")
mgr_cluster = self.db_cluster.get_cluster_manager()
if not ks_names:
ks_names = ["keyspace1"]
backup_task = mgr_cluster.create_backup_task(location_list=self.locations, keyspace_list=ks_names)
backup_task_status = backup_task.wait_and_get_final_status(timeout=1500)
assert backup_task_status == TaskStatus.DONE, (
f"Backup task ended in {backup_task_status} instead of {TaskStatus.DONE}"
)
soft_timeout = 36 * 60
hard_timeout = 50 * 60
with adaptive_timeout(Operations.MGMT_REPAIR, self.db_cluster.data_nodes[0], timeout=soft_timeout):
self.verify_backup_success(
mgr_cluster=mgr_cluster,
backup_task=backup_task,
ks_names=ks_names,
restore_data_with_task=True,
timeout=hard_timeout,
)
self.run_verification_read_stress(ks_names)
mgr_cluster.delete() # remove cluster at the end of the test
self.log.info("finishing test_restore_backup_with_task")
def test_restore_alternator_backup_with_task(self, delete_tables: list = None):
self.log.info("starting test_restore_alternator_backup_with_task")
mgr_cluster = self.db_cluster.get_cluster_manager(
alternator_credentials=self.alternator.get_credentials(node=self.db_cluster.nodes[0])
)
backup_task = mgr_cluster.create_backup_task(location_list=self.locations)
backup_task_status = backup_task.wait_and_get_final_status(timeout=1500)
assert backup_task_status == TaskStatus.DONE, (
f"Backup task ended in {backup_task_status} instead of {TaskStatus.DONE}"
)
soft_timeout = 36 * 60
hard_timeout = 50 * 60
with adaptive_timeout(Operations.MGMT_REPAIR, self.db_cluster.data_nodes[0], timeout=soft_timeout):
self.verify_alternator_backup_success(
mgr_cluster=mgr_cluster, backup_task=backup_task, delete_tables=delete_tables, timeout=hard_timeout
)
mgr_cluster.delete() # remove cluster at the end of the test
self.log.info("finishing test_restore_alternator_backup_with_task")
class ManagerBackupTests(ManagerRestoreTests):
def test_basic_backup(self, ks_names: list = None):
self.log.info("starting test_basic_backup")
mgr_cluster = self.db_cluster.get_cluster_manager()
backup_task = mgr_cluster.create_backup_task(location_list=self.locations)
backup_task_status = backup_task.wait_and_get_final_status(timeout=1500)
assert backup_task_status == TaskStatus.DONE, (
f"Backup task ended in {backup_task_status} instead of {TaskStatus.DONE}"
)
# Do restore with a task for multiDC clusters, otherwise the test will take a long time
restore_with_task = True if self.db_node.test_config.MULTI_REGION else False
self.verify_backup_success(
mgr_cluster=mgr_cluster,
backup_task=backup_task,
ks_names=ks_names,
restore_data_with_task=restore_with_task,
)
self.run_verification_read_stress(ks_names)
mgr_cluster.delete() # remove cluster at the end of the test
self.log.info("finishing test_basic_backup")
def test_backup_multiple_ks_tables(self):
self.log.info("starting test_backup_multiple_ks_tables")
mgr_cluster = self.db_cluster.get_cluster_manager()
tables = self.create_ks_and_tables(10, 100)
self.log.debug("tables list = {}".format(tables))
# TODO: insert data to those tables
backup_task = mgr_cluster.create_backup_task(location_list=self.locations)
backup_task_status = backup_task.wait_and_get_final_status(timeout=1500)
assert backup_task_status == TaskStatus.DONE, (
f"Backup task ended in {backup_task_status} instead of {TaskStatus.DONE}"
)
self.verify_backup_success(mgr_cluster=mgr_cluster, backup_task=backup_task)
self.log.info("finishing test_backup_multiple_ks_tables")
def test_backup_location_with_path(self):
self.log.info("starting test_backup_location_with_path")
mgr_cluster = self.db_cluster.get_cluster_manager()
try:
mgr_cluster.create_backup_task(location_list=[f"{location}/path_testing/" for location in self.locations])
except ScyllaManagerError as error:
self.log.info("Expected to fail - error: {}".format(error))
self.log.info("finishing test_backup_location_with_path")
def test_backup_rate_limit(self):
self.log.info("starting test_backup_rate_limit")
mgr_cluster = self.db_cluster.get_cluster_manager()
rate_limit_list = [f"{dc}:{random.randint(15, 25)}" for dc in self.get_all_dcs_names()]
self.log.info("rate limit will be {}".format(rate_limit_list))
backup_task = mgr_cluster.create_backup_task(location_list=self.locations, rate_limit_list=rate_limit_list)
task_status = backup_task.wait_and_get_final_status(timeout=18000)
assert task_status == TaskStatus.DONE, (
f"Task {backup_task.id} did not end successfully:\n{backup_task.detailed_progress}"
)
self.log.info("backup task finished with status {}".format(task_status))
# TODO: verify that the rate limit is as set in the cmd
self.verify_backup_success(mgr_cluster=mgr_cluster, backup_task=backup_task)
self.log.info("finishing test_backup_rate_limit")
def test_backup_purge_removes_orphan_files(self):
"""
The test stops a backup task mid-upload, so that orphan files will remain in the destination bucket.
Afterwards, the test reruns the backup task from scratch (with the --no-continue flag, so it's practically
a new task) and after the task concludes (successfully) the test makes sure the manager has deleted the
previously mentioned orphan files from the bucket.
"""
self.log.info("starting test_backup_purge_removes_orphan_files")
mgr_cluster = self.db_cluster.get_cluster_manager()
snapshot_file_list_pre_test = self.get_all_snapshot_files(cluster_id=mgr_cluster.id)
backup_task = mgr_cluster.create_backup_task(location_list=self.locations, retention=1)
backup_task.wait_for_uploading_stage(step=5)
backup_task.stop()
snapshot_file_list_post_task_stopping = self.get_all_snapshot_files(cluster_id=mgr_cluster.id)
orphan_files_pre_rerun = snapshot_file_list_post_task_stopping.difference(snapshot_file_list_pre_test)
assert orphan_files_pre_rerun, "SCT could not create orphan snapshots by stopping a backup task"
# So that the files' names will be different form the previous ones,
# and they won't simply replace the previous files in the bucket
for node in self.db_cluster.nodes:
node.run_nodetool("compact")
backup_task.start(continue_task=False)
backup_task.wait_and_get_final_status(step=10)
snapshot_file_list_post_purge = self.get_all_snapshot_files(cluster_id=mgr_cluster.id)
orphan_files_post_rerun = snapshot_file_list_post_purge.intersection(orphan_files_pre_rerun)
assert not orphan_files_post_rerun, "orphan files were not deleted!"
self.log.info("finishing test_backup_purge_removes_orphan_files")
def test_enospc_during_backup(self):
self.log.info("starting test_enospc_during_backup")
mgr_cluster = self.db_cluster.get_cluster_manager()
# deleting previous snapshots so that the current backup will last longer
previous_backup_tasks = mgr_cluster.backup_task_list
for backup_task in previous_backup_tasks:
backup_task.delete_backup_snapshot()
target_node = self.db_cluster.nodes[1]
with ignore_no_space_errors(node=target_node):
try:
backup_task = mgr_cluster.create_backup_task(location_list=self.locations)
backup_task.wait_for_uploading_stage()
backup_task.stop()
reach_enospc_on_node(target_node=target_node)
backup_task.start()
backup_task.wait_and_get_final_status()
assert backup_task.status == TaskStatus.DONE, (
"The backup failed to run on a node with no free space,"
" while it should have had the room for snapshots due "
"to the previous run"
)
finally:
clean_enospc_on_node(target_node=target_node, sleep_time=30)
self.log.info("finishing test_enospc_during_backup")
def test_enospc_before_restore(self):
if is_tablets_feature_enabled(self.db_cluster.nodes[0]):
# TODO: Get back to this restriction after https://github.com/scylladb/scylla-manager/issues/4275 resolution
self.log.info(
"Skipping test_enospc_before_restore due to enabled tablets. "
"For details https://github.com/scylladb/scylla-manager/issues/4276"
)
return
self.log.info("starting test_enospc_before_restore")
mgr_cluster = self.db_cluster.get_cluster_manager()
backup_task = mgr_cluster.create_backup_task(location_list=self.locations, keyspace_list=["keyspace1"])
backup_task_status = backup_task.wait_and_get_final_status(timeout=1500)
assert backup_task_status == TaskStatus.DONE, (
f"Backup task ended in {backup_task_status} instead of {TaskStatus.DONE}"
)
target_node = self.db_cluster.nodes[1]
with ignore_no_space_errors(node=target_node), ignore_stream_mutation_fragments_errors():
try:
reach_enospc_on_node(target_node=target_node)
snapshot_tag = backup_task.get_snapshot_tag()
restore_task = mgr_cluster.create_restore_task(
restore_data=True, location_list=self.locations, snapshot_tag=snapshot_tag
)
final_status = restore_task.wait_and_get_final_status(step=30)
assert final_status == TaskStatus.ERROR, (
f"The restore task is supposed to fail, since node {target_node} lacks the disk space to download"
f"the snapshot files"
)
finally:
clean_enospc_on_node(target_node=target_node, sleep_time=30)
self.log.info("finishing test_enospc_before_restore")
def test_backup_feature(self):
self.generate_load_and_wait_for_results()
with self.subTest("Backup Multiple KS' and Tables"):
self.test_backup_multiple_ks_tables()
with self.subTest("Backup to Location with path"):
self.test_backup_location_with_path()
with self.subTest("Test Backup Rate Limit"):
self.test_backup_rate_limit()
with self.subTest("Test Backup Purge Removes Orphans Files"):
self.test_backup_purge_removes_orphan_files()
with self.subTest("Test restore a backup with restore task"):
self.test_restore_backup_with_task()
with self.subTest("Test Backup end of space"): # Preferably at the end
self.test_enospc_during_backup()
with self.subTest("Test Restore end of space"):
self.test_enospc_before_restore()
def test_alternator_backup_feature(self):
test_table_config = self.params.get("alternator_test_table") or {}
features = {
"lsi": test_table_config.get("lsi_name", None),
"gsi": test_table_config.get("gsi_name", None),
"tags": test_table_config.get("tags", None),
}
target_node = self.db_cluster.nodes[0]
with alternator_backuped_tables(target_node, self.alternator, params=self.params, **features) as tables:
self.alternator.verify_tables_features(node=target_node, tables=tables, **features)
self.generate_load_and_wait_for_results()
with self.subTest("Test restore alternator backup with restore task"):
self.test_restore_alternator_backup_with_task(delete_tables=tables.keys())
self.alternator.verify_tables_features(
node=target_node,
tables=tables,
wait_for_item_count=test_table_config.get("items", None),
**features,
)
self.run_verification_read_stress()
def test_no_delta_backup_at_disabled_compaction(self):
"""The purpose of test is to check that delta backup (no changes to DB between backups) takes time -> 0.
Important test precondition is to disable compaction on all nodes in the cluster.
Otherwise, new set of SSTables is created what ends up in the situation that almost no deduplication is applied.
For more details https://github.com/scylladb/scylla-manager/issues/3936#issuecomment-2277611709
"""
self.log.info("starting test_consecutive_backups")
self.log.info("Run write stress")
self.run_prepare_write_cmd()
self.log.info("Disable compaction for every node in the cluster")
self.disable_compaction()
self.log.info("Prepare Manager")
mgr_cluster = self.db_cluster.get_cluster_manager(force_add=True)
self.log.info("Run backup #1")
backup_task_1 = mgr_cluster.create_backup_task(location_list=self.locations)
backup_task_1_status = backup_task_1.wait_and_get_final_status(timeout=3600)
assert backup_task_1_status == TaskStatus.DONE, (
f"Backup task ended in {backup_task_1_status} instead of {TaskStatus.DONE}"
)
self.log.info(f"Backup task #1 duration - {backup_task_1.duration}")
self.log.info("Run backup #2")
backup_task_2 = mgr_cluster.create_backup_task(location_list=self.locations)
backup_task_2_status = backup_task_2.wait_and_get_final_status(timeout=60)
assert backup_task_2_status == TaskStatus.DONE, (
f"Backup task ended in {backup_task_2_status} instead of {TaskStatus.DONE}"
)
self.log.info(f"Backup task #2 duration - {backup_task_2.duration}")
assert backup_task_2.duration < timedelta(seconds=15), "No-delta backup took more than 15 seconds"
self.log.info("Verify restore from backup #2")
self.verify_backup_success(
mgr_cluster=mgr_cluster, backup_task=backup_task_2, restore_data_with_task=True, timeout=3600
)
self.log.info("Run verification read stress")
self.run_verification_read_stress()
self.log.info("finishing test_consecutive_backups")
class ManagerRepairTests(ManagerTestFunctionsMixIn):
LOCALSTRATEGY_KEYSPACE_NAME = "localstrategy_keyspace"
NETWORKSTRATEGY_KEYSPACE_NAME = "networkstrategy_keyspace"
def _test_intensity_and_parallel(self, fault_multiple_nodes):
keyspace_to_be_repaired = "keyspace2"
InfoEvent(message="starting test_intensity_and_parallel").publish()
manager_tool = mgmt.get_scylla_manager_tool(manager_node=self.monitors.nodes[0])
mgr_cluster = manager_tool.add_cluster(
name=self.CLUSTER_NAME + "_intensity_and_parallel",
db_cluster=self.db_cluster,
auth_token=self.monitors.mgmt_auth_token,
)
InfoEvent(message="Starting faulty load (to be repaired)").publish()
self.create_missing_rows_in_cluster(
create_missing_rows_in_multiple_nodes=fault_multiple_nodes,
keyspace_to_be_repaired=keyspace_to_be_repaired,
total_num_of_rows=29296872,
)
InfoEvent(message="Starting a repair with no intensity").publish()
base_repair_task = mgr_cluster.create_repair_task(keyspace="keyspace*")
base_repair_task.wait_and_get_final_status(step=30)
assert base_repair_task.status == TaskStatus.DONE, "The base repair task did not end in the expected time"
InfoEvent(message=f"The base repair, with no intensity argument, took {base_repair_task.duration}").publish()
with self.db_cluster.cql_connection_patient(self.db_cluster.nodes[0]) as session:
session.execute(f"DROP KEYSPACE IF EXISTS {keyspace_to_be_repaired}")
arg_list = [
{"intensity": 0.5},
{"intensity": 0.25},
{"intensity": 0.0001},
{"intensity": 2},
{"intensity": 4},
{"parallel": 1},
{"parallel": 2},
{"intensity": 2, "parallel": 1},
{"intensity": 100},
{"intensity": 0},
]
for arg_dict in arg_list:
InfoEvent(message="Starting faulty load (to be repaired)").publish()
self.create_missing_rows_in_cluster(
create_missing_rows_in_multiple_nodes=fault_multiple_nodes,
keyspace_to_be_repaired=keyspace_to_be_repaired,
total_num_of_rows=29296872,
)
InfoEvent(message=f"Starting a repair with {arg_dict}").publish()
repair_task = mgr_cluster.create_repair_task(**arg_dict, keyspace="keyspace*")
repair_task.wait_and_get_final_status(step=30)
InfoEvent(message=f"repair with {arg_dict} took {repair_task.duration}").publish()
with self.db_cluster.cql_connection_patient(self.db_cluster.nodes[0]) as session:
session.execute(f"DROP KEYSPACE IF EXISTS {keyspace_to_be_repaired}")
InfoEvent(message="finishing test_intensity_and_parallel").publish()
def test_repair_intensity_feature(self, fault_multiple_nodes):
InfoEvent(message="Starting C-S write load").publish()
self.run_prepare_write_cmd()
InfoEvent(message="Flushing").publish()
for node in self.db_cluster.nodes:
node.run_nodetool("flush")
InfoEvent(message="Waiting for compactions to end").publish()
self.wait_no_compactions_running(n=30, sleep_time=30)
InfoEvent(message="Starting C-S read load").publish()
stress_read_thread = self.generate_background_read_load()
time.sleep(600) # So we will see the base load of the cluster
InfoEvent(message="Sleep ended - Starting tests").publish()
with self.subTest("test_intensity_and_parallel"):
self._test_intensity_and_parallel(fault_multiple_nodes=fault_multiple_nodes)
load_results = stress_read_thread.get_results()
self.log.info("load={}".format(load_results))
def test_repair_multiple_keyspace_types(self):
self.log.info("starting test_repair_multiple_keyspace_types")
manager_tool = mgmt.get_scylla_manager_tool(manager_node=self.monitors.nodes[0])
mgr_cluster = self.db_cluster.get_cluster_manager()
rf = self.get_rf_based_on_nodes_number() if self.db_node.test_config.MULTI_REGION else 3
self.create_keyspace_and_basic_table(self.NETWORKSTRATEGY_KEYSPACE_NAME, replication_factor=rf)
self.create_keyspace_and_basic_table(self.LOCALSTRATEGY_KEYSPACE_NAME, replication_factor=0)
repair_task = mgr_cluster.create_repair_task()
task_final_status = repair_task.wait_and_get_final_status(timeout=7200)
assert task_final_status == TaskStatus.DONE, "Task: {} final status is: {}.".format(
repair_task.id, str(repair_task.status)
)
self.log.info("Task: {} is done.".format(repair_task.id))
self.log.debug("sctool version is : {}".format(manager_tool.sctool.version))
expected_keyspaces_to_be_repaired = ["system_distributed", self.NETWORKSTRATEGY_KEYSPACE_NAME]
if not self.db_cluster.nodes[0].raft.is_consistent_topology_changes_enabled:
expected_keyspaces_to_be_repaired.append("system_auth")
self.log.debug("Keyspaces expected to be repaired: {}".format(expected_keyspaces_to_be_repaired))
per_keyspace_progress = repair_task.per_keyspace_progress
self.log.info("Looking in the repair output for all of the required keyspaces")
for keyspace_name in expected_keyspaces_to_be_repaired:
keyspace_repair_percentage = per_keyspace_progress.get(keyspace_name, None)
assert keyspace_repair_percentage is not None, "The keyspace {} was not included in the repair!".format(
keyspace_name
)
assert keyspace_repair_percentage == 100, "The repair of the keyspace {} stopped at {}%".format(
keyspace_name, keyspace_repair_percentage
)
localstrategy_keyspace_percentage = per_keyspace_progress.get(self.LOCALSTRATEGY_KEYSPACE_NAME, None)
assert localstrategy_keyspace_percentage is None, (
"The keyspace with the replication strategy of localstrategy was included in repair, when it shouldn't"
)
self.log.info("the sctool repair command was completed successfully")
mgr_cluster.delete() # remove cluster at the end of the test
self.log.info("finishing test_repair_multiple_keyspace_types")
def test_repair_intensity_feature_on_multiple_node(self):
self.test_repair_intensity_feature(fault_multiple_nodes=True)
def test_repair_intensity_feature_on_single_node(self):
self.test_repair_intensity_feature(fault_multiple_nodes=False)
def test_repair_control(self):
InfoEvent(message="Starting C-S write load").publish()
self.run_prepare_write_cmd()
InfoEvent(message="Flushing").publish()
for node in self.db_cluster.nodes:
node.run_nodetool("flush")
InfoEvent(message="Waiting for compactions to end").publish()
self.wait_no_compactions_running(n=90, sleep_time=30)
InfoEvent(message="Starting C-S read load").publish()
stress_read_thread = self.generate_background_read_load()
time.sleep(600) # So we will see the base load of the cluster
InfoEvent(message="Sleep ended - Starting tests").publish()
self.create_repair_and_alter_it_with_repair_control()
load_results = stress_read_thread.get_results()
self.log.info("load={}".format(load_results))
class ManagerCRUDTests(ManagerTestFunctionsMixIn):
def test_cluster_crud(self):
"""
Test steps:
1) add a cluster to manager.
2) update the cluster attributes in manager: name/host
3) delete the cluster from manager and re-add again.
"""
self.log.info("starting test_mgmt_cluster_crud")
manager_tool = mgmt.get_scylla_manager_tool(manager_node=self.monitors.nodes[0])
mgr_cluster = self.db_cluster.get_cluster_manager()
# Test cluster attributes
cluster_orig_name = mgr_cluster.name
mgr_cluster.update(name="{}_renamed".format(cluster_orig_name))
assert mgr_cluster.name == cluster_orig_name + "_renamed", "Cluster name wasn't changed after update command"
mgr_cluster.delete()
mgr_cluster = manager_tool.add_cluster(
self.CLUSTER_NAME, db_cluster=self.db_cluster, auth_token=self.monitors.mgmt_auth_token
)
mgr_cluster.delete() # remove cluster at the end of the test
self.log.info("finishing test_mgmt_cluster_crud")
class ManagerHealthCheckTests(ManagerTestFunctionsMixIn):
def test_cluster_healthcheck(self):
self.log.info("starting test_mgmt_cluster_healthcheck")
mgr_cluster = self.db_cluster.get_cluster_manager()
other_host, other_host_ip = [
host_data
for host_data in self.get_cluster_hosts_with_ips()
if host_data[1] != self.get_cluster_hosts_ip()[0]
][0]
sleep = 40
self.log.debug("Sleep {} seconds, waiting for health-check task to run by schedule on first time".format(sleep))
time.sleep(sleep)
healthcheck_task = mgr_cluster.get_healthcheck_task()
self.log.debug("Health-check task history is: {}".format(healthcheck_task.history))
dict_host_health = mgr_cluster.get_hosts_health()
for host_health in dict_host_health.values():
assert host_health.status == HostStatus.UP, "Not all hosts status is 'UP'"
assert host_health.rest_status == HostRestStatus.UP, "Not all hosts REST status is 'UP'"
# Check for sctool status change after scylla-server down
other_host.stop_scylla_server()
self.log.debug("Health-check next run is: {}".format(healthcheck_task.next_run))
self.log.debug("Sleep {} seconds, waiting for health-check task to run after node down".format(sleep))
time.sleep(sleep)
dict_host_health = mgr_cluster.get_hosts_health()
assert dict_host_health[other_host_ip].status == HostStatus.DOWN, "Host: {} status is not 'DOWN'".format(
other_host_ip
)
assert dict_host_health[other_host_ip].rest_status == HostRestStatus.DOWN, (
"Host: {} REST status is not 'DOWN'".format(other_host_ip)
)
other_host.start_scylla_server()
mgr_cluster.delete() # remove cluster at the end of the test
self.log.info("finishing test_mgmt_cluster_healthcheck")
def test_healthcheck_change_max_timeout(self):
"""
New in manager 2.6
'max_timeout' is new parameter in the scylla manager yaml. It decides the maximum
amount of time the manager healthcheck function will wait for a ping response before
it will announce the node as timed out.
The test sets the timeout as such that the latency of the nodes that exist in the
local region (us-east-1) will not be longer than the set timeout, and therefore
will appear as UP in the healthcheck, while the latency of the node that is the
distant region (us-west-2) will be longer than the set timeout, and therefore the
healthcheck will report it as TIMEOUT.
The test makes sure that the healthcheck reports those statuses correctly.
"""
self.log.info("starting test_healthcheck_change_max_timeout")
nodes_num_per_dc = 3
nodes_from_local_dc = self.db_cluster.nodes[:nodes_num_per_dc]
nodes_from_distant_dc = self.db_cluster.nodes[nodes_num_per_dc:]
manager_node = self.monitors.nodes[0]
mgr_cluster = self.db_cluster.get_cluster_manager()
try:
reconfigure_scylla_manager(
manager_node=manager_node, logger=self.log, values_to_update=[{"healthcheck": {"max_timeout": "20ms"}}]
)
sleep = 40
self.log.debug("Sleep %s seconds, waiting for health-check task to rerun", sleep)
time.sleep(sleep)
dict_host_health = mgr_cluster.get_hosts_health()
for node in nodes_from_distant_dc:
assert dict_host_health[node.ip_address].status == HostStatus.TIMEOUT, (
f'After setting "max_timeout" to a value shorter than the latency of the distant dc nodes, '
f"the healthcheck status of {node.ip_address} was not {HostStatus.TIMEOUT} as expected, but "
f"instead it was {dict_host_health[node.ip_address].status}"
)
for node in nodes_from_local_dc:
assert dict_host_health[node.ip_address].status == HostStatus.UP, (
f'After setting "max_timeout" to a value longer than the latency of the local dc nodes, '
f"the healthcheck status of {node.ip_address} is not {HostStatus.UP} as expected, but "
f"instead it was {dict_host_health[node.ip_address].status}"
)
finally:
reconfigure_scylla_manager(manager_node=manager_node, logger=self.log, values_to_remove=["healthcheck"])
mgr_cluster.delete() # remove cluster at the end of the test
self.log.info("finishing test_healthcheck_change_max_timeout")
class ManagerEncryptionTests(ManagerTestFunctionsMixIn):
def _disable_client_encryption(self) -> None:
for node in self.db_cluster.nodes:
with node.remote_scylla_yaml() as scylla_yml:
scylla_yml.client_encryption_options.enabled = False
node.restart_scylla()
def test_client_encryption(self):
self.log.info("starting test_client_encryption")
self.log.info("ENABLED client encryption checks")
if not self.db_cluster.nodes[0].is_client_encrypt:
self.db_cluster.enable_client_encrypt()
manager_node = self.monitors.nodes[0]
self.log.info("Create and send client TLS certificate/key to the manager node")
manager_node.create_node_certificate(
cert_file=manager_node.ssl_conf_dir / TLSAssets.CLIENT_CERT,
cert_key=manager_node.ssl_conf_dir / TLSAssets.CLIENT_KEY,
)
manager_node.remoter.run(f"mkdir -p {mgmt.cli.SSL_CONF_DIR}")
manager_node.remoter.send_files(src=str(manager_node.ssl_conf_dir) + "/", dst=str(mgmt.cli.SSL_CONF_DIR))
mgr_cluster = self.db_cluster.get_cluster_manager(force_add=True, client_encrypt=True)
healthcheck_task = mgr_cluster.get_healthcheck_task()
healthcheck_task.wait_for_status(list_status=[TaskStatus.DONE], step=5, timeout=240)
self.log.debug("Health-check task history is: {}".format(healthcheck_task.history))
dict_host_health = mgr_cluster.get_hosts_health()
for host_health in dict_host_health.values():
assert host_health.ssl == HostSsl.ON, "Not all hosts ssl is 'ON'"
assert host_health.status == HostStatus.UP, "Not all hosts status is 'UP'"
self.log.info("DISABLED client encryption checks")
self._disable_client_encryption()
# SM caches scylla nodes configuration and the healthcheck svc is independent on the cache updates.
# Cache is being updated periodically, every 1 minute following the manager config for SCT.
# We need to wait until SM is aware about the configuration change.
sleep_time = 90
self.log.debug("Sleep %s seconds, waiting for SM is aware about the configuration change", sleep_time)
time.sleep(sleep_time)
dict_host_health = mgr_cluster.get_hosts_health()
for host_health in dict_host_health.values():
assert host_health.ssl == HostSsl.OFF, "Not all hosts ssl is 'OFF'"
mgr_cluster.delete() # remove cluster at the end of the test
self.log.info("finishing test_client_encryption")
class ManagerSuspendTests(ManagerTestFunctionsMixIn):
def _test_suspend_and_resume_task_template(self, task_type):
# task types: backup/repair
self.log.info("starting test_suspend_and_resume_{}".format(task_type))
# re-add the cluster to make the backup task run from scratch, otherwise it may be very fast and
# the test is not able to catch the required statuses
mgr_cluster = self.db_cluster.get_cluster_manager(force_add=True)
if task_type == "backup":
suspendable_task = mgr_cluster.create_backup_task(location_list=self.locations)
elif task_type == "repair":
# Set intensity and parallel to 1 to make repair task run longer to be able to catch RUNNING state
suspendable_task = mgr_cluster.create_repair_task(intensity=1, parallel=1)
else:
raise ValueError(f"Not familiar with task type: {task_type}")
assert suspendable_task.wait_for_status(list_status=[TaskStatus.RUNNING], timeout=300, step=5), (
f"task {suspendable_task.id} failed to reach status {TaskStatus.RUNNING}"
)
with mgr_cluster.suspend_manager_then_resume(start_tasks=True):
assert suspendable_task.wait_for_status(list_status=[TaskStatus.STOPPED], timeout=300, step=10), (
f"task {suspendable_task.id} failed to reach status {TaskStatus.STOPPED}"
)
assert suspendable_task.wait_for_status(list_status=[TaskStatus.DONE], timeout=1200, step=10), (
f"task {suspendable_task.id} failed to reach status {TaskStatus.DONE}"
)
self.log.info("finishing test_suspend_and_resume_{}".format(task_type))
def _test_suspend_with_on_resume_start_tasks_flag_template(self, wait_for_duration):
suspension_duration = 75
test_name_filler = "after_duration_passed" if wait_for_duration else "before_duration_passed"
self.log.info("starting test_suspend_with_on_resume_start_tasks_flag_{}".format(test_name_filler))
# re-add the cluster to make the backup task run from scratch, otherwise it may run very fast and
# the test won't be able to catch the required statuses
mgr_cluster = self.db_cluster.get_cluster_manager(force_add=True)
task_type = random.choice(["backup", "repair"])
if task_type == "backup":
suspendable_task = mgr_cluster.create_backup_task(location_list=self.locations)
else:
suspendable_task = mgr_cluster.create_repair_task()
assert suspendable_task.wait_for_status(list_status=[TaskStatus.RUNNING], timeout=300, step=5), (
f"task {suspendable_task.id} failed to reach status {TaskStatus.RUNNING}"
)
with mgr_cluster.suspend_manager_then_resume(
start_tasks=False, start_tasks_in_advance=True, duration=f"{suspension_duration}s"
):
assert suspendable_task.wait_for_status(list_status=[TaskStatus.STOPPED], timeout=60, step=2), (
f"task {suspendable_task.id} failed to reach status {TaskStatus.STOPPED}"
)
if wait_for_duration: # Whether waiting for the duration time to pass or not
time.sleep(suspension_duration + 5)
if wait_for_duration:
assert suspendable_task.wait_for_status(list_status=[TaskStatus.DONE], timeout=1200, step=10), (
f"After the cluster was resumed (while resuming AFTER the suspend duration has passed),"
f" task {suspendable_task.id} failed to reach status "
f"{TaskStatus.DONE}, but instead stayed in {suspendable_task.status}"
)
else:
assert suspendable_task.status == TaskStatus.STOPPED, (
"After the cluster was resumed (while resuming BEFORE the suspend duration "
f"has passed), task {suspendable_task.id} failed to stay in status STOPPED"
)
time.sleep(suspension_duration + 5)
assert suspendable_task.status == TaskStatus.STOPPED, (
"After the cluster was resumed (while resuming BEFORE the suspend duration "
f"has passed), task {suspendable_task.id} failed to stay in status STOPPED after suspension time ended"
)
self.log.info("finishing test_suspend_with_on_resume_start_tasks_flag_{}".format(test_name_filler))
def _test_suspend_and_resume_without_starting_tasks(self):
self.log.info("starting test_suspend_and_resume_without_starting_tasks")
# re-add the cluster to make the backup task run from scratch, otherwise it may be very fast and
# the test is not able to catch the required statuses
mgr_cluster = self.db_cluster.get_cluster_manager(force_add=True)
suspendable_task = mgr_cluster.create_backup_task(location_list=self.locations)
assert suspendable_task.wait_for_status(list_status=[TaskStatus.RUNNING], timeout=300, step=5), (
f"task {suspendable_task.id} failed to reach status {TaskStatus.RUNNING}"
)
with mgr_cluster.suspend_manager_then_resume(start_tasks=False):
mgr_cluster.suspend()
assert suspendable_task.wait_for_status(list_status=[TaskStatus.STOPPED], timeout=300, step=10), (
f"task {suspendable_task.id} failed to reach status {TaskStatus.STOPPED}"
)
mgr_cluster.resume(start_tasks=False)
self.log.info("Waiting a little time to make sure the task isn't started")
time.sleep(60)
current_task_status = suspendable_task.status
assert current_task_status == TaskStatus.STOPPED, (
f'Task {current_task_status} did not remain in "{TaskStatus.STOPPED}" status, but instead '
f'reached "{current_task_status}" status'
)
self.log.info("finishing test_suspend_and_resume_without_starting_tasks")
def test_suspend_and_resume(self):
with self.subTest("Suspend and resume backup task"):
self._test_suspend_and_resume_task_template(task_type="backup")
with self.subTest("Suspend and resume repair task"):
self._test_suspend_and_resume_task_template(task_type="repair")
with self.subTest("Suspend and resume without starting task"):
self._test_suspend_and_resume_without_starting_tasks()
with self.subTest("Suspend with on resume start tasks flag after duration has passed"):
self._test_suspend_with_on_resume_start_tasks_flag_template(wait_for_duration=True)
with self.subTest("Suspend with on resume start tasks flag before duration has passed"):
self._test_suspend_with_on_resume_start_tasks_flag_template(wait_for_duration=False)
class ManagerHelperTests(ManagerTestFunctionsMixIn):
def _unlock_cloud_key(self) -> str | None:
"""The operation is required to make the particular Cloud cluster key reusable.
For that, the key should be unlocked from the original cluster.
"""
self.log.info("Unlock the EaR key used by cluster to reuse it while restoring to a new cluster (1-1 restore)")
ear_key = self.db_cluster.get_ear_key()
if not ear_key:
self.log.warning("No EaR key found, skipping unlock")
return None
self.db_cluster.unlock_ear_key()
return ear_key.get("keyid")
def test_prepare_backup_snapshot(self): # pylint: disable=too-many-locals # noqa: PLR0914
"""Test prepares backup snapshot for its future use in nemesis or restore benchmarks
Steps:
1. Populate the cluster with data.
- C-S write cmd is based on `confirmation_stress_template` template in manager_persistent_snapshots.yaml
- Backup size should be specified in Jenkins job passing `mgmt_prepare_snapshot_size` parameter
2. Run backup and wait for it to finish.
3. Log snapshot details into console.
"""
is_cloud_manager = self.params.get("use_cloud_manager")
self.log.info("Initialize Scylla Manager")
mgr_cluster = self.db_cluster.get_cluster_manager()
self.log.info("Define backup location")
if is_cloud_manager:
# Extract location from an automatically scheduled backup task
auto_backup_task = mgr_cluster.backup_task_list[0]
location_list = [auto_backup_task.get_task_info_dict()["location"]]
self.log.info("Delete scheduled backup task to not interfere")
mgr_cluster.delete_task(auto_backup_task)
else:
location_list = self.locations
self.log.info("Populate the cluster with data")
backup_size = self.params.get("mgmt_prepare_snapshot_size") # in Gb
assert backup_size and backup_size >= 1, "Backup size must be at least 1Gb"
ks_name, cs_write_cmds = self.build_snapshot_preparer_cs_write_cmd(backup_size)
self.run_and_verify_stress_in_threads(cs_cmds=cs_write_cmds, stop_on_failure=True)
self.log.info("Run backup and wait for it to finish")
backup_task = mgr_cluster.create_backup_task(location_list=location_list, rate_limit_list=["0"])
backup_task_status = backup_task.wait_and_get_final_status(timeout=200000)
assert backup_task_status == TaskStatus.DONE, (
f"Backup task ended in {backup_task_status} instead of {TaskStatus.DONE}"
)
if is_cloud_manager:
self.log.info("Copy bucket with snapshot since the original bucket is deleted together with cluster")
# can be several locations for multiDC cluster, for example,
# 'AWS_EU_SOUTH_1:s3:scylla-cloud-backup-170-176-15c7bm,AWS_EU_WEST_1:s3:scylla-cloud-backup-170-175-9dy2w4'
location_list = location_list[0].split(",")
for location in location_list:
# from AWS_US_EAST_1:s3:scylla-cloud-backup-8072-7216-v5dn53' to scylla-cloud-backup-8072-7216-v5dn53
original_bucket_name = location.split(":")[-1].strip("'")
bucket_name = original_bucket_name + "-manager-tests"
region = self.get_region_from_bucket_location(location)
self.copy_backup_snapshot_bucket(source=original_bucket_name, destination=bucket_name, region=region)
if is_cloud_manager:
cluster_id = self.db_cluster.cloud_cluster_id
key_id = self._unlock_cloud_key()
manager_cluster_id = self.db_cluster.get_manager_cluster_id()
else:
cluster_id = mgr_cluster.id
key_id = "N/A"
manager_cluster_id = "N/A"
self.log.info("Send snapshot details to Argus")
snapshot_details = {
"tag": backup_task.get_snapshot_tag(),
"size": backup_size,
"locations": ",".join(location_list),
"ks_name": ks_name,
"scylla_version": self.params.get_version_based_on_conf()[0],
"cluster_id": cluster_id,
"ear_key_id": key_id,
"manager_cluster_id": manager_cluster_id,
}
send_manager_snapshot_details_to_argus(
argus_client=self.test_config.argus_client(),
snapshot_details=snapshot_details,
)
class ManagerSanityTests(
ManagerBackupTests,
ManagerRestoreTests,
ManagerRepairTests,
ManagerCRUDTests,
ManagerHealthCheckTests,
ManagerSuspendTests,
ManagerEncryptionTests,
):
def test_manager_sanity(self, prepared_ks: bool = False, ks_names: list = None):
"""
Test steps:
1) Run the repair test.
2) Run test_mgmt_cluster test.
3) test_mgmt_cluster_healthcheck
4) test_client_encryption
"""
if not prepared_ks:
self.generate_load_and_wait_for_results()
with self.subTest("Basic Backup Test"):
self.test_basic_backup(ks_names=ks_names)
with self.subTest("Restore Backup Test"):
self.test_restore_backup_with_task(ks_names=ks_names)
with self.subTest("Repair Multiple Keyspace Types"):
self.test_repair_multiple_keyspace_types()
with self.subTest("Mgmt Cluster CRUD"):
self.test_cluster_crud()
with self.subTest("Mgmt cluster Health Check"):
self.test_cluster_healthcheck()
# test_healthcheck_change_max_timeout requires a multi dc run
if self.db_cluster.nodes[0].test_config.MULTI_REGION:
with self.subTest("Basic test healthcheck change max timeout"):
self.test_healthcheck_change_max_timeout()
with self.subTest("Basic test suspend and resume"):
self.test_suspend_and_resume()
with self.subTest("Client Encryption"):
# Since this test activates encryption, it has to be the last test in the sanity
self.test_client_encryption()
def test_manager_sanity_vnodes_tablets_cluster(self):
"""
Test steps:
1) Create tablets keyspace and propagate some data.
2) Create vnodes keyspace and propagate some data.
3) Run sanity test (test_manager_sanity).
"""
self.log.info("starting test_manager_sanity_vnodes_tablets_cluster")
ks_config = [("tablets_keyspace", True), ("vnodes_keyspace", False)]
ks_names = [i[0] for i in ks_config]
for ks_name, tablets_enabled in ks_config:
tablets_config = TabletsConfiguration(enabled=tablets_enabled)
self.create_keyspace(ks_name, replication_factor=3, tablets_config=tablets_config)
self.generate_load_and_wait_for_results(keyspace_name=ks_name)
self.test_manager_sanity(prepared_ks=True, ks_names=ks_names)
self.log.info("finishing test_manager_sanity_vnodes_tablets_cluster")
class ManagerRollbackTests(ManagerTestFunctionsMixIn):
def test_mgmt_repair_nemesis(self):
"""
Test steps:
1) Run cassandra stress on cluster.
2) Add cluster to Manager and run full repair via Nemesis
"""
self.generate_load_and_wait_for_results()
self.log.debug("test_mgmt_cli: initialize MgmtRepair nemesis")
mgmt_nemesis = MgmtRepair(tester_obj=self, termination_event=self.db_cluster.nemesis_termination_event)
mgmt_nemesis.disrupt()
def test_manager_upgrade(self):
"""
Test steps:
1) Run the repair test.
2) Run manager upgrade to new version of yaml: 'scylla_mgmt_upgrade_to_repo'. (the 'from' version is: 'scylla_mgmt_address').
"""
self.log.info("starting test_manager_upgrade")
scylla_mgmt_upgrade_to_repo = self.params.get("scylla_mgmt_upgrade_to_repo")
manager_node = self.monitors.nodes[0]
manager_tool = mgmt.get_scylla_manager_tool(manager_node=manager_node)
selected_host = self.get_cluster_hosts_ip()[0]
cluster_name = "mgr_cluster1"
mgr_cluster = manager_tool.get_cluster(cluster_name=cluster_name) or manager_tool.add_cluster(
name=cluster_name, host=selected_host, auth_token=self.monitors.mgmt_auth_token
)
self.log.info("Running some stress and repair before upgrade")
self.test_mgmt_repair_nemesis()
repair_task_list = mgr_cluster.repair_task_list
manager_from_version = manager_tool.sctool.version
manager_tool.upgrade(scylla_mgmt_upgrade_to_repo=scylla_mgmt_upgrade_to_repo)
assert manager_from_version[0] != manager_tool.sctool.version[0], "Manager version not changed after upgrade."
# verify all repair tasks exist
for repair_task in repair_task_list:
self.log.debug("{} status: {}".format(repair_task.id, repair_task.status))
self.log.info("Running a new repair task after upgrade")
repair_task = mgr_cluster.create_repair_task()
self.log.debug("{} status: {}".format(repair_task.id, repair_task.status))
self.log.info("finishing test_manager_upgrade")
def test_manager_rollback_upgrade(self):
"""
Test steps:
1) Run Upgrade test: scylla_mgmt_address --> scylla_mgmt_upgrade_to_repo
2) Run manager downgrade to pre-upgrade version as in yaml: 'scylla_mgmt_address'.
"""
self.log.info("starting test_manager_rollback_upgrade")
self.test_manager_upgrade()
scylla_mgmt_address = self.params.get("scylla_mgmt_address")
manager_node = self.monitors.nodes[0]
manager_tool = mgmt.get_scylla_manager_tool(manager_node=manager_node)