Re: [PATCH] Implement config file testing mode.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Vladislav,

> Hi Jan,
> 
> 15.07.2014 18:25, Jan Friesse wrote:
>> Vladislav,
>> generally good idea. But I'm thinking about usage. What exactly is your
>> use case?
> 
> I plan to use it to test configuration file validity after it is
> automatically created by my higher-level tools if for some reason
> regression testing didn't catch config anomalies.
> 
>>
>> Because I can imagine use case, where user is testing config before
>> running corosync on terminal or via some tool (let's say graphic one).
>> But then, if I would be such user, I would probably like to see parser
>> errors on terminal/in tool instead of trying to find them on log (what
>> may be problem if logging section of configuration is improperly
>> configured).
>>
>> So (at least from my point of view), such test mode should set ouput to
>> stdout (or stderr) and don't allow config to change it.
>>
>> What do you think?
> 
> Yep, that would be nice to have too. Although return code is more
> important. Then, if you decide to go that way, implementing '-q' (quiet)
> or '-v' (verbose on stdout) would also be nice.
> 

Yep, agree. Do you think you can prepare such patch? ;)

Anyway, I've changed your patch to include "t" in the getopt string and
pushed.

Regards,
  Honza

>>
>> Regards,
>>   Honza
>>
>> Vladislav Bogdanov napsal(a):
>>> Signed-off-by: Vladislav Bogdanov <bubble@xxxxxxxxxxxxx>
>>> ---
>>>   exec/main.c    |   17 ++++++++++++++---
>>>   man/corosync.8 |    3 +++
>>>   2 files changed, 17 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/exec/main.c b/exec/main.c
>>> index be765de..864fe33 100644
>>> --- a/exec/main.c
>>> +++ b/exec/main.c
>>> @@ -1190,7 +1190,7 @@ int main (int argc, char **argv, char **envp)
>>>       const char *error_string;
>>>       struct totem_config totem_config;
>>>       int res, ch;
>>> -    int background, setprio;
>>> +    int background, setprio, testonly;
>>>       struct stat stat_out;
>>>       enum e_corosync_done flock_err;
>>>       uint64_t totem_config_warnings;
>>> @@ -1200,6 +1200,7 @@ int main (int argc, char **argv, char **envp)
>>>        */
>>>       background = 1;
>>>       setprio = 0;
>>> +    testonly = 0;
>>>
>>>       while ((ch = getopt (argc, argv, "fprv")) != EOF) {
>>>
>>> @@ -1212,6 +1213,9 @@ int main (int argc, char **argv, char **envp)
>>>               case 'r':
>>>                   setprio = 1;
>>>                   break;
>>> +            case 't':
>>> +                testonly = 1;
>>> +                break;
>>>               case 'v':
>>>                   printf ("Corosync Cluster Engine, version '%s'\n",
>>> VERSION);
>>>                   printf ("Copyright (c) 2006-2009 Red Hat, Inc.\n");
>>> @@ -1224,6 +1228,7 @@ int main (int argc, char **argv, char **envp)
>>>                       "usage:\n"\
>>>                       "        -f     : Start application in
>>> foreground.\n"\
>>>                       "        -p     : Does nothing.    \n"\
>>> +                    "        -t     : Test configuration and exit.\n"\
>>>                       "        -r     : Set round robin realtime
>>> scheduling \n"\
>>>                       "        -v     : Display version and SVN
>>> revision of Corosync and exit.\n");
>>>                   logsys_system_fini();
>>> @@ -1283,8 +1288,10 @@ int main (int argc, char **argv, char **envp)
>>>           corosync_exit_error (COROSYNC_DONE_LOGCONFIGREAD);
>>>       }
>>>
>>> -    log_printf (LOGSYS_LEVEL_NOTICE, "Corosync Cluster Engine ('%s'):
>>> started and ready to provide service.", VERSION);
>>> -    log_printf (LOGSYS_LEVEL_INFO, "Corosync built-in features:"
>>> PACKAGE_FEATURES "");
>>> +    if (!testonly) {
>>> +        log_printf (LOGSYS_LEVEL_NOTICE, "Corosync Cluster Engine
>>> ('%s'): started and ready to provide service.", VERSION);
>>> +        log_printf (LOGSYS_LEVEL_INFO, "Corosync built-in features:"
>>> PACKAGE_FEATURES "");
>>> +    }
>>>
>>>       /*
>>>        * Make sure required directory is present
>>> @@ -1336,6 +1343,10 @@ int main (int argc, char **argv, char **envp)
>>>           corosync_exit_error (COROSYNC_DONE_MAINCONFIGREAD);
>>>       }
>>>
>>> +    if (testonly) {
>>> +        corosync_exit_error (COROSYNC_DONE_EXIT);
>>> +    }
>>> +
>>>       ip_version = totem_config.ip_version;
>>>
>>>       totem_config.totem_memb_ring_id_create_or_load =
>>> corosync_ring_id_create_or_load;
>>> diff --git a/man/corosync.8 b/man/corosync.8
>>> index 59b2dda..559b392 100644
>>> --- a/man/corosync.8
>>> +++ b/man/corosync.8
>>> @@ -50,6 +50,9 @@ Does nothing (was: "Do not set process priority" -
>>> this is now the default).
>>>   .B -r
>>>   Set round robin realtime scheduling.
>>>   .TP
>>> +.B -t
>>> +Test configuration and then exit.
>>> +.TP
>>>   .B -v
>>>   Display version and SVN revision of Corosync and exit.
>>>   .SH SEE ALSO
>>>
>>
> 

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss




[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux