Updated feedback test.
This commit is contained in:
@ -21,65 +21,90 @@
|
|||||||
* @verbatim
|
* @verbatim
|
||||||
* Revision History
|
* Revision History
|
||||||
*
|
*
|
||||||
* Date Who Description
|
* Date Who Description
|
||||||
* 09-03-2015 Markus Mäkelä Initial implementation
|
* 09-03-2015 Markus Mäkelä Initial implementation
|
||||||
|
* 10-03-2015 Massimiliano Pinto Added http_check
|
||||||
*
|
*
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define FAILTEST(s) printf("TEST FAILED: " s "\n");return 1;
|
#define FAILTEST(s) printf("TEST FAILED: " s "\n");return 1;
|
||||||
|
#include <my_config.h>
|
||||||
|
#include <mysql.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <notification.h>
|
#include <notification.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <test_utils.h>
|
|
||||||
#include <housekeeper.h>
|
#include <housekeeper.h>
|
||||||
#include <buffer.h>
|
#include <buffer.h>
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
|
|
||||||
|
static char* server_options[] = {
|
||||||
|
"MariaDB Corporation MaxScale",
|
||||||
|
"--no-defaults",
|
||||||
|
"--datadir=",
|
||||||
|
"--language=",
|
||||||
|
"--skip-innodb",
|
||||||
|
"--default-storage-engine=myisam",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
const int num_elements = (sizeof(server_options) / sizeof(char *)) - 1;
|
||||||
|
|
||||||
|
static char* server_groups[] = {
|
||||||
|
"embedded",
|
||||||
|
"server",
|
||||||
|
"server",
|
||||||
|
"embedded",
|
||||||
|
"server",
|
||||||
|
"server",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
FEEDBACK_CONF* fc;
|
FEEDBACK_CONF* fc;
|
||||||
char* home;
|
|
||||||
char* cnf;
|
|
||||||
GWBUF* buf;
|
GWBUF* buf;
|
||||||
regex_t re;
|
regex_t re;
|
||||||
|
char* home;
|
||||||
|
char* cnf;
|
||||||
|
|
||||||
init_test_env();
|
hkinit();
|
||||||
home = getenv("MAXSCALE_HOME");
|
|
||||||
|
|
||||||
if(home == NULL)
|
mysql_library_init(num_elements, server_options, server_groups);
|
||||||
|
|
||||||
|
if ((fc = config_get_feedback_data()) == NULL)
|
||||||
{
|
{
|
||||||
FAILTEST("MAXSCALE_HOME was not defined.");
|
FAILTEST("Configuration for Feedback was NULL.");
|
||||||
}
|
}
|
||||||
printf("Home: %s\n",home);
|
|
||||||
|
|
||||||
cnf = malloc(strlen(home) + strlen("/etc/MaxScale.cnf") + 1);
|
fc->feedback_enable = 1;
|
||||||
strcpy(cnf,home);
|
fc->feedback_user_info = "TEST_user_info";
|
||||||
strcat(cnf,"/etc/MaxScale.cnf");
|
fc->mac_sha1 = "TEST_user_info";
|
||||||
|
fc->feedback_url = "http://127.0.0.1/post.php";
|
||||||
|
|
||||||
printf("Config: %s\n",cnf);
|
fc->feedback_last_action = _NOTIFICATION_SEND_PENDING;
|
||||||
|
fc->feedback_timeout = _NOTIFICATION_OPERATION_TIMEOUT;
|
||||||
config_load(cnf);
|
fc->feedback_connect_timeout = _NOTIFICATION_CONNECT_TIMEOUT;
|
||||||
|
fc->release_info = "";
|
||||||
if((fc = config_get_feedback_data()) == NULL ||
|
fc->sysname="";
|
||||||
fc->feedback_user_info == NULL)
|
|
||||||
{
|
|
||||||
FAILTEST("Configuration was NULL.");
|
|
||||||
}
|
|
||||||
|
|
||||||
regcomp(&re,fc->feedback_user_info,0);
|
regcomp(&re,fc->feedback_user_info,0);
|
||||||
|
|
||||||
module_create_feedback_report(&buf,NULL,fc);
|
module_create_feedback_report(&buf,NULL,fc);
|
||||||
printf("%s",(char*)buf->start);
|
|
||||||
|
|
||||||
if(regexec(&re,(char*)buf->start,0,NULL,0))
|
if(regexec(&re,(char*)buf->start,0,NULL,0))
|
||||||
{
|
{
|
||||||
FAILTEST("Regex match of 'user_info' failed.");
|
FAILTEST("Regex match of 'user_info' failed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (do_http_post(buf, fc) != 0)
|
||||||
|
{
|
||||||
|
FAILTEST("Http send failed\n");
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user