-
Notifications
You must be signed in to change notification settings - Fork 95
/
mgmt_cli_test.py
1506 lines (1321 loc) · 82.9 KB
/
mgmt_cli_test.py
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
# pylint: disable=too-many-lines
# pylint: disable=too-many-lines
import random
from pathlib import Path
from functools import cached_property
import re
import time
from textwrap import dedent
from datetime import datetime, timedelta
from dataclasses import dataclass
import boto3
import yaml
from invoke import exceptions
from sdcm import mgmt
from sdcm.argus_results import send_manager_benchmark_results_to_argus
from sdcm.mgmt import ScyllaManagerError, TaskStatus, HostStatus, HostSsl, HostRestStatus
from sdcm.mgmt.cli import ScyllaManagerTool, RestoreTask
from sdcm.mgmt.common import reconfigure_scylla_manager, get_persistent_snapshots
from sdcm.provision.helpers.certificate import TLSAssets
from sdcm.remote import shell_script_cmd
from sdcm.tester import ClusterTester
from sdcm.cluster import TestConfig
from sdcm.nemesis import MgmtRepair
from sdcm.utils.adaptive_timeouts import adaptive_timeout, Operations
from sdcm.utils.common import reach_enospc_on_node, clean_enospc_on_node
from sdcm.utils.issues import SkipPerIssues
from sdcm.utils.loader_utils import LoaderUtilsMixin
from sdcm.utils.time_utils import ExecutionTimer
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.compaction_ops import CompactionOps
from sdcm.utils.gce_utils import get_gce_storage_client
from sdcm.utils.azure_utils import AzureService
from sdcm.utils.tablets.common import TabletsConfiguration
from sdcm.exceptions import FilesNotCorrupted
@dataclass
class ManagerTestMetrics:
backup_time = "N/A"
restore_time = "N/A"
@dataclass
class SnapshotData:
"""Describes the backup snapshot:
- bucket: S3 bucket name
- tag: snapshot tag, for example 'sm_20240816185129UTC'
- exp_timeout: expected timeout for the restore operation
- keyspaces: list of keyspaces presented in backup
- cs_read_cmd_template: cassandra-stress read command template
- prohibit_verification_read: if True, the verification read will be prohibited. Most likely, such a backup was
created via c-s user profile.
- number_of_rows: number of data rows written in the DB
- node_ids: list of node ids where backup was created
"""
bucket: str
tag: str
exp_timeout: int
keyspaces: list[str]
ks_tables_map: dict[str, list[str]]
cs_read_cmd_template: str
prohibit_verification_read: bool
number_of_rows: int
node_ids: list[str]
class BackupFunctionsMixIn(LoaderUtilsMixin):
DESTINATION = Path('/tmp/backup')
backup_azure_blob_service = None
backup_azure_blob_sas = None
test_config = TestConfig()
@cached_property
def locations(self) -> list[str]:
backend = self.params.get("backup_bucket_backend")
buckets = self.params.get("backup_bucket_location")
if not isinstance(buckets, list):
buckets = buckets.split()
# FIXME: Make it works with multiple locations or file a bug for scylla-manager.
return [f"{backend}:{location}" for location in buckets[:1]]
def _run_cmd_with_retry(self, executor, cmd, retries=10):
for _ in range(retries):
try:
executor(cmd)
break
except exceptions.UnexpectedExit as ex:
self.log.debug("cmd %s failed with error %s, will retry", cmd, ex)
def install_awscli_dependencies(self, node):
if node.distro.is_ubuntu or node.distro.is_debian:
cmd = dedent("""
apt update
apt install -y python3-pip
PIP_BREAK_SYSTEM_PACKAGES=1 pip install awscli
""")
elif node.distro.is_rhel_like:
cmd = dedent("""
yum install -y epel-release
yum install -y python-pip
yum remove -y epel-release
pip install awscli==1.18.140
""")
else:
raise RuntimeError("This distro is not supported")
self._run_cmd_with_retry(executor=node.remoter.sudo, cmd=shell_script_cmd(cmd))
def install_gsutil_dependencies(self, node):
if node.distro.is_ubuntu or node.distro.is_debian:
cmd = dedent("""
echo 'deb https://packages.cloud.google.com/apt cloud-sdk main' | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt-get update
""")
self._run_cmd_with_retry(executor=node.remoter.run, cmd=shell_script_cmd(cmd))
node.install_package("google-cloud-cli")
else:
raise NotImplementedError("At the moment, we only support debian installation")
def install_azcopy_dependencies(self, node):
self._run_cmd_with_retry(executor=node.remoter.sudo, cmd=shell_script_cmd("""\
curl -L https://aka.ms/downloadazcopy-v10-linux | \
tar xz -C /usr/bin --strip-components 1 --wildcards '*/azcopy'
"""))
self.backup_azure_blob_service = \
f"https://{self.test_config.backup_azure_blob_credentials['account']}.blob.core.windows.net/"
self.backup_azure_blob_sas = self.test_config.backup_azure_blob_credentials["download_sas"]
@staticmethod
def download_from_s3(node, source, destination):
node.remoter.sudo(f"aws s3 cp '{source}' '{destination}'")
@staticmethod
def download_from_gs(node, source, destination):
node.remoter.sudo(f"gsutil cp '{source.replace('gcs://', 'gs://')}' '{destination}'")
def download_from_azure(self, node, source, destination):
# azure://<bucket>/<path> -> https://<account>.blob.core.windows.net/<bucket>/<path>?SAS
source = f"{source.replace('azure://', self.backup_azure_blob_service)}{self.backup_azure_blob_sas}"
node.remoter.sudo(f"azcopy copy '{source}' '{destination}'")
def get_table_id(self, node, table_name, keyspace_name=None, remove_hyphen=True):
"""
:param keyspace_name: not mandatory. Should be used when there's more than one table with the same
name in different keyspaces
:param remove_hyphen: In the table's directory, scylla removes the hyphens from the id. Setting
the attribute to True will remove the hyphens.
"""
query = f"SELECT id FROM system_schema.tables WHERE table_name='{table_name}'"
if keyspace_name:
query += f"and keyspace_name='{keyspace_name}'"
with self.db_cluster.cql_connection_patient(node) as session:
results = session.execute(query)
base_id = str(results[0].id)
if remove_hyphen:
return base_id.replace('-', '')
return base_id
def restore_backup_without_manager(self, mgr_cluster, snapshot_tag, ks_tables_list, location=None,
precreated_backup=False):
"""Restore backup without Scylla Manager but using the `nodetool refresh` operation
(https://opensource.docs.scylladb.com/stable/operating-scylla/nodetool-commands/refresh.html).
The method downloads backup files from the backup bucket (aws s3 cp ...) and then loads them (nodetool refresh)
into the cluster node by node and table by table.
Two flows are supported:
- restore to a new cluster from pre-created backup.
- restore from backup created at the same cluster.
The difference between these two flows is in the way the node_id is retrieved - if the backup was created with
the cluster under test use node_ids of cluster under test, otherwise, get node_id from `sctool backup files...`
"""
backup_bucket_backend = self.params.get("backup_bucket_backend")
if backup_bucket_backend == "s3":
install_dependencies = self.install_awscli_dependencies
download = self.download_from_s3
elif backup_bucket_backend == "gcs":
install_dependencies = self.install_gsutil_dependencies
download = self.download_from_gs
elif backup_bucket_backend == "azure":
install_dependencies = self.install_azcopy_dependencies
download = self.download_from_azure
else:
raise ValueError(f'{backup_bucket_backend=} is not supported')
browse_all_clusters = True if precreated_backup else False
per_node_backup_file_paths = mgr_cluster.get_backup_files_dict(snapshot_tag, location, browse_all_clusters)
# One path is for schema, it should be filtrated as this method is supposed to be run on restored schema cluster
backed_up_node_ids = [i for i in per_node_backup_file_paths if 'schema' not in i]
nodetool_refresh_extra_flags = self.params.get('mgmt_nodetool_refresh_flags') or ""
for index, node in enumerate(self.db_cluster.nodes):
install_dependencies(node=node)
node_data_path = Path("/var/lib/scylla/data")
# If the backup was not created with the cluster under test (precreated backup), get node_id from
# sctool backup files output, otherwise, use node_ids of cluster under test
backed_up_node_id = backed_up_node_ids[index] if precreated_backup else node.host_id
for keyspace, tables in ks_tables_list.items():
keyspace_path = node_data_path / keyspace
for table in tables:
table_id = self.get_table_id(node=node, table_name=table, keyspace_name=keyspace)
table_upload_path = keyspace_path / f"{table}-{table_id}" / "upload"
with ExecutionTimer() as timer:
for file_path in per_node_backup_file_paths[backed_up_node_id][keyspace][table]:
download(node=node, source=file_path, destination=table_upload_path)
self.log.info(f"[Node {index}][{keyspace}.{table}] Download took {timer.duration}")
node.remoter.sudo(f"chown scylla:scylla -Rf {table_upload_path}")
with ExecutionTimer() as timer:
node.run_nodetool(f"refresh {keyspace} {table} {nodetool_refresh_extra_flags}")
self.log.info(f"[Node {index}][{keyspace}.{table}] Nodetool refresh took {timer.duration}")
def restore_backup_from_backup_task(self, mgr_cluster, backup_task, keyspace_and_table_list):
snapshot_tag = backup_task.get_snapshot_tag()
self.restore_backup_without_manager(mgr_cluster=mgr_cluster, snapshot_tag=snapshot_tag,
ks_tables_list=keyspace_and_table_list)
# pylint: disable=too-many-arguments
def verify_backup_success(self, mgr_cluster, backup_task, ks_names: list = None, tables_names: list = None,
truncate=True, restore_data_with_task=False, timeout=None):
if ks_names is None:
ks_names = ['keyspace1']
if tables_names is None:
tables_names = ['standard1']
ks_tables_map = {keyspace: tables_names for keyspace in ks_names}
if truncate:
for ks, tables in ks_tables_map.items():
for table_name in tables:
self.log.info(f'running truncate on {ks}.{table_name}')
self.db_cluster.nodes[0].run_cqlsh(f'TRUNCATE {ks}.{table_name}')
if restore_data_with_task:
self.restore_backup_with_task(mgr_cluster=mgr_cluster, snapshot_tag=backup_task.get_snapshot_tag(),
timeout=timeout, restore_data=True)
else:
self.restore_backup_from_backup_task(mgr_cluster=mgr_cluster, backup_task=backup_task,
keyspace_and_table_list=ks_tables_map)
def restore_backup_with_task(self, mgr_cluster, snapshot_tag, timeout, restore_schema=False, restore_data=False,
location_list=None, extra_params=None):
location_list = location_list if location_list else self.locations
restore_task = mgr_cluster.create_restore_task(restore_schema=restore_schema, restore_data=restore_data,
location_list=location_list, snapshot_tag=snapshot_tag,
extra_params=extra_params)
restore_task.wait_and_get_final_status(step=30, timeout=timeout)
assert restore_task.status == TaskStatus.DONE, f"Restoration of {snapshot_tag} has failed!"
InfoEvent(message=f'The restore task has ended successfully. '
f'Restore run time: {restore_task.duration}.').publish()
if restore_schema:
self.db_cluster.restart_scylla() # After schema restoration, you should restart the nodes
return restore_task
def run_verification_read_stress(self, ks_names=None):
stress_queue = []
stress_cmd = self.params.get('stress_read_cmd')
keyspace_num = self.params.get('keyspace_num')
InfoEvent(message='Starting read stress for data verification').publish()
stress_start_time = datetime.now()
if ks_names:
self.assemble_and_run_all_stress_cmd_by_ks_names(stress_queue, stress_cmd, ks_names)
else:
self.assemble_and_run_all_stress_cmd(stress_queue, stress_cmd, keyspace_num)
for stress in stress_queue:
self.verify_stress_thread(cs_thread_pool=stress)
stress_run_time = datetime.now() - stress_start_time
InfoEvent(message=f'The read stress run was completed. Total run time: {stress_run_time}').publish()
def _generate_load(self, keyspace_name: str = None):
self.log.info('Starting c-s write workload')
stress_cmd = self.params.get('stress_cmd')
stress_thread = self.run_stress_thread(stress_cmd=stress_cmd, keyspace_name=keyspace_name)
self.log.info('Sleeping for 15s to let cassandra-stress run...')
time.sleep(15)
return stress_thread
def generate_load_and_wait_for_results(self, keyspace_name: str = None):
load_thread = self._generate_load(keyspace_name=keyspace_name)
load_results = load_thread.get_results()
self.log.info(f'load={load_results}')
def get_keyspace_name(self, ks_prefix: str = 'keyspace', ks_number: int = 1) -> list:
"""Get keyspace name based on the following logic:
- if keyspaces number > 1, numeric indexes are used in the ks name;
- if keyspaces number == 1, ks name depends on whether compression is applied to keyspace. If applied,
the compression postfix will be used in the name, otherwise numeric index (keyspace1)
"""
if ks_number > 1:
return ['{}{}'.format(ks_prefix, i) for i in range(1, ks_number + 1)]
else:
stress_cmd = self.params.get('stress_read_cmd')
if 'compression' in stress_cmd:
compression_postfix = re.search('compression=(.*)Compressor', stress_cmd).group(1)
keyspace_name = '{}_{}'.format(ks_prefix, compression_postfix.lower())
else:
keyspace_name = '{}{}'.format(ks_prefix, ks_number)
return [keyspace_name]
def generate_background_read_load(self):
self.log.info('Starting c-s read')
stress_cmd = self.params.get('stress_read_cmd')
number_of_nodes = self.params.get("n_db_nodes")
number_of_loaders = self.params.get("n_loaders")
throttle_per_node = 14666
throttle_per_loader = int(throttle_per_node * number_of_nodes / number_of_loaders)
stress_cmd = stress_cmd.replace("<THROTTLE_PLACE_HOLDER>", str(throttle_per_loader))
stress_thread = self.run_stress_thread(stress_cmd=stress_cmd)
self.log.info('Sleeping for 15s to let cassandra-stress run...')
time.sleep(15)
return stress_thread
# pylint: disable=too-many-public-methods
class MgmtCliTest(BackupFunctionsMixIn, ClusterTester):
"""
Test Scylla Manager operations on Scylla cluster.
"""
CLUSTER_NAME = "mgr_cluster1"
LOCALSTRATEGY_KEYSPACE_NAME = "localstrategy_keyspace"
NETWORKSTRATEGY_KEYSPACE_NAME = "networkstrategy_keyspace"
manager_test_metrics = ManagerTestMetrics()
def _ensure_and_get_cluster(self, manager_tool, force_add: bool = False):
"""Get the cluster if it is already added, otherwise add it to manager.
Use force_add=True if you want to re-add the cluster (delete and add again) even if it already added.
"""
mgr_cluster = manager_tool.get_cluster(cluster_name=self.CLUSTER_NAME)
if not mgr_cluster or force_add:
if mgr_cluster:
mgr_cluster.delete()
mgr_cluster = manager_tool.add_cluster(name=self.CLUSTER_NAME, db_cluster=self.db_cluster,
auth_token=self.monitors.mgmt_auth_token)
return mgr_cluster
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_mgmt_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._ensure_and_get_cluster(manager_tool)
# 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')
def get_cluster_hosts_ip(self):
return ScyllaManagerTool.get_cluster_hosts_ip(self.db_cluster)
def get_cluster_hosts_with_ips(self):
return ScyllaManagerTool.get_cluster_hosts_with_ips(self.db_cluster)
def get_all_dcs_names(self):
dcs_names = set()
for node in self.db_cluster.nodes:
data_center = self.db_cluster.get_nodetool_info(node)['Data Center']
dcs_names.add(data_center)
return dcs_names
def _create_keyspace_and_basic_table(self, keyspace_name, table_name="example_table",
replication_factor=1):
self.log.info("creating keyspace {}".format(keyspace_name))
keyspace_existence = self.create_keyspace(keyspace_name, replication_factor)
assert keyspace_existence, "keyspace creation failed"
# Keyspaces without tables won't appear in the repair, so the must have one
self.log.info("creating the table {} in the keyspace {}".format(table_name, keyspace_name))
self.create_table(table_name, keyspace_name=keyspace_name)
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_mgmt_cluster_crud()
with self.subTest('Mgmt cluster Health Check'):
self.test_mgmt_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')
def test_repair_intensity_feature_on_multiple_node(self):
self._repair_intensity_feature(fault_multiple_nodes=True)
def test_repair_intensity_feature_on_single_node(self):
self._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))
def _create_repair_and_alter_it_with_repair_control(self):
keyspace_to_be_repaired = "keyspace2"
manager_tool = mgmt.get_scylla_manager_tool(manager_node=self.monitors.nodes[0])
mgr_cluster = manager_tool.add_cluster(name=self.CLUSTER_NAME + '_repair_control',
db_cluster=self.db_cluster,
auth_token=self.monitors.mgmt_auth_token)
# writing 292968720 rows, equal to the amount of data written in the prepare (around 100gb per node),
# to create a large data fault and therefore a longer running repair
self.create_missing_rows_in_cluster(create_missing_rows_in_multiple_nodes=True,
keyspace_to_be_repaired=keyspace_to_be_repaired,
total_num_of_rows=292968720)
arg_list = [{"intensity": .0001},
{"intensity": 0},
{"parallel": 1},
{"intensity": 2, "parallel": 1}]
InfoEvent(message="Repair started").publish()
repair_task = mgr_cluster.create_repair_task(keyspace="keyspace2")
next_percentage_block = 20
repair_task.wait_for_percentage(next_percentage_block)
for args in arg_list:
next_percentage_block += 20
InfoEvent(message=f"Changing repair args to: {args}").publish()
mgr_cluster.control_repair(**args)
repair_task.wait_for_percentage(next_percentage_block)
repair_task.wait_and_get_final_status(step=30)
InfoEvent(message="Repair ended").publish()
def _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 get_email_data(self):
self.log.info("Prepare data for email")
email_data = self._get_common_email_data()
restore_parameters = self.params.get("mgmt_restore_extra_params")
agent_backup_config = self.params.get("mgmt_agent_backup_config")
if agent_backup_config:
agent_backup_config = agent_backup_config.dict()
email_data.update(
{
"manager_server_repo": self.params.get("scylla_mgmt_address"),
"manager_agent_repo": (self.params.get("scylla_mgmt_agent_address") or
self.params.get("scylla_mgmt_address")),
"backup_time": str(self.manager_test_metrics.backup_time),
"restore_time": str(self.manager_test_metrics.restore_time),
"restore_parameters": restore_parameters,
"agent_backup_config": agent_backup_config,
}
)
return email_data
def test_restore_multiple_backup_snapshots(self): # pylint: disable=too-many-locals # noqa: PLR0914
manager_tool = mgmt.get_scylla_manager_tool(manager_node=self.monitors.nodes[0])
mgr_cluster = self._ensure_and_get_cluster(manager_tool)
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()
target_bucket = persistent_manager_snapshots_dict[cluster_backend]["bucket"]
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(cs_thread_pool=read_thread)
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 create_ks_and_tables(self, num_ks, num_table):
# FIXME: beforehand we better change to have RF=1 to avoid restoring content while restoring replica of data
table_name = []
with self.db_cluster.cql_connection_patient(self.db_cluster.nodes[0]) as session:
for keyspace in range(num_ks):
session.execute(f"CREATE KEYSPACE IF NOT EXISTS ks00{keyspace} "
"WITH replication={'class':'NetworkTopologyStrategy', 'replication_factor':1}")
for table in range(num_table):
session.execute(f'CREATE COLUMNFAMILY IF NOT EXISTS ks00{keyspace}.table00{table} '
'(key varchar, c varchar, v varchar, PRIMARY KEY(key, c))')
table_name.append(f'ks00{keyspace}.table00{table}')
# FIXME: improve the structure + data insertion
# can use this function to populate tables better?
# self.populate_data_parallel()
return table_name
def test_basic_backup(self, ks_names: list = None):
self.log.info('starting test_basic_backup')
manager_tool = mgmt.get_scylla_manager_tool(manager_node=self.monitors.nodes[0])
mgr_cluster = self._ensure_and_get_cluster(manager_tool)
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, ks_names=ks_names)
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_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')
compaction_ops = CompactionOps(cluster=self.db_cluster)
for node in self.db_cluster.nodes:
compaction_ops.disable_autocompaction_on_ks_cf(node=node)
self.log.info('Prepare Manager')
manager_tool = mgmt.get_scylla_manager_tool(manager_node=self.monitors.nodes[0])
mgr_cluster = self._ensure_and_get_cluster(manager_tool, 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')
def test_restore_backup_with_task(self, ks_names: list = None):
self.log.info('starting test_restore_backup_with_task')
manager_tool = mgmt.get_scylla_manager_tool(manager_node=self.monitors.nodes[0])
mgr_cluster = self._ensure_and_get_cluster(manager_tool)
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_backup_multiple_ks_tables(self):
self.log.info('starting test_backup_multiple_ks_tables')
manager_tool = mgmt.get_scylla_manager_tool(manager_node=self.monitors.nodes[0])
mgr_cluster = self._ensure_and_get_cluster(manager_tool)
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')
manager_tool = mgmt.get_scylla_manager_tool(manager_node=self.monitors.nodes[0])
mgr_cluster = self._ensure_and_get_cluster(manager_tool)
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')
manager_tool = mgmt.get_scylla_manager_tool(manager_node=self.monitors.nodes[0])
mgr_cluster = self._ensure_and_get_cluster(manager_tool)
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')
@staticmethod
def _get_all_snapshot_files_s3(cluster_id, bucket_name, region_name):
file_set = set()
s3_client = boto3.client('s3', region_name=region_name)
paginator = s3_client.get_paginator('list_objects')
pages = paginator.paginate(Bucket=bucket_name, Prefix=f'backup/sst/cluster/{cluster_id}')
for page in pages:
# No Contents key means that no snapshot file of the cluster exist,
# probably no backup ran before this function
if "Contents" in page:
content_list = page["Contents"]
file_set.update([item["Key"] for item in content_list])
return file_set
@staticmethod
def _get_all_snapshot_files_gce(cluster_id, bucket_name):
file_set = set()
storage_client, _ = get_gce_storage_client()
blobs = storage_client.list_blobs(bucket_or_name=bucket_name, prefix=f'backup/sst/cluster/{cluster_id}')
for listing_object in blobs:
file_set.add(listing_object.name)
# Unlike S3, if no files match the prefix, no error will occur
return file_set
@staticmethod
def _get_all_snapshot_files_azure(cluster_id, bucket_name):
file_set = set()
azure_service = AzureService()
container_client = azure_service.blob.get_container_client(container=bucket_name)
dir_listing = container_client.list_blobs(name_starts_with=f'backup/sst/cluster/{cluster_id}')
for listing_object in dir_listing:
file_set.add(listing_object.name)
return file_set
def _get_all_snapshot_files(self, cluster_id):
bucket_name = self.params.get('backup_bucket_location').split()[0]
if self.params.get('backup_bucket_backend') == 's3':
region_name = self.params.get("backup_bucket_region") or self.params.get("region_name").split()[0]
return self._get_all_snapshot_files_s3(cluster_id=cluster_id, bucket_name=bucket_name,
region_name=region_name)
elif self.params.get('backup_bucket_backend') == 'gcs':
return self._get_all_snapshot_files_gce(cluster_id=cluster_id, bucket_name=bucket_name)
elif self.params.get('backup_bucket_backend') == 'azure':
return self._get_all_snapshot_files_azure(cluster_id=cluster_id, bucket_name=bucket_name)
else:
raise ValueError(f'"{self.params.get("backup_bucket_backend")}" not supported')
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')
manager_tool = mgmt.get_scylla_manager_tool(manager_node=self.monitors.nodes[0])
mgr_cluster = self._ensure_and_get_cluster(manager_tool)
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_client_encryption(self):
self.log.info('starting test_client_encryption')
manager_node = self.monitors.nodes[0]
manager_tool = mgmt.get_scylla_manager_tool(manager_node=manager_node)
mgr_cluster = self._ensure_and_get_cluster(manager_tool)
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'"
healthcheck_task = mgr_cluster.get_healthcheck_task()
self.db_cluster.enable_client_encrypt()
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))
# SM caches scylla nodes configuration and the healthcheck svc is independent from 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.
mgr_cluster.update(
client_encrypt=True,
force_non_ssl_session_port=mgr_cluster.sctool.is_minimum_3_2_6_or_snapshot
)
time.sleep(90)
healthcheck_task.wait_for_status(list_status=[TaskStatus.DONE], step=5, timeout=240)
sleep = 40
self.log.debug('Sleep {} seconds, waiting for health-check task to run by schedule on first time'.format(sleep))
time.sleep(sleep)
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'"
mgr_cluster.delete() # remove cluster at the end of the test
self.log.info('finishing test_client_encryption')
def test_mgmt_cluster_healthcheck(self):
self.log.info('starting test_mgmt_cluster_healthcheck')
manager_tool = mgmt.get_scylla_manager_tool(manager_node=self.monitors.nodes[0])
mgr_cluster = self._ensure_and_get_cluster(manager_tool)
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_from_local_dc = self.db_cluster.nodes[:2]
nodes_from_distant_dc = self.db_cluster.nodes[2:]
manager_node = self.monitors.nodes[0]
manager_tool = mgmt.get_scylla_manager_tool(manager_node=manager_node)
mgr_cluster = self._ensure_and_get_cluster(manager_tool)
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')
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)
manager_from_version = manager_tool.sctool.version
manager_tool.rollback_upgrade(scylla_mgmt_address=scylla_mgmt_address)
assert manager_from_version[0] != manager_tool.sctool.version[0], "Manager version not changed after rollback."
self.log.info('finishing test_manager_rollback_upgrade')
def test_repair_multiple_keyspace_types(self): # pylint: disable=invalid-name
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._ensure_and_get_cluster(manager_tool)
self._create_keyspace_and_basic_table(self.NETWORKSTRATEGY_KEYSPACE_NAME, replication_factor=2)
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")