* Test quorum */
| 767 | * Test quorum |
| 768 | */ |
| 769 | static int test_quorum (void) { |
| 770 | cmap_handle_t cmap_handle; |
| 771 | cs_error_t err; |
| 772 | unsigned int instance_id; |
| 773 | pthread_t kill_thread; |
| 774 | char *str; |
| 775 | uint32_t expected_votes; |
| 776 | |
| 777 | err = cmap_initialize (&cmap_handle); |
| 778 | if (err != CS_OK) { |
| 779 | printf ("Could not initialize Cluster Map API instance error %d. Test skipped\n", err); |
| 780 | return (1); |
| 781 | } |
| 782 | |
| 783 | |
| 784 | if (cmap_get_string(cmap_handle, "quorum.provider", &str) != CS_OK) { |
| 785 | printf ("Could not get \"provider\" key: %d. Test skipped\n", err); |
| 786 | return (1); |
| 787 | } |
| 788 | if (strcmp(str, "corosync_votequorum") != 0) { |
| 789 | printf ("Provider is not corosync_votequorum. Test skipped\n"); |
| 790 | free(str); |
| 791 | return (1); |
| 792 | } |
| 793 | free(str); |
| 794 | |
| 795 | if (cmap_get_uint32(cmap_handle, "quorum.expected_votes", &expected_votes) != CS_OK) { |
| 796 | printf ("Could not get \"expected_votes\" key: %d. Test skipped\n", err); |
| 797 | return (1); |
| 798 | } |
| 799 | |
| 800 | if (expected_votes != 1) { |
| 801 | printf ("Expected_votes is not 1. Test skipped\n"); |
| 802 | return (1); |
| 803 | } |
| 804 | |
| 805 | /* |
| 806 | * Set to not quorate |
| 807 | */ |
| 808 | err = cmap_set_uint32(cmap_handle, "quorum.expected_votes", 2); |
| 809 | if (err != CS_OK) { |
| 810 | printf ("Can't set map key. Error %d\n", err); |
| 811 | return (2); |
| 812 | } |
| 813 | |
| 814 | printf ("%s: initialize\n", __FUNCTION__); |
| 815 | err = sam_initialize (2000, SAM_RECOVERY_POLICY_QUORUM_RESTART); |
| 816 | if (err != CS_OK) { |
| 817 | fprintf (stderr, "Can't initialize SAM API. Error %d\n", err); |
| 818 | return 2; |
| 819 | } |
| 820 | |
| 821 | printf ("%s: register\n", __FUNCTION__); |
| 822 | err = sam_register (&instance_id); |
| 823 | if (err != CS_OK) { |
| 824 | fprintf (stderr, "Can't register. Error %d\n", err); |
| 825 | return 2; |
| 826 | } |
nothing calls this directly
no test coverage detected