-
Notifications
You must be signed in to change notification settings - Fork 114
/
test_messages.py
5410 lines (4467 loc) · 175 KB
/
test_messages.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
import inspect
from unittest import TestCase
from pcs.common import file_type_codes
from pcs.common.fencing_topology import (
TARGET_TYPE_NODE,
TARGET_TYPE_REGEXP,
TARGET_TYPE_ATTRIBUTE,
)
from pcs.common.file import RawFileError
from pcs.common.reports import (
const,
messages as reports,
)
from pcs.common.types import CibRuleExpressionType
# pylint: disable=too-many-lines
class AllClassesTested(TestCase):
def test_success(self):
self.maxDiff = None
message_classes = frozenset(
name
for name, member in inspect.getmembers(reports, inspect.isclass)
if issubclass(member, reports.ReportItemMessage)
and member
not in {reports.ReportItemMessage, reports.LegacyCommonMessage}
)
test_classes = frozenset(
name
for name, member in inspect.getmembers(
inspect.getmodule(self), inspect.isclass
)
if issubclass(member, NameBuildTest)
)
untested = sorted(message_classes - test_classes)
self.assertEqual(
untested,
[],
f"It seems {len(untested)} subclass(es) of 'ReportItemMessage' are "
"missing tests. Make sure the test classes have the same name as "
"the code classes.",
)
class NameBuildTest(TestCase):
"""
Base class for the testing of message building.
"""
def assert_message_from_report(self, message, report):
self.maxDiff = None
self.assertEqual(message, report.message)
class ResourceForConstraintIsMultiinstance(NameBuildTest):
def test_success(self):
self.assertEqual(
(
"resource1 is a bundle resource, you should use the "
"bundle id: parent1 when adding constraints"
),
reports.ResourceForConstraintIsMultiinstance(
"resource1", "bundle", "parent1"
).message,
)
class DuplicateConstraintsList(NameBuildTest):
def test_single_constraint(self):
self.assert_message_from_report(
"Duplicate constraints:\n"
" resourceA with resourceD (score:score) (id:id123)",
reports.DuplicateConstraintsList(
"rsc_colocation",
[
{
"options": {
"id": "id123",
"rsc": "resourceA",
"with-rsc": "resourceD",
"score": "score",
}
}
],
),
)
def test_multiple_constraints(self):
self.assert_message_from_report(
(
"Duplicate constraints:\n"
" rsc_another rsc=resourceA (id:id123)\n"
" rsc_another rsc=resourceB (id:id321)"
),
reports.DuplicateConstraintsList(
"rsc_another",
[
{"options": {"id": "id123", "rsc": "resourceA"}},
{"options": {"id": "id321", "rsc": "resourceB"}},
],
),
)
class DuplicateConstraintsExist(NameBuildTest):
def test_build_message(self):
self.assert_message_from_report(
"duplicate constraint already exists",
reports.DuplicateConstraintsExist(["c1", "c3", "c0"]),
)
class EmptyResourceSetList(NameBuildTest):
def test_success(self):
self.assert_message_from_report(
"Resource set list is empty",
reports.EmptyResourceSetList(),
)
class RequiredOptionsAreMissing(NameBuildTest):
def test_build_message_with_type(self):
self.assert_message_from_report(
"required TYPE option 'NAME' is missing",
reports.RequiredOptionsAreMissing(["NAME"], option_type="TYPE"),
)
def test_build_message_without_type(self):
self.assert_message_from_report(
"required option 'NAME' is missing",
reports.RequiredOptionsAreMissing(["NAME"]),
)
def test_build_message_with_multiple_names(self):
self.assert_message_from_report(
"required options 'ANOTHER', 'NAME' are missing",
reports.RequiredOptionsAreMissing(["NAME", "ANOTHER"]),
)
class PrerequisiteOptionIsMissing(NameBuildTest):
def test_without_type(self):
self.assert_message_from_report(
"If option 'a' is specified, option 'b' must be specified as well",
reports.PrerequisiteOptionIsMissing("a", "b"),
)
def test_with_type(self):
self.assert_message_from_report(
"If some option 'a' is specified, "
"other option 'b' must be specified as well",
reports.PrerequisiteOptionIsMissing("a", "b", "some", "other"),
)
class PrerequisiteOptionMustBeEnabledAsWell(NameBuildTest):
def test_without_type(self):
self.assert_message_from_report(
"If option 'a' is enabled, option 'b' must be enabled as well",
reports.PrerequisiteOptionMustBeEnabledAsWell("a", "b"),
)
def test_with_type(self):
self.assert_message_from_report(
"If some option 'a' is enabled, "
"other option 'b' must be enabled as well",
reports.PrerequisiteOptionMustBeEnabledAsWell(
"a", "b", "some", "other"
),
)
class PrerequisiteOptionMustBeDisabled(NameBuildTest):
def test_without_type(self):
self.assert_message_from_report(
"If option 'a' is enabled, option 'b' must be disabled",
reports.PrerequisiteOptionMustBeDisabled("a", "b"),
)
def test_with_type(self):
self.assert_message_from_report(
"If some option 'a' is enabled, other option 'b' must be disabled",
reports.PrerequisiteOptionMustBeDisabled("a", "b", "some", "other"),
)
class PrerequisiteOptionMustNotBeSet(NameBuildTest):
def test_without_type(self):
self.assert_message_from_report(
"Cannot set option 'a' because option 'b' is already set",
reports.PrerequisiteOptionMustNotBeSet(
"a",
"b",
),
)
def test_with_type(self):
self.assert_message_from_report(
"Cannot set some option 'a' because other option 'b' is "
"already set",
reports.PrerequisiteOptionMustNotBeSet(
"a",
"b",
option_type="some",
prerequisite_type="other",
),
)
class RequiredOptionOfAlternativesIsMissing(NameBuildTest):
def test_minimal(self):
self.assert_message_from_report(
"option 'aAa', 'bBb' or 'cCc' has to be specified",
reports.RequiredOptionOfAlternativesIsMissing(
["aAa", "cCc", "bBb"]
),
)
def test_with_type(self):
self.assert_message_from_report(
"test option 'aAa' has to be specified",
reports.RequiredOptionOfAlternativesIsMissing(
["aAa"], option_type="test"
),
)
def test_with_deprected(self):
self.assert_message_from_report(
(
"option 'bBb', 'aAa' (deprecated) or 'cCc' (deprecated) has "
"to be specified"
),
reports.RequiredOptionOfAlternativesIsMissing(
["aAa", "cCc", "bBb"], deprecated_names=["cCc", "aAa"]
),
)
class InvalidOptions(NameBuildTest):
def test_build_message_with_type(self):
self.assert_message_from_report(
"invalid TYPE option 'NAME', allowed options are: 'FIRST', "
"'SECOND'",
reports.InvalidOptions(["NAME"], ["SECOND", "FIRST"], "TYPE"),
)
def test_build_message_without_type(self):
self.assert_message_from_report(
"invalid option 'NAME', allowed options are: 'FIRST', 'SECOND'",
reports.InvalidOptions(["NAME"], ["FIRST", "SECOND"], ""),
)
def test_build_message_with_multiple_names(self):
self.assert_message_from_report(
"invalid options: 'ANOTHER', 'NAME', allowed option is 'FIRST'",
reports.InvalidOptions(["NAME", "ANOTHER"], ["FIRST"], ""),
)
def test_pattern(self):
self.assert_message_from_report(
(
"invalid option 'NAME', allowed are options matching patterns: "
"'exec_<name>'"
),
reports.InvalidOptions(["NAME"], [], "", ["exec_<name>"]),
)
def test_allowed_and_patterns(self):
self.assert_message_from_report(
(
"invalid option 'NAME', allowed option is 'FIRST' and options "
"matching patterns: 'exec_<name>'"
),
reports.InvalidOptions(
["NAME"], ["FIRST"], "", allowed_patterns=["exec_<name>"]
),
)
def test_no_allowed_options(self):
self.assert_message_from_report(
"invalid options: 'ANOTHER', 'NAME', there are no options allowed",
reports.InvalidOptions(["NAME", "ANOTHER"], [], ""),
)
class InvalidUserdefinedOptions(NameBuildTest):
def test_without_type(self):
self.assert_message_from_report(
(
"invalid option 'exec_NAME', options may contain "
"a-z A-Z 0-9 /_- characters only"
),
reports.InvalidUserdefinedOptions(["exec_NAME"], "a-z A-Z 0-9 /_-"),
)
def test_with_type(self):
self.assert_message_from_report(
(
"invalid heuristics option 'exec_NAME', heuristics options may "
"contain a-z A-Z 0-9 /_- characters only"
),
reports.InvalidUserdefinedOptions(
["exec_NAME"], "a-z A-Z 0-9 /_-", "heuristics"
),
)
def test_more_options(self):
self.assert_message_from_report(
(
"invalid TYPE options: 'ANOTHER', 'NAME', TYPE options may "
"contain a-z A-Z 0-9 /_- characters only"
),
reports.InvalidUserdefinedOptions(
["NAME", "ANOTHER"], "a-z A-Z 0-9 /_-", "TYPE"
),
)
class InvalidOptionType(NameBuildTest):
def test_allowed_string(self):
self.assert_message_from_report(
"specified option name is not valid, use allowed types",
reports.InvalidOptionType("option name", "allowed types"),
)
def test_allowed_list(self):
self.assert_message_from_report(
"specified option name is not valid, use 'allowed', 'types'",
reports.InvalidOptionType("option name", ["types", "allowed"]),
)
class InvalidOptionValue(NameBuildTest):
def test_multiple_allowed_values(self):
self.assert_message_from_report(
"'VALUE' is not a valid NAME value, use 'FIRST', 'SECOND'",
reports.InvalidOptionValue("NAME", "VALUE", ["SECOND", "FIRST"]),
)
def test_textual_hint(self):
self.assert_message_from_report(
"'VALUE' is not a valid NAME value, use some hint",
reports.InvalidOptionValue("NAME", "VALUE", "some hint"),
)
def test_cannot_be_empty(self):
self.assert_message_from_report(
"NAME cannot be empty",
reports.InvalidOptionValue(
"NAME", "VALUE", allowed_values=None, cannot_be_empty=True
),
)
def test_cannot_be_empty_with_hint(self):
self.assert_message_from_report(
"NAME cannot be empty, use 'FIRST', 'SECOND'",
reports.InvalidOptionValue(
"NAME", "VALUE", ["SECOND", "FIRST"], cannot_be_empty=True
),
)
def test_forbidden_characters(self):
self.assert_message_from_report(
r"NAME cannot contain }{\r\n characters",
reports.InvalidOptionValue(
"NAME",
"VALUE",
allowed_values=None,
forbidden_characters="}{\\r\\n",
),
)
def test_forbidden_characters_with_hint(self):
self.assert_message_from_report(
r"NAME cannot contain }{\r\n characters, use 'FIRST', 'SECOND'",
reports.InvalidOptionValue(
"NAME",
"VALUE",
["SECOND", "FIRST"],
forbidden_characters="}{\\r\\n",
),
)
def test_cannot_be_empty_and_forbidden_characters(self):
self.assert_message_from_report(
"NAME cannot be empty, use 'FIRST', 'SECOND'",
reports.InvalidOptionValue(
"NAME", "VALUE", ["SECOND", "FIRST"], True
),
)
class DeprecatedOption(NameBuildTest):
def test_no_desc_hint_array(self):
self.assert_message_from_report(
"option 'option name' is deprecated and should not be used,"
" use 'new_a', 'new_b' instead",
reports.DeprecatedOption("option name", ["new_b", "new_a"], ""),
)
def test_desc_hint_string(self):
self.assert_message_from_report(
"option type option 'option name' is deprecated and should not be"
" used, use 'new option' instead",
reports.DeprecatedOption(
"option name", ["new option"], "option type"
),
)
class DeprecatedOptionValue(NameBuildTest):
def test_replaced_by(self):
self.assert_message_from_report(
(
"Value 'deprecatedValue' of option optionA is deprecated and "
"should not be used, use 'newValue' value instead"
),
reports.DeprecatedOptionValue(
"optionA", "deprecatedValue", "newValue"
),
)
def test_no_replacement(self):
self.assert_message_from_report(
(
"Value 'deprecatedValue' of option optionA is deprecated and "
"should not be used"
),
reports.DeprecatedOptionValue("optionA", "deprecatedValue"),
)
class MutuallyExclusiveOptions(NameBuildTest):
def test_build_message(self):
self.assert_message_from_report(
"Only one of some options 'a' and 'b' can be used",
reports.MutuallyExclusiveOptions(["b", "a"], "some"),
)
class InvalidCibContent(NameBuildTest):
def test_message_can_be_more_verbose(self):
report = "no verbose\noutput\n"
self.assert_message_from_report(
"invalid cib:\n{0}".format(report),
reports.InvalidCibContent(report, True),
)
def test_message_cannot_be_more_verbose(self):
report = "some verbose\noutput"
self.assert_message_from_report(
"invalid cib:\n{0}".format(report),
reports.InvalidCibContent(report, False),
)
class InvalidIdIsEmpty(NameBuildTest):
def test_all(self):
self.assert_message_from_report(
"description cannot be empty",
reports.InvalidIdIsEmpty("description"),
)
class InvalidIdBadChar(NameBuildTest):
def test_build_message_with_first_char_invalid(self):
self.assert_message_from_report(
(
"invalid ID_DESCRIPTION 'ID', 'INVALID_CHARACTER' is not a"
" valid first character for a ID_DESCRIPTION"
),
reports.InvalidIdBadChar(
"ID", "ID_DESCRIPTION", "INVALID_CHARACTER", is_first_char=True
),
)
def test_build_message_with_non_first_char_invalid(self):
self.assert_message_from_report(
(
"invalid ID_DESCRIPTION 'ID', 'INVALID_CHARACTER' is not a"
" valid character for a ID_DESCRIPTION"
),
reports.InvalidIdBadChar(
"ID", "ID_DESCRIPTION", "INVALID_CHARACTER", is_first_char=False
),
)
class InvalidTimeoutValue(NameBuildTest):
def test_all(self):
self.assert_message_from_report(
"'24h' is not a valid number of seconds to wait",
reports.InvalidTimeoutValue("24h"),
)
class InvalidScore(NameBuildTest):
def test_all(self):
self.assert_message_from_report(
"invalid score '1M', use integer or INFINITY or -INFINITY",
reports.InvalidScore("1M"),
)
class MultipleScoreOptions(NameBuildTest):
def test_all(self):
self.assert_message_from_report(
"multiple score options cannot be specified",
reports.MultipleScoreOptions(),
)
class RunExternalProcessStarted(NameBuildTest):
def test_build_message_minimal(self):
self.assert_message_from_report(
"Running: COMMAND\nEnvironment:\n",
reports.RunExternalProcessStarted("COMMAND", "", dict()),
)
def test_build_message_with_stdin(self):
self.assert_message_from_report(
(
"Running: COMMAND\nEnvironment:\n"
"--Debug Input Start--\n"
"STDIN\n"
"--Debug Input End--\n"
),
reports.RunExternalProcessStarted("COMMAND", "STDIN", dict()),
)
def test_build_message_with_env(self):
self.assert_message_from_report(
("Running: COMMAND\nEnvironment:\n" " env_a=A\n" " env_b=B\n"),
reports.RunExternalProcessStarted(
"COMMAND",
"",
{
"env_a": "A",
"env_b": "B",
},
),
)
def test_build_message_maximal(self):
self.assert_message_from_report(
(
"Running: COMMAND\nEnvironment:\n"
" env_a=A\n"
" env_b=B\n"
"--Debug Input Start--\n"
"STDIN\n"
"--Debug Input End--\n"
),
reports.RunExternalProcessStarted(
"COMMAND",
"STDIN",
{
"env_a": "A",
"env_b": "B",
},
),
)
def test_insidious_environment(self):
self.assert_message_from_report(
(
"Running: COMMAND\nEnvironment:\n"
" test=a:{green},b:{red}\n"
"--Debug Input Start--\n"
"STDIN\n"
"--Debug Input End--\n"
),
reports.RunExternalProcessStarted(
"COMMAND",
"STDIN",
{
"test": "a:{green},b:{red}",
},
),
)
class RunExternalProcessFinished(NameBuildTest):
def test_all(self):
self.assert_message_from_report(
(
"Finished running: com-mand\n"
"Return value: 0\n"
"--Debug Stdout Start--\n"
"STDOUT\n"
"--Debug Stdout End--\n"
"--Debug Stderr Start--\n"
"STDERR\n"
"--Debug Stderr End--\n"
),
reports.RunExternalProcessFinished(
"com-mand", 0, "STDOUT", "STDERR"
),
)
class RunExternalProcessError(NameBuildTest):
def test_all(self):
self.assert_message_from_report(
"unable to run command com-mand: reason",
reports.RunExternalProcessError("com-mand", "reason"),
)
class NoActionNecessary(NameBuildTest):
def test_all(self):
self.assert_message_from_report(
"No action necessary, requested change would have no effect",
reports.NoActionNecessary(),
)
class NodeCommunicationStarted(NameBuildTest):
def test_build_message_with_data(self):
self.assert_message_from_report(
(
"Sending HTTP Request to: TARGET\n"
"--Debug Input Start--\n"
"DATA\n"
"--Debug Input End--\n"
),
reports.NodeCommunicationStarted("TARGET", "DATA"),
)
def test_build_message_without_data(self):
self.assert_message_from_report(
"Sending HTTP Request to: TARGET\n",
reports.NodeCommunicationStarted("TARGET", ""),
)
class NodeCommunicationFinished(NameBuildTest):
def test_all(self):
self.assert_message_from_report(
(
"Finished calling: node1\n"
"Response Code: 0\n"
"--Debug Response Start--\n"
"DATA\n"
"--Debug Response End--\n"
),
reports.NodeCommunicationFinished("node1", 0, "DATA"),
)
class NodeCommunicationDebugInfo(NameBuildTest):
def test_all(self):
self.assert_message_from_report(
(
"Communication debug info for calling: node1\n"
"--Debug Communication Info Start--\n"
"DATA\n"
"--Debug Communication Info End--\n"
),
reports.NodeCommunicationDebugInfo("node1", "DATA"),
)
class NodeCommunicationNotConnected(NameBuildTest):
def test_all(self):
self.assert_message_from_report(
"Unable to connect to node2 (this is reason)",
reports.NodeCommunicationNotConnected("node2", "this is reason"),
)
class NodeCommunicationNoMoreAddresses(NameBuildTest):
def test_success(self):
self.assert_message_from_report(
"Unable to connect to 'node_name' via any of its addresses",
reports.NodeCommunicationNoMoreAddresses(
"node_name",
"my/request",
),
)
class NodeCommunicationErrorNotAuthorized(NameBuildTest):
def test_success(self):
self.assert_message_from_report(
"Unable to authenticate to node1 (some error)",
reports.NodeCommunicationErrorNotAuthorized(
"node1", "some-command", "some error"
),
)
class NodeCommunicationErrorPermissionDenied(NameBuildTest):
def test_all(self):
self.assert_message_from_report(
"node3: Permission denied (reason)",
reports.NodeCommunicationErrorPermissionDenied(
"node3", "com-mand", "reason"
),
)
class NodeCommunicationErrorUnsupportedCommand(NameBuildTest):
def test_all(self):
self.assert_message_from_report(
"node1: Unsupported command (reason), try upgrading pcsd",
reports.NodeCommunicationErrorUnsupportedCommand(
"node1", "com-mand", "reason"
),
)
class NodeCommunicationCommandUnsuccessful(NameBuildTest):
def test_all(self):
self.assert_message_from_report(
"node1: reason",
reports.NodeCommunicationCommandUnsuccessful(
"node1", "com-mand", "reason"
),
)
class NodeCommunicationError(NameBuildTest):
def test_all(self):
self.assert_message_from_report(
"Error connecting to node1 (reason)",
reports.NodeCommunicationError("node1", "com-mand", "reason"),
)
class NodeCommunicationErrorUnableToConnect(NameBuildTest):
def test_all(self):
self.assert_message_from_report(
"Unable to connect to node1 (reason)",
reports.NodeCommunicationErrorUnableToConnect(
"node1", "com-mand", "reason"
),
)
class NodeCommunicationErrorTimedOut(NameBuildTest):
def test_success(self):
self.assert_message_from_report(
(
"node-1: Connection timeout (Connection timed out after 60049 "
"milliseconds)"
),
reports.NodeCommunicationErrorTimedOut(
"node-1",
"/remote/command",
"Connection timed out after 60049 milliseconds",
),
)
class NodeCommunicationProxyIsSet(NameBuildTest):
def test_minimal(self):
self.assert_message_from_report(
"Proxy is set in environment variables, try disabling it",
reports.NodeCommunicationProxyIsSet(),
)
def test_with_node(self):
self.assert_message_from_report(
"Proxy is set in environment variables, try disabling it",
reports.NodeCommunicationProxyIsSet(node="node1"),
)
def test_with_address(self):
self.assert_message_from_report(
"Proxy is set in environment variables, try disabling it",
reports.NodeCommunicationProxyIsSet(address="aaa"),
)
def test_all(self):
self.assert_message_from_report(
"Proxy is set in environment variables, try disabling it",
reports.NodeCommunicationProxyIsSet(node="node1", address="aaa"),
)
class NodeCommunicationRetrying(NameBuildTest):
def test_success(self):
self.assert_message_from_report(
(
"Unable to connect to 'node_name' via address 'failed.address' "
"and port '2224'. Retrying request 'my/request' via address "
"'next.address' and port '2225'"
),
reports.NodeCommunicationRetrying(
"node_name",
"failed.address",
"2224",
"next.address",
"2225",
"my/request",
),
)
class DefaultsCanBeOverriden(NameBuildTest):
def test_message(self):
self.assert_message_from_report(
(
"Defaults do not apply to resources which override them with "
"their own defined values"
),
reports.DefaultsCanBeOverriden(),
)
class CorosyncAuthkeyWrongLength(NameBuildTest):
def test_at_most_allowed_singular_provided_plural(self):
self.assert_message_from_report(
(
"At least 0 and at most 1 byte key must be provided for "
"a corosync authkey, 2 bytes key provided"
),
reports.CorosyncAuthkeyWrongLength(2, 0, 1),
)
def test_at_most_allowed_plural_provided_singular(self):
self.assert_message_from_report(
(
"At least 2 and at most 3 bytes key must be provided for "
"a corosync authkey, 1 byte key provided"
),
reports.CorosyncAuthkeyWrongLength(1, 2, 3),
)
def test_exactly_allowed_singular_provided_plural(self):
self.assert_message_from_report(
(
"1 byte key must be provided for a corosync authkey, 2 bytes "
"key provided"
),
reports.CorosyncAuthkeyWrongLength(2, 1, 1),
)
def test_exactly_allowed_plural_provided_singular(self):
self.assert_message_from_report(
(
"2 bytes key must be provided for a corosync authkey, 1 byte "
"key provided"
),
reports.CorosyncAuthkeyWrongLength(1, 2, 2),
)
class CorosyncConfigDistributionStarted(NameBuildTest):
def test_all(self):
self.assert_message_from_report(
"Sending updated corosync.conf to nodes...",
reports.CorosyncConfigDistributionStarted(),
)
# TODO: consider generalizing
class CorosyncConfigAcceptedByNode(NameBuildTest):
def test_all(self):
self.assert_message_from_report(
"node1: Succeeded", reports.CorosyncConfigAcceptedByNode("node1")
)
class CorosyncConfigDistributionNodeError(NameBuildTest):
def test_all(self):
self.assert_message_from_report(
"node1: Unable to set corosync config",
reports.CorosyncConfigDistributionNodeError("node1"),
)
class CorosyncNotRunningCheckStarted(NameBuildTest):
def test_all(self):
self.assert_message_from_report(
"Checking corosync is not running on nodes...",
reports.CorosyncNotRunningCheckStarted(),
)
class CorosyncNotRunningCheckNodeError(NameBuildTest):
def test_all(self):
self.assert_message_from_report(
"node1: Unable to check if corosync is not running",
reports.CorosyncNotRunningCheckNodeError("node1"),
)
class CorosyncNotRunningOnNode(NameBuildTest):
def test_all(self):
self.assert_message_from_report(
"node2: corosync is not running",
reports.CorosyncNotRunningOnNode("node2"),
)
class CorosyncRunningOnNode(NameBuildTest):
def test_all(self):
self.assert_message_from_report(
"node3: corosync is running", reports.CorosyncRunningOnNode("node3")
)
class CorosyncQuorumGetStatusError(NameBuildTest):
def test_success(self):
self.assert_message_from_report(
"Unable to get quorum status: a reason",
reports.CorosyncQuorumGetStatusError("a reason"),
)
def test_success_with_node(self):
self.assert_message_from_report(
"node1: Unable to get quorum status: a reason",
reports.CorosyncQuorumGetStatusError("a reason", "node1"),
)
class CorosyncQuorumHeuristicsEnabledWithNoExec(NameBuildTest):
def test_message(self):
self.assert_message_from_report(
(
"No exec_NAME options are specified, so heuristics are "
"effectively disabled"
),
reports.CorosyncQuorumHeuristicsEnabledWithNoExec(),
)
class CorosyncQuorumSetExpectedVotesError(NameBuildTest):
def test_all(self):
self.assert_message_from_report(
"Unable to set expected votes: reason",
reports.CorosyncQuorumSetExpectedVotesError("reason"),
)
class CorosyncConfigReloaded(NameBuildTest):
def test_with_node(self):
self.assert_message_from_report(
"node1: Corosync configuration reloaded",
reports.CorosyncConfigReloaded("node1"),
)
def test_without_node(self):
self.assert_message_from_report(
"Corosync configuration reloaded",
reports.CorosyncConfigReloaded(),
)
class CorosyncConfigReloadError(NameBuildTest):
def test_with_node(self):
self.assert_message_from_report(
"node1: Unable to reload corosync configuration: a reason",
reports.CorosyncConfigReloadError("a reason", "node1"),
)
def test_without_node(self):
self.assert_message_from_report(
"Unable to reload corosync configuration: different reason",
reports.CorosyncConfigReloadError("different reason"),
)
class CorosyncConfigReloadNotPossible(NameBuildTest):
def test_success(self):
self.assert_message_from_report(
(
"node1: Corosync is not running, therefore reload of the "
"corosync configuration is not possible"
),
reports.CorosyncConfigReloadNotPossible("node1"),
)
class CorosyncConfigUnsupportedTransport(NameBuildTest):
def test_success(self):
self.assert_message_from_report(
(
"Transport 'netk' currently configured in corosync.conf is "
"unsupported. Supported transport types are: 'knet', 'udp', "
"'udpu'"
),
reports.CorosyncConfigUnsupportedTransport(
"netk", ["udp", "knet", "udpu"]
),
)
class ParseErrorCorosyncConfMissingClosingBrace(NameBuildTest):
def test_all(self):
self.assert_message_from_report(
"Unable to parse corosync config: missing closing brace",
reports.ParseErrorCorosyncConfMissingClosingBrace(),
)