http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/resources/logsearch.properties ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/resources/logsearch.properties b/ambari-logsearch/ambari-logsearch-portal/src/main/resources/logsearch.properties deleted file mode 100755 index b6cc4a5..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/resources/logsearch.properties +++ /dev/null @@ -1,63 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#logsearch.solr.url=http://host:port/solr -logsearch.solr.url= - -#Solr Core -logsearch.solr.collection.service.logs=hadoop_logs -#logsearch.solr.collection.service.logs=ranger_audits -logsearch.solr.collection.history=history -logsearch.service.logs.split.interval.mins=none -logsearch.collection.service.logs.numshards=1 -logsearch.collection.service.logs.replication.factor=1 - -#If set, metrics will be sent to Ambari -#logsearch.solr.metrics.collector.hosts=example.com -logsearch.solr.metrics.collector.hosts= -logsearch.solr.audit.logs.url= -#logsearch.solr.collection.audit.logs=collection_name -logsearch.solr.collection.audit.logs=ranger_audits -logsearch.audit.logs.split.interval.mins=none -logsearch.collection.audit.logs.numshards=1 -logsearch.collection.audit.logs.replication.factor=1 - -#Logfeeder Settings -logsearch.logfeeder.include.default.level=fatal,error,warn - -#Authentication settings -#Note: Simple will be supported only if file ,ldap and external_auth all three are disabled. -logsearch.auth.file.enable=true -logsearch.auth.ldap.enable=false -logsearch.auth.simple.enable=false -logsearch.auth.external_auth.enable=false -logsearch.auth.external_auth.host_url=http://ip:port -logsearch.auth.external_auth.login_url=/api/v1/users/$USERNAME/privileges?fields=* -#Note: Use comma(,) for separation of multiple roles -logsearch.roles.allowed=AMBARI.ADMINISTRATOR - - -#communication protocol i.e http or https etc. -logsearch.protocol= - -logsearch.solr.kerberos.enable=false -logsearch.solr.jaas.file=/usr/lib/ambari-logsearch-portal/logsearch_solr_jaas.conf - - -#portal Kerberos -logsearch.spnego.kerberos.enabled=false -logsearch.spnego.kerberos.keytab= -logsearch.spnego.kerberos.principal= -logsearch.spnego.kerberos.host= \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/resources/swagger/swagger.html ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/resources/swagger/swagger.html b/ambari-logsearch/ambari-logsearch-portal/src/main/resources/swagger/swagger.html deleted file mode 100644 index 33346d3..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/resources/swagger/swagger.html +++ /dev/null @@ -1,115 +0,0 @@ -<!DOCTYPE html> -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<html> -<head> - <title>Log Search REST API</title> - <link rel="icon" type="image/png" href="images/favicon-32x32.png" sizes="32x32" /> - <link rel="icon" type="image/png" href="images/favicon-16x16.png" sizes="16x16" /> - <link href='css/typography.css' media='screen' rel='stylesheet' type='text/css'/> - <link href='css/reset.css' media='screen' rel='stylesheet' type='text/css'/> - <link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/> - <link href='css/reset.css' media='print' rel='stylesheet' type='text/css'/> - <link href='css/print.css' media='print' rel='stylesheet' type='text/css'/> - <script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script> - <script src='lib/jquery.slideto.min.js' type='text/javascript'></script> - <script src='lib/jquery.wiggle.min.js' type='text/javascript'></script> - <script src='lib/jquery.ba-bbq.min.js' type='text/javascript'></script> - <script src='lib/handlebars-2.0.0.js' type='text/javascript'></script> - <script src='lib/underscore-min.js' type='text/javascript'></script> - <script src='lib/backbone-min.js' type='text/javascript'></script> - <script src='swagger-ui.js' type='text/javascript'></script> - <script src='lib/highlight.7.3.pack.js' type='text/javascript'></script> - <script src='lib/marked.js' type='text/javascript'></script> - <script src='lib/swagger-oauth.js' type='text/javascript'></script> - - <script type="text/javascript"> - $(function () { - var url = window.location.search.match(/url=([^&]+)/); - if (url && url.length > 1) { - url = decodeURIComponent(url[1]); - } else { - var urlPrefix = location.protocol +'//'+ location.hostname+(location.port ? ':'+location.port: ''); - url = urlPrefix + "/api/v1/swagger.yaml"; - } - window.swaggerUi = new SwaggerUi({ - url: url, - dom_id: "swagger-ui-container", - supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'], - onComplete: function(swaggerApi, swaggerUi){ - if(typeof initOAuth == "function") { - initOAuth({ - clientId: "your-client-id", - realm: "your-realms", - appName: "your-app-name" - }); - } - - $('pre code').each(function(i, e) { - hljs.highlightBlock(e) - }); - - addApiKeyAuthorization(); - }, - onFailure: function(data) { - log("Unable to Load SwaggerUI"); - }, - docExpansion: "none", - apisSorter: "alpha", - showRequestHeaders: false - }); - - function addApiKeyAuthorization(){ - var username = encodeURIComponent($('#input_username')[0].value); - var password = encodeURIComponent($('#input_password')[0].value); - if (username && username.trim() != "" && password && password != "") { - var apiKeyAuth = new SwaggerClient.PasswordAuthorization("Authorization", username, password); - window.swaggerUi.api.clientAuthorizations.add("key", apiKeyAuth); - log("added authorization header: " + 'Basic ' + btoa(username + ':' + password)); - } - } - - $('#input_username, #input_password').change(addApiKeyAuthorization); - - window.swaggerUi.load(); - - function log() { - if ('console' in window) { - console.log.apply(console, arguments); - } - } - }); - </script> -</head> - -<body class="swagger-section"> -<div id='header'> - <div class="swagger-ui-wrap"> - <a id="logo" href="http://swagger.io">swagger</a> - <form id='api_selector'> - <div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div> - <div class="input"><input placeholder="username" id="input_username" name="username" type="text" size="10"></div> - <div class="input"><input placeholder="password" id="input_password" name="password" type="password" size="10"></div> - <div class='input'><a id="explore" href="#">Explore</a></div> - </form> - </div> -</div> - -<div id="message-bar" class="swagger-ui-wrap"> </div> -<div id="swagger-ui-container" class="swagger-ui-wrap"></div> -</body> -</html> http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/resources/templates/audit_log_txt.ftl ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/resources/templates/audit_log_txt.ftl b/ambari-logsearch/ambari-logsearch-portal/src/main/resources/templates/audit_log_txt.ftl deleted file mode 100644 index 587e366..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/resources/templates/audit_log_txt.ftl +++ /dev/null @@ -1,42 +0,0 @@ -<#-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> ---------------------------------SUMMARY----------------------------------- -Users = ${usersSummary} -Resources = ${resourcesSummary} - - - - -Users Components/Access --------------------------------------------------------------------------- -<#if users??> - <#list users as user> -${user.data} - </#list> -</#if> - - - - - -Resources Components/Access --------------------------------------------------------------------------- -<#if resources??> - <#list resources as resource> -${resource.data} - </#list> -</#if> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/resources/templates/service_log_txt.ftl ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/resources/templates/service_log_txt.ftl b/ambari-logsearch/ambari-logsearch-portal/src/main/resources/templates/service_log_txt.ftl deleted file mode 100644 index 8a5e19d..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/resources/templates/service_log_txt.ftl +++ /dev/null @@ -1,36 +0,0 @@ -<#-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -**********************Summary********************** -Number of Logs : ${numberOfLogs} -From : ${from} -To : ${to} -Host : ${hosts} -Component : ${components} -Levels : ${levels} -Format : ${format} - -Included String: [${iString}] - -Excluded String: [${eString}] - -************************Logs*********************** -2016-09-26 11:49:19,723 WARN MainThread lock.py:60 - Releasing the lock. -<#if logs??> - <#list logs as log> -${log.data} - </#list> -</#if> http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/resources/user_pass.json ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/resources/user_pass.json b/ambari-logsearch/ambari-logsearch-portal/src/main/resources/user_pass.json deleted file mode 100644 index 97a7f45..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/resources/user_pass.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "users": [{ - "name": "Logsearch Admin", - "username": "admin", - "password": "admin", - "en_password": "" - }] -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/scripts/run.sh ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/scripts/run.sh b/ambari-logsearch/ambari-logsearch-portal/src/main/scripts/run.sh deleted file mode 100755 index b8fd6c4..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/scripts/run.sh +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/bash -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -curr_dir=`pwd` -cd `dirname $0`; script_dir=`pwd`; cd $curr_dir - -if [ ! -z "$LOGSEARCH_INCLUDE" ]; then - source $LOGSEARCH_INCLUDE -fi - -if [ ! -z "$LOGSEARCH_SOLR_CLIENT_SSL_INCLUDE" ]; then - source $LOGSEARCH_SOLR_CLIENT_SSL_INCLUDE -fi - -JAVA=java -if [ -x $JAVA_HOME/bin/java ]; then - JAVA=$JAVA_HOME/bin/java -fi - -if [ "$LOGSEARCH_JAVA_MEM" = "" ]; then - LOGSEARCH_JAVA_MEM="-Xmx1g" -fi - -if [ "$LOGFILE" = "" ]; then - LOGFILE="/var/log/logsearch/logsearch.out" - touch $LOGFILE 2> /dev/null - if [ $? -ne 0 ]; then - LOGFILE=/tmp/${USER}_logsearch.out - fi -fi - - -#Temporarily enabling JMX so we can monitor the memory and CPU utilization of the process -#JMX="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=3098" - -LOGSEARCH_DEBUG_SUSPEND=${LOGSEARCH_DEBUG_SUSPEND:-n} -if [ "$LOGSEARCH_DEBUG" = "true" ] && [ ! -z "$LOGSEARCH_DEBUG_PORT" ]; then - LOGSEARCH_JAVA_OPTS="$LOGSEARCH_JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,address=$LOGSEARCH_DEBUG_PORT,server=y,suspend=$LOGSEARCH_DEBUG_SUSPEND " -fi - -if [ "$LOGSEARCH_SSL" = "true" ]; then - LOGSEARCH_JAVA_OPTS="$LOGSEARCH_JAVA_OPTS -Djavax.net.ssl.keyStore=$LOGSEARCH_KEYSTORE_LOCATION -Djavax.net.ssl.keyStoreType=$LOGSEARCH_KEYSTORE_TYPE -Djavax.net.ssl.trustStore=$LOGSEARCH_TRUSTSTORE_LOCATION -Djavax.net.ssl.trustStoreType=$LOGSEARCH_TRUSTSTORE_TYPE" -fi - -if [ "$PID_FILE" = "" ]; then - LOGSEARCH_PID_DIR=$HOME - PID_FILE=$LOGSEARCH_PID_DIR/logsearch-search-$USER.pid -fi - -if [ -f ${PID_FILE} ]; then - PID=`cat ${PID_FILE}` - if kill -0 $PID 2>/dev/null; then - echo "logsearch already running (${PID}) killing..." - kill $PID 2>/dev/null - sleep 5 - if kill -0 $PID 2>/dev/null; then - echo "logsearch still running. Will kill process forcefully in another 10 seconds..." - sleep 10 - kill -9 $PID 2>/dev/null - sleep 2 - fi - fi - - if kill -0 $PID 2>/dev/null; then - echo "ERROR: Even after all efforts to stop logsearch, it is still running. pid=$PID. Please manually kill the service and try again." - exit 1 - fi -fi - -if [ -z "$LOGSEARCH_CONF_DIR" ]; then - LOGSEARCH_CONF_DIR="/etc/logsearch/conf" - if [ ! -d $LOGSEARCH_CONF_DIR ]; then - if [ -d $script_dir/classes ]; then - LOGSEARCH_CONF_DIR=$script_dir/classes - fi - fi - echo "LOGSEARCH_CONF_DIR not found. Use default: $LOGSEARCH_CONF_DIR" -fi - -LOGSEARCH_GC_LOGFILE=`dirname $LOGFILE`/logsearch_gc.log -LOGSEARCH_GC_OPTS="-XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:$LOGSEARCH_GC_LOGFILE" - -echo "Starting logsearch. Output file=$LOGFILE pid_file=$PID_FILE" -#LOGSEARCH_CLI_CLASSPATH= -#set -x -nohup $JAVA -cp "$LOGSEARCH_CLI_CLASSPATH:$LOGSEARCH_CONF_DIR:$script_dir/libs/*:$script_dir/classes" $LOGSEARCH_GC_OPTS $LOGSEARCH_JAVA_MEM $LOGSEARCH_JAVA_OPTS $JMX org.apache.ambari.logsearch.LogSearch $LOGSEARCH_PORT $* > $LOGFILE 2>&1 & -echo $! > $PID_FILE http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/main/scripts/stop.sh ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/scripts/stop.sh b/ambari-logsearch/ambari-logsearch-portal/src/main/scripts/stop.sh deleted file mode 100755 index 3612f08..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/scripts/stop.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -curr_dir=`pwd` -cd `dirname $0`; script_dir=`pwd`; cd $curr_dir - -if [ "$PID_FILE" = "" ]; then - LOGSEARCH_PID_DIR=$HOME - PID_FILE=$LOGSEARCH_PID_DIR/logsearch-search-$USER.pid -fi - -if [ -f ${PID_FILE} ]; then - PID=`cat ${PID_FILE}` - if kill -0 $PID 2>/dev/null; then - echo "logsearch running with process id (${PID}). Killing..." - kill $PID 2>/dev/null - sleep 5 - if kill -0 $PID 2>/dev/null; then - echo "logsearch still running. Will kill process forcefully in another 10 seconds..." - sleep 10 - kill -9 $PID 2>/dev/null - sleep 2 - fi - fi - - if kill -0 $PID 2>/dev/null; then - echo "ERROR: Even after all efforts to stop logsearch, it is still running. pid=$PID. Please manually kill the service and try again." - exit 1 - fi -fi - http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/common/LogSearchContextUtilTest.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/common/LogSearchContextUtilTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/common/LogSearchContextUtilTest.java deleted file mode 100644 index cd33741..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/common/LogSearchContextUtilTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.ambari.logsearch.common; - -import org.apache.ambari.logsearch.web.model.User; -import org.junit.Before; -import org.junit.Test; - -import junit.framework.Assert; - -public class LogSearchContextUtilTest { - - @Before - public void resetContext() { - LogSearchContext.resetContext(); - } - - @Test - public void testNoContext() { - Assert.assertNull(LogSearchContext.getCurrentUsername()); - } - - @Test - public void testUserSession() { - User user = new User("UserName", "Password", null); - - LogSearchContext context = new LogSearchContext(); - context.setUser(user); - - LogSearchContext.setContext(context); - - Assert.assertEquals(LogSearchContext.getCurrentUsername(), "UserName"); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/common/ManageStartEndTimeTest.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/common/ManageStartEndTimeTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/common/ManageStartEndTimeTest.java deleted file mode 100644 index 6b75d87..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/common/ManageStartEndTimeTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.ambari.logsearch.common; - -import java.util.Date; - -import org.junit.Assert; -import org.junit.Test; - -public class ManageStartEndTimeTest { - - @Test - public void testManageStartEndTime() { - ManageStartEndTime.manage(); - Date[] range = ManageStartEndTime.getStartEndTime(); - Assert.assertEquals(range[1].getTime() - range[0].getTime(), 60*60*1000); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/AbstractRequestConverterTest.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/AbstractRequestConverterTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/AbstractRequestConverterTest.java deleted file mode 100644 index 0bff00e..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/AbstractRequestConverterTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.ambari.logsearch.converter; - -import org.apache.ambari.logsearch.model.request.impl.BaseLogRequest; -import org.apache.ambari.logsearch.model.request.impl.CommonSearchRequest; - -public class AbstractRequestConverterTest { - - public void fillBaseLogRequestWithTestData(BaseLogRequest request) { - fillCommonRequestWithTestData(request); - request.setFrom("2016-09-13T22:00:01.000Z"); - request.setTo("2016-09-14T22:00:01.000Z"); - request.setMustBe("logsearch_app,secure_log"); - request.setMustNot("hst_agent,system_message"); - request.setIncludeQuery("[{\"log_message\" : \"myincludemessage\"}]"); - request.setExcludeQuery("[{\"log_message\" : \"myexcludemessage\"}]"); - } - - public void fillCommonRequestWithTestData(CommonSearchRequest request) { - request.setStartIndex("0"); - request.setPage("0"); - request.setPageSize("25"); - request.setClusters("cl1"); - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/AuditBarGraphRequestQueryConverterTest.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/AuditBarGraphRequestQueryConverterTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/AuditBarGraphRequestQueryConverterTest.java deleted file mode 100644 index b9e577c..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/AuditBarGraphRequestQueryConverterTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.ambari.logsearch.converter; - -import org.apache.ambari.logsearch.model.request.impl.AuditBarGraphRequest; -import org.apache.solr.client.solrj.SolrQuery; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class AuditBarGraphRequestQueryConverterTest extends AbstractRequestConverterTest { - - private AuditBarGraphRequestQueryConverter underTest; - - @Before - public void setUp() { - underTest = new AuditBarGraphRequestQueryConverter(); - } - - @Test - public void testConvert() { - // GIVEN - AuditBarGraphRequest request = new AuditBarGraphRequest(); - // WHEN - fillBaseLogRequestWithTestData(request); - request.setUnit("+1HOUR"); - // THEN - SolrQuery query = underTest.convert(request); - assertEquals("?q=*%3A*&facet=true&facet.pivot=%7B%21range%3Dr1%7Drepo&facet.mincount=1&facet.limit=-1&facet.sort=index" + - "&facet.range=%7B%21tag%3Dr1%7DevtTime&f.evtTime.facet.range.start=2016-09-13T22%3A00%3A01.000Z&f.evtTime.facet.range.end=2016-09-14T22%3A00%3A01.000Z&f.evtTime.facet.range.gap=%2B1HOUR" + - "&rows=0&start=0&fq=cluster%3Acl1", - query.toQueryString()); - } - - @Test - public void testConvertWithoutData() { - // GIVEN - AuditBarGraphRequest request = new AuditBarGraphRequest(); - // WHEN - SolrQuery query = underTest.convert(request); - // THEN - assertEquals(Integer.valueOf(0), query.getRows()); - assertEquals(-1, query.getFacetLimit()); - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/AuditComponentRequestQueryConverterTest.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/AuditComponentRequestQueryConverterTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/AuditComponentRequestQueryConverterTest.java deleted file mode 100644 index 7a1b08d..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/AuditComponentRequestQueryConverterTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.ambari.logsearch.converter; - -import org.apache.ambari.logsearch.model.request.impl.AuditComponentRequest; -import org.apache.solr.client.solrj.SolrQuery; -import org.junit.Before; -import org.junit.Test; -import org.springframework.data.solr.core.DefaultQueryParser; -import org.springframework.data.solr.core.query.SimpleFacetQuery; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertEquals; - -public class AuditComponentRequestQueryConverterTest extends AbstractRequestConverterTest { - - private AuditComponentsRequestQueryConverter underTest; - - @Before - public void setUp() { - underTest = new AuditComponentsRequestQueryConverter(); - } - - @Test - public void testConvert() { - // GIVEN - AuditComponentRequest request = new AuditComponentRequest(); - fillCommonRequestWithTestData(request); - // WHEN - SimpleFacetQuery facetQuery = underTest.convert(request); - SolrQuery query = new DefaultQueryParser().doConstructSolrQuery(facetQuery); - // THEN - assertEquals("?q=*%3A*&rows=0&fq=evtTime%3A%5B*+TO+*%5D&fq=cluster%3Acl1&facet=true&facet.mincount=1&facet.limit=-1&facet.sort=index&facet.field=repo", - query.toQueryString()); - } - - @Test - public void testConvertWithoutData() { - // GIVEN - AuditComponentRequest request = new AuditComponentRequest(); - // WHEN - SimpleFacetQuery facetQuery = underTest.convert(request); - SolrQuery query = new DefaultQueryParser().doConstructSolrQuery(facetQuery); - // THEN - assertNotNull(facetQuery); - assertEquals("?q=*%3A*&rows=0&fq=evtTime%3A%5B*+TO+*%5D&facet=true&facet.mincount=1&facet.limit=-1&facet.sort=index&facet.field=repo", - query.toQueryString()); - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/AuditLogRequestConverterTest.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/AuditLogRequestConverterTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/AuditLogRequestConverterTest.java deleted file mode 100644 index 330a036..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/AuditLogRequestConverterTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.ambari.logsearch.converter; - -import org.apache.ambari.logsearch.model.request.impl.AuditLogRequest; -import org.apache.solr.client.solrj.SolrQuery; -import org.junit.Before; -import org.junit.Test; -import org.springframework.data.solr.core.DefaultQueryParser; -import org.springframework.data.solr.core.query.SimpleQuery; - -import static org.junit.Assert.assertEquals; - -public class AuditLogRequestConverterTest extends AbstractRequestConverterTest { - - private AuditLogRequestQueryConverter underTest; - - @Before - public void setUp() { - underTest = new AuditLogRequestQueryConverter(); - } - - @Test - public void testConvert() { - // GIVEN - AuditLogRequest request = new AuditLogRequest(); - fillBaseLogRequestWithTestData(request); - // WHEN - SimpleQuery simpleQuery = underTest.convert(request); - SolrQuery queryResult = new DefaultQueryParser().doConstructSolrQuery(simpleQuery); - // THEN - assertEquals("?q=*%3A*&start=0&rows=25&fq=repo%3A%28logsearch_app+secure_log%29&fq=-repo%3A%28hst_agent+system_message%29" + - "&fq=log_message%3Amyincludemessage&fq=-log_message%3Amyexcludemessage&fq=cluster%3Acl1&sort=evtTime+desc%2Cseq_num+desc", - queryResult.toQueryString()); - } - - @Test - public void testConvertWithoutData() { - // GIVEN - AuditLogRequest request = new AuditLogRequest(); - // WHEN - SimpleQuery simpleQuery = underTest.convert(request); - SolrQuery queryResult = new DefaultQueryParser().doConstructSolrQuery(simpleQuery); - // THEN - assertEquals("?q=*%3A*&start=0&rows=99999&sort=evtTime+desc%2Cseq_num+desc", queryResult.toQueryString()); - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/AuditServiceLoadRequestQueryConverterTest.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/AuditServiceLoadRequestQueryConverterTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/AuditServiceLoadRequestQueryConverterTest.java deleted file mode 100644 index cce9115..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/AuditServiceLoadRequestQueryConverterTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.ambari.logsearch.converter; - -import org.apache.ambari.logsearch.model.request.impl.AuditServiceLoadRequest; -import org.apache.solr.client.solrj.SolrQuery; -import org.junit.Before; -import org.junit.Test; -import org.springframework.data.solr.core.DefaultQueryParser; - -import static org.junit.Assert.assertEquals; - -public class AuditServiceLoadRequestQueryConverterTest extends AbstractRequestConverterTest { - - private AuditServiceLoadRequestQueryConverter underTest; - - @Before - public void setUp() { - underTest = new AuditServiceLoadRequestQueryConverter(); - } - - @Test - public void testConvert() { - // GIVEN - AuditServiceLoadRequest request = new AuditServiceLoadRequest(); - fillBaseLogRequestWithTestData(request); - // WHEN - SolrQuery solrQuery = new DefaultQueryParser().doConstructSolrQuery(underTest.convert(request)); - // THEN - assertEquals("?q=*%3A*&rows=0&fq=evtTime%3A%5B2016-09-13T22%3A00%3A01.000Z+TO+2016-09-14T22%3A00%3A01.000Z%5D" + - "&fq=log_message%3Amyincludemessage&fq=-log_message%3Amyexcludemessage&fq=repo%3A%28logsearch_app+secure_log%29" + - "&fq=-repo%3A%28hst_agent+system_message%29&fq=cluster%3Acl1&facet=true&facet.mincount=1&facet.limit=10&facet.field=repo", solrQuery.toQueryString()); - } - - @Test - public void testConvertWithoutData() { - // GIVEN - AuditServiceLoadRequest request = new AuditServiceLoadRequest(); - // WHEN - SolrQuery solrQuery = new DefaultQueryParser().doConstructSolrQuery(underTest.convert(request)); - // THEN - assertEquals("?q=*%3A*&rows=0&fq=evtTime%3A%5B*+TO+*%5D&facet=true&facet.mincount=1&facet.limit=10&facet.field=repo", - solrQuery.toQueryString()); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/BaseServiceLogRequestQueryConverterTest.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/BaseServiceLogRequestQueryConverterTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/BaseServiceLogRequestQueryConverterTest.java deleted file mode 100644 index da7d79c..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/BaseServiceLogRequestQueryConverterTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.ambari.logsearch.converter; - -import org.apache.ambari.logsearch.model.request.impl.ServiceLogRequest; -import org.apache.ambari.logsearch.util.SolrUtil; -import org.apache.solr.client.solrj.SolrQuery; -import org.junit.Before; -import org.junit.Test; -import org.springframework.data.solr.core.DefaultQueryParser; -import org.springframework.data.solr.core.query.SimpleQuery; - -import static org.junit.Assert.assertEquals; - -public class BaseServiceLogRequestQueryConverterTest extends AbstractRequestConverterTest { - - private BaseServiceLogRequestQueryConverter underTest; - - @Before - public void setUp() { - underTest = new BaseServiceLogRequestQueryConverter(); - } - - @Test - public void testConvertRequest() { - // GIVEN - ServiceLogRequest logRequest = new ServiceLogRequest(); - fillBaseLogRequestWithTestData(logRequest); - logRequest.setLevel("FATAL,ERROR,WARN,UNKNOWN"); - logRequest.setFileName("/var/log/myfile-*-hdfs.log"); - logRequest.setComponentName("component"); - logRequest.setHostName("logsearch.com"); - // WHEN - SimpleQuery query = underTest.convert(logRequest); - DefaultQueryParser defaultQueryParser = new DefaultQueryParser(); - SolrQuery solrQuery = defaultQueryParser.doConstructSolrQuery(query); - SolrUtil.removeDoubleOrTripleEscapeFromFilters(solrQuery); - // THEN - assertEquals("?q=*%3A*&start=0&rows=25&fq=type%3A%28logsearch_app+secure_log%29&fq=-type%3A%28hst_agent+system_message%29" + - "&fq=log_message%3Amyincludemessage&fq=-log_message%3Amyexcludemessage&fq=cluster%3Acl1" + - "&fq=host%3Alogsearch.com&fq=path%3A%5C%2Fvar%5C%2Flog%5C%2Fmyfile%5C-%5C*%5C-hdfs.log&fq=type%3Acomponent" + - "&fq=level%3A%28FATAL+ERROR+WARN+UNKNOWN%29&fq=logtime%3A%5B2016-09-13T22%3A00%3A01.000Z+TO+2016-09-14T22%3A00%3A01.000Z%5D&sort=logtime+desc%2Cseq_num+desc", - solrQuery.toQueryString()); - } - - @Test - public void testConvertRequestWithoutData() { - // GIVEN - ServiceLogRequest logRequest = new ServiceLogRequest(); - // WHEN - SimpleQuery query = underTest.convert(logRequest); - // THEN - assertEquals(Integer.valueOf(99999), query.getRows()); - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/FieldAuditLogRequestQueryConverterTest.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/FieldAuditLogRequestQueryConverterTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/FieldAuditLogRequestQueryConverterTest.java deleted file mode 100644 index 08541e1..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/FieldAuditLogRequestQueryConverterTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.ambari.logsearch.converter; - -import org.apache.ambari.logsearch.model.request.impl.FieldAuditLogRequest; -import org.apache.solr.client.solrj.SolrQuery; -import org.junit.Before; -import org.junit.Test; -import org.springframework.data.solr.core.DefaultQueryParser; - -import static org.junit.Assert.assertEquals; - -public class FieldAuditLogRequestQueryConverterTest extends AbstractRequestConverterTest { - - private FieldAuditLogRequestQueryConverter underTest; - - @Before - public void setUp() { - underTest = new FieldAuditLogRequestQueryConverter(); - } - - @Test - public void testConvert() { - // GIVEN - FieldAuditLogRequest request = new FieldAuditLogRequest(); - fillBaseLogRequestWithTestData(request); - request.setTop(10); - request.setField("myfield"); - // WHEN - SolrQuery query = new DefaultQueryParser().doConstructSolrQuery(underTest.convert(request)); - // THEN - assertEquals("?q=*%3A*&rows=0&fq=evtTime%3A%5B2016-09-13T22%3A00%3A01.000Z+TO+2016-09-14T22%3A00%3A01.000Z%5D&fq=log_message%3Amyincludemessage" + - "&fq=-log_message%3Amyexcludemessage&fq=repo%3A%28logsearch_app+secure_log%29&fq=-repo%3A%28hst_agent+system_message%29&fq=cluster%3Acl1&facet=true" + - "&facet.mincount=1&facet.limit=10&facet.pivot=myfield%2Crepo", - query.toQueryString()); - } - - @Test(expected = IllegalArgumentException.class) // TODO: later use @Valid on the fields to validate object - public void testConvertWithoutData() { - // GIVEN - FieldAuditLogRequest request = new FieldAuditLogRequest(); - // WHEN - new DefaultQueryParser().doConstructSolrQuery(underTest.convert(request)); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/HostLogFilesRequestQueryConverterTest.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/HostLogFilesRequestQueryConverterTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/HostLogFilesRequestQueryConverterTest.java deleted file mode 100644 index 60dba44..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/HostLogFilesRequestQueryConverterTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.ambari.logsearch.converter; - -import org.apache.ambari.logsearch.model.request.impl.HostLogFilesRequest; -import org.apache.solr.client.solrj.SolrQuery; -import org.junit.Before; -import org.junit.Test; -import org.springframework.data.solr.core.DefaultQueryParser; - -import static org.junit.Assert.assertEquals; - -public class HostLogFilesRequestQueryConverterTest extends AbstractRequestConverterTest { - - private HostLogFilesRequestQueryConverter underTest; - - @Before - public void setUp() { - underTest = new HostLogFilesRequestQueryConverter(); - } - - @Test - public void testConvertHostNameOnly() { - // GIVEN - HostLogFilesRequest request = new HostLogFilesRequest(); - request.setHostName("hostName"); - // WHEN - SolrQuery query = new DefaultQueryParser().doConstructSolrQuery(underTest.convert(request)); - // THEN - assertEquals("?q=host%3A%28hostName%29&rows=0&facet=true&facet.mincount=1&facet.limit=-1&facet.pivot=type%2Cpath", - query.toQueryString()); - } - - @Test - public void testConvertHostNameAndComponentName() { - // GIVEN - HostLogFilesRequest request = new HostLogFilesRequest(); - request.setHostName("hostName"); - request.setComponentName("componentName"); - // WHEN - SolrQuery query = new DefaultQueryParser().doConstructSolrQuery(underTest.convert(request)); - // THEN - assertEquals("?q=host%3A%28hostName%29+AND+type%3A%28componentName%29&rows=0&facet=true&facet.mincount=1&facet.limit=-1" + - "&facet.pivot=type%2Cpath", query.toQueryString()); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogAnyGraphRequestConverterTest.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogAnyGraphRequestConverterTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogAnyGraphRequestConverterTest.java deleted file mode 100644 index 8e96b16..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogAnyGraphRequestConverterTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.ambari.logsearch.converter; - -import org.apache.ambari.logsearch.model.request.impl.ServiceAnyGraphRequest; -import org.apache.solr.client.solrj.SolrQuery; -import org.junit.Before; -import org.junit.Test; -import org.springframework.data.solr.core.DefaultQueryParser; - -import static org.junit.Assert.assertEquals; - -public class ServiceLogAnyGraphRequestConverterTest extends AbstractRequestConverterTest { - - private ServiceLogAnyGraphRequestQueryConverter underTest; - - @Before - public void setUp() { - underTest = new ServiceLogAnyGraphRequestQueryConverter(); - } - - @Test - public void testConverter() { - // GIVEN - ServiceAnyGraphRequest request = new ServiceAnyGraphRequest(); - request.setUnit("+1HOUR"); - fillBaseLogRequestWithTestData(request); - // WHEN - SolrQuery query = new DefaultQueryParser().doConstructSolrQuery(underTest.convert(request)); - // THEN - assertEquals("?q=*%3A*&rows=0&fq=logtime%3A%5B2016-09-13T22%3A00%3A01.000Z+TO+2016-09-14T22%3A00%3A01.000Z%5D" + - "&fq=log_message%3Amyincludemessage&fq=-log_message%3Amyexcludemessage&fq=type%3A%28logsearch_app+secure_log%29" + - "&fq=-type%3A%28hst_agent+system_message%29&fq=cluster%3Acl1&facet=true&facet.mincount=1&facet.limit=-1&facet.field=level", - query.toQueryString()); - } - - @Test - public void testConverterWithoutData() { - // GIVEN - ServiceAnyGraphRequest request = new ServiceAnyGraphRequest(); - // WHEN - SolrQuery query = new DefaultQueryParser().doConstructSolrQuery(underTest.convert(request)); - // THEN - assertEquals("?q=*%3A*&rows=0&fq=logtime%3A%5B*+TO+*%5D&facet=true&facet.mincount=1&facet.limit=-1&facet.field=level", - query.toQueryString()); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogComponentLevelRequestQueryConverterTest.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogComponentLevelRequestQueryConverterTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogComponentLevelRequestQueryConverterTest.java deleted file mode 100644 index 981e239..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogComponentLevelRequestQueryConverterTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.ambari.logsearch.converter; - -import org.apache.ambari.logsearch.model.request.impl.ServiceLogComponentLevelRequest; -import org.apache.solr.client.solrj.SolrQuery; -import org.junit.Before; -import org.junit.Test; -import org.springframework.data.solr.core.DefaultQueryParser; - -import static org.junit.Assert.assertEquals; - -public class ServiceLogComponentLevelRequestQueryConverterTest extends AbstractRequestConverterTest { - - private ServiceLogComponentLevelRequestQueryConverter underTest; - - @Before - public void setUp() { - underTest = new ServiceLogComponentLevelRequestQueryConverter(); - } - - @Test - public void testConverter() { - // GIVEN - ServiceLogComponentLevelRequest request = new ServiceLogComponentLevelRequest(); - fillBaseLogRequestWithTestData(request); - request.setComponentName("mycomponent"); - request.setLevel("WARN,ERROR,FATAL"); - // WHEN - SolrQuery query = new DefaultQueryParser().doConstructSolrQuery(underTest.convert(request)); - // THEN - assertEquals("?q=*%3A*&rows=0&fq=logtime%3A%5B2016-09-13T22%3A00%3A01.000Z+TO+2016-09-14T22%3A00%3A01.000Z%5D" + - "&fq=log_message%3Amyincludemessage&fq=-log_message%3Amyexcludemessage&fq=type%3A%28logsearch_app+secure_log%29" + - "&fq=-type%3A%28hst_agent+system_message%29&fq=type%3Amycomponent&fq=level%3A%28WARN+ERROR+FATAL%29&fq=cluster%3Acl1" + - "&facet=true&facet.mincount=1&facet.limit=-1&facet.sort=index&facet.pivot=type%2Clevel", - query.toQueryString()); - } - - @Test - public void testConverterWithoutData() { - // GIVEN - ServiceLogComponentLevelRequest request = new ServiceLogComponentLevelRequest(); - request.setLevel("WARN,ERROR,FATAL"); - // WHEN - SolrQuery query = new DefaultQueryParser().doConstructSolrQuery(underTest.convert(request)); - // THEN - assertEquals("?q=*%3A*&rows=0&fq=logtime%3A%5B*+TO+*%5D&fq=level%3A%28WARN+ERROR+FATAL%29&facet=true" + - "&facet.mincount=1&facet.limit=-1&facet.sort=index&facet.pivot=type%2Clevel", query.toQueryString()); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogComponentRequestFacetQueryConverterTest.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogComponentRequestFacetQueryConverterTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogComponentRequestFacetQueryConverterTest.java deleted file mode 100644 index b72ffc5..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogComponentRequestFacetQueryConverterTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.ambari.logsearch.converter; - -import org.apache.ambari.logsearch.model.request.impl.ServiceLogComponentHostRequest; -import org.apache.solr.client.solrj.SolrQuery; -import org.junit.Before; -import org.junit.Test; -import org.springframework.data.solr.core.DefaultQueryParser; - -import static org.junit.Assert.assertEquals; - -public class ServiceLogComponentRequestFacetQueryConverterTest extends AbstractRequestConverterTest { - - private ServiceLogComponentRequestFacetQueryConverter underTest; - - @Before - public void setUp() { - underTest = new ServiceLogComponentRequestFacetQueryConverter(); - } - - @Test - public void testConverter() { - // GIVEN - ServiceLogComponentHostRequest request = new ServiceLogComponentHostRequest(); - fillBaseLogRequestWithTestData(request); - request.setComponentName("mycomponent"); - request.setLevel("WARN,ERROR,FATAL"); - // WHEN - SolrQuery query = new DefaultQueryParser().doConstructSolrQuery(underTest.convert(request)); - // THEN - assertEquals("?q=*%3A*&rows=0&fq=logtime%3A%5B2016-09-13T22%3A00%3A01.000Z+TO+2016-09-14T22%3A00%3A01.000Z%5D" + - "&fq=log_message%3Amyincludemessage&fq=-log_message%3Amyexcludemessage&fq=type%3A%28logsearch_app+secure_log%29" + - "&fq=-type%3A%28hst_agent+system_message%29&fq=type%3Amycomponent&fq=level%3A%28WARN+ERROR+FATAL%29&fq=cluster%3Acl1" + - "&facet=true&facet.mincount=1&facet.limit=-1&facet.sort=index&facet.pivot=type%2Chost%2Clevel&facet.pivot=type%2Clevel", - query.toQueryString()); - } - - @Test - public void testConverterWithoutData() { - // GIVEN - ServiceLogComponentHostRequest request = new ServiceLogComponentHostRequest(); - request.setLevel("WARN,ERROR,FATAL"); - // WHEN - SolrQuery query = new DefaultQueryParser().doConstructSolrQuery(underTest.convert(request)); - // THEN - assertEquals("?q=*%3A*&rows=0&fq=logtime%3A%5B*+TO+*%5D&fq=level%3A%28WARN+ERROR+FATAL%29" + - "&facet=true&facet.mincount=1&facet.limit=-1&facet.sort=index&facet.pivot=type%2Chost%2Clevel&facet.pivot=type%2Clevel", - query.toQueryString()); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogLevelCountRequestQueryConverterTest.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogLevelCountRequestQueryConverterTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogLevelCountRequestQueryConverterTest.java deleted file mode 100644 index 69986dc..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogLevelCountRequestQueryConverterTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.ambari.logsearch.converter; - -import org.apache.ambari.logsearch.model.request.impl.ServiceLogLevelCountRequest; -import org.apache.solr.client.solrj.SolrQuery; -import org.junit.Before; -import org.junit.Test; -import org.springframework.data.solr.core.DefaultQueryParser; - -import static org.junit.Assert.assertEquals; - -public class ServiceLogLevelCountRequestQueryConverterTest extends AbstractRequestConverterTest { - - private ServiceLogLevelCountRequestQueryConverter underTest; - - @Before - public void setUp() { - underTest = new ServiceLogLevelCountRequestQueryConverter(); - } - - @Test - public void testConvert() { - // GIVEN - ServiceLogLevelCountRequest request = new ServiceLogLevelCountRequest(); - fillBaseLogRequestWithTestData(request); - // WHEN - SolrQuery query = new DefaultQueryParser().doConstructSolrQuery(underTest.convert(request)); - // THEN - assertEquals("?q=*%3A*&rows=0&fq=logtime%3A%5B2016-09-13T22%3A00%3A01.000Z+TO+2016-09-14T22%3A00%3A01.000Z%5D&fq=log_message%3Amyincludemessage" + - "&fq=-log_message%3Amyexcludemessage&fq=type%3A%28logsearch_app+secure_log%29&fq=-type%3A%28hst_agent+system_message%29" + - "&fq=cluster%3Acl1&facet=true&facet.mincount=1&facet.limit=-1&facet.field=level", - query.toQueryString()); - } - - @Test - public void testConvertWithoutData() { - // GIVEN - ServiceLogLevelCountRequest request = new ServiceLogLevelCountRequest(); - // WHEN - SolrQuery query = new DefaultQueryParser().doConstructSolrQuery(underTest.convert(request)); - // THEN - assertEquals("?q=*%3A*&rows=0&fq=logtime%3A%5B*+TO+*%5D&facet=true&facet.mincount=1&facet.limit=-1&facet.field=level", - query.toQueryString()); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogLevelDateRangeRequestQueryConverterTest.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogLevelDateRangeRequestQueryConverterTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogLevelDateRangeRequestQueryConverterTest.java deleted file mode 100644 index 1987e54..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogLevelDateRangeRequestQueryConverterTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.ambari.logsearch.converter; - -import org.apache.ambari.logsearch.model.request.impl.ServiceGraphRequest; -import org.apache.solr.client.solrj.SolrQuery; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class ServiceLogLevelDateRangeRequestQueryConverterTest extends AbstractRequestConverterTest { - - private ServiceLogLevelDateRangeRequestQueryConverter underTest; - - @Before - public void setUp() { - underTest = new ServiceLogLevelDateRangeRequestQueryConverter(); - } - - @Test - public void testConvert() { - // GIVEN - ServiceGraphRequest request = new ServiceGraphRequest(); - fillBaseLogRequestWithTestData(request); - request.setUnit("+1HOUR"); - request.setLevel("WARN,ERROR,FATAL"); - // WHEN - SolrQuery query = underTest.convert(request); - // THEN - assertEquals("?q=*%3A*&facet=true&facet.pivot=%7B%21range%3Dr1%7Dlevel&facet.mincount=1&facet.limit=-1&facet.sort=index" + - "&facet.range=%7B%21tag%3Dr1%7Dlogtime&f.logtime.facet.range.start=2016-09-13T22%3A00%3A01.000Z" + - "&f.logtime.facet.range.end=2016-09-14T22%3A00%3A01.000Z&f.logtime.facet.range.gap=%2B1HOUR&rows=0&start=0" + - "&fq=level%3A%28WARN+OR+ERROR+OR+FATAL%29&fq=cluster%3Acl1", query.toQueryString()); - } - - @Test - public void testConvertWithoutData() { - // GIVEN - ServiceGraphRequest request = new ServiceGraphRequest(); - request.setUnit("+1HOUR"); // minimal data for date range gap - request.setFrom("2016-09-13T22:00:01.000Z"); - request.setTo("2016-09-14T22:00:01.000Z"); - // WHEN - SolrQuery query = underTest.convert(request); - // THEN - assertEquals("?q=*%3A*&facet=true&facet.pivot=%7B%21range%3Dr1%7Dlevel&facet.mincount=1&facet.limit=-1&facet.sort=index" + - "&facet.range=%7B%21tag%3Dr1%7Dlogtime&f.logtime.facet.range.start=2016-09-13T22%3A00%3A01.000Z" + - "&f.logtime.facet.range.end=2016-09-14T22%3A00%3A01.000Z&f.logtime.facet.range.gap=%2B1HOUR&rows=0&start=0", - query.toQueryString()); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogTreeRequestFacetQueryConverterTest.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogTreeRequestFacetQueryConverterTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogTreeRequestFacetQueryConverterTest.java deleted file mode 100644 index 167d7d8..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogTreeRequestFacetQueryConverterTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.ambari.logsearch.converter; - -import org.apache.ambari.logsearch.model.request.impl.ServiceLogHostComponentRequest; -import org.apache.solr.client.solrj.SolrQuery; -import org.junit.Before; -import org.junit.Test; -import org.springframework.data.solr.core.DefaultQueryParser; - -import static org.junit.Assert.assertEquals; - -public class ServiceLogTreeRequestFacetQueryConverterTest extends AbstractRequestConverterTest { - private ServiceLogTreeRequestFacetQueryConverter underTest; - - @Before - public void setUp() { - underTest = new ServiceLogTreeRequestFacetQueryConverter(); - } - - @Test - public void testConvert() { - // GIVEN - ServiceLogHostComponentRequest request = new ServiceLogHostComponentRequest(); - fillBaseLogRequestWithTestData(request); - request.setLevel("WARN,ERROR,FATAL"); - // WHEN - SolrQuery query = new DefaultQueryParser().doConstructSolrQuery(underTest.convert(request)); - // THEN - assertEquals("?q=*%3A*&rows=0&fq=logtime%3A%5B2016-09-13T22%3A00%3A01.000Z+TO+2016-09-14T22%3A00%3A01.000Z%5D&fq=log_message%3Amyincludemessage" + - "&fq=-log_message%3Amyexcludemessage&fq=type%3A%28logsearch_app+secure_log%29&fq=-type%3A%28hst_agent+system_message%29" + - "&fq=level%3A%28WARN+ERROR+FATAL%29&fq=cluster%3Acl1&facet=true&facet.mincount=1&facet.limit=-1&facet.sort=index&facet.pivot=host%2Ctype%2Clevel&facet.pivot=host%2Clevel", - query.toQueryString()); - } - - @Test - public void testConvertWithoutData() { - // GIVEN - ServiceLogHostComponentRequest request = new ServiceLogHostComponentRequest(); - request.setLevel("WARN,ERROR,FATAL"); - // WHEN - SolrQuery query = new DefaultQueryParser().doConstructSolrQuery(underTest.convert(request)); - // THEN - assertEquals("?q=*%3A*&rows=0&fq=logtime%3A%5B*+TO+*%5D&fq=level%3A%28WARN+ERROR+FATAL%29&facet=true&facet.mincount=1" + - "&facet.limit=-1&facet.sort=index&facet.pivot=host%2Ctype%2Clevel&facet.pivot=host%2Clevel", - query.toQueryString()); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogTruncatedRequestQueryConverterTest.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogTruncatedRequestQueryConverterTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogTruncatedRequestQueryConverterTest.java deleted file mode 100644 index 02d3f2e..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/ServiceLogTruncatedRequestQueryConverterTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.ambari.logsearch.converter; - -import org.apache.ambari.logsearch.model.request.impl.ServiceLogTruncatedRequest; -import org.apache.solr.client.solrj.SolrQuery; -import org.junit.Before; -import org.junit.Test; -import org.springframework.data.solr.core.DefaultQueryParser; - -import static org.junit.Assert.assertEquals; - -public class ServiceLogTruncatedRequestQueryConverterTest extends AbstractRequestConverterTest { - - private ServiceLogTruncatedRequestQueryConverter underTest; - - @Before - public void setUp() { - underTest = new ServiceLogTruncatedRequestQueryConverter(); - } - - @Test - public void testConvert() { - // GIVEN - ServiceLogTruncatedRequest request = new ServiceLogTruncatedRequest(); - fillBaseLogRequestWithTestData(request); - request.setScrollType("0"); - request.setNumberRows(10); - request.setId("id"); - // WHEN - SolrQuery query = new DefaultQueryParser().doConstructSolrQuery(underTest.convert(request)); - // THEN - assertEquals("?q=*%3A*&start=0&rows=10&fq=type%3A%28logsearch_app+secure_log%29&fq=-type%3A%28hst_agent+system_message%29" + - "&fq=log_message%3Amyincludemessage&fq=-log_message%3Amyexcludemessage&fq=cluster%3Acl1&sort=logtime+desc%2Cseq_num+desc", - query.toQueryString()); - } - - @Test - public void testConvertWithoutData() { - // GIVEN - ServiceLogTruncatedRequest request = new ServiceLogTruncatedRequest(); - // WHEN - SolrQuery query = new DefaultQueryParser().doConstructSolrQuery(underTest.convert(request)); - // THEN - assertEquals("?q=*%3A*&start=0&sort=logtime+desc%2Cseq_num+desc", - query.toQueryString()); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/StringFieldFacetQueryConverterTest.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/StringFieldFacetQueryConverterTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/StringFieldFacetQueryConverterTest.java deleted file mode 100644 index 3597779..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/StringFieldFacetQueryConverterTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.ambari.logsearch.converter; - -import org.apache.solr.client.solrj.SolrQuery; -import org.junit.Before; -import org.junit.Test; -import org.springframework.data.solr.core.DefaultQueryParser; -import org.springframework.data.solr.core.query.SimpleQuery; - -import static org.junit.Assert.assertEquals; - -public class StringFieldFacetQueryConverterTest extends AbstractRequestConverterTest { - private StringFieldFacetQueryConverter underTest; - - @Before - public void setUp() { - underTest = new StringFieldFacetQueryConverter(); - } - - @Test - public void testConvert() { - // GIVEN - String field = "myfield"; - // WHEN - SimpleQuery simpleQuery = underTest.convert(field); - SolrQuery queryResult = new DefaultQueryParser().doConstructSolrQuery(simpleQuery); - // THEN - assertEquals("?q=*%3A*&rows=0&facet=true&facet.mincount=1&facet.limit=-1&facet.field=myfield", - queryResult.toQueryString()); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverterTest.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverterTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverterTest.java deleted file mode 100644 index 66560c5..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/UserConfigRequestQueryConverterTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.ambari.logsearch.converter; - -import org.apache.ambari.logsearch.model.request.impl.UserConfigRequest; -import org.apache.solr.client.solrj.SolrQuery; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class UserConfigRequestQueryConverterTest extends AbstractRequestConverterTest { - - private UserConfigRequestQueryConverter underTest; - - @Before - public void setUp() { - underTest = new UserConfigRequestQueryConverter(); - } - - @Test - public void testConvert() { - // GIVEN - UserConfigRequest request = new UserConfigRequest(); - request.setRowType("myRowType"); // TODO: validate these 3 fields @Valid on UserConfigRequest object -> not null - request.setFilterName("myFilterName"); - request.setClusters("cl1,cl2"); - // WHEN - SolrQuery queryResult = underTest.convert(request); - // THEN - assertEquals("?q=*%3A*&fq=rowtype%3AmyRowType&fq=filtername%3A*myFilterName*&fq=cluster%3A%28cl1+OR+cl2%29&start=0&rows=10&sort=filtername+asc", - queryResult.toQueryString()); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f1e340/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/UserExportRequestQueryConverterTest.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/UserExportRequestQueryConverterTest.java b/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/UserExportRequestQueryConverterTest.java deleted file mode 100644 index 0ab57ab..0000000 --- a/ambari-logsearch/ambari-logsearch-portal/src/test/java/org/apache/ambari/logsearch/converter/UserExportRequestQueryConverterTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.ambari.logsearch.converter; - -import org.apache.ambari.logsearch.model.request.impl.UserExportRequest; -import org.apache.solr.client.solrj.SolrQuery; -import org.junit.Before; -import org.junit.Test; -import org.springframework.data.solr.core.DefaultQueryParser; - -import static org.junit.Assert.assertEquals; - -public class UserExportRequestQueryConverterTest extends AbstractRequestConverterTest { - private UserExportRequestQueryConverter underTest; - - @Before - public void setUp() { - underTest = new UserExportRequestQueryConverter(); - } - - @Test - public void testConverter() { - // GIVEN - UserExportRequest request = new UserExportRequest(); - fillBaseLogRequestWithTestData(request); - request.setFormat("myFormat"); - request.setClusters(null); - // WHEN - SolrQuery query = new DefaultQueryParser().doConstructSolrQuery(underTest.convert(request)); - // THEN - assertEquals("?q=*%3A*&rows=0&fq=evtTime%3A%5B2016-09-13T22%3A00%3A01.000Z+TO+2016-09-14T22%3A00%3A01.000Z%5D" + - "&fq=log_message%3Amyincludemessage&fq=-log_message%3Amyexcludemessage&fq=repo%3A%28logsearch_app+secure_log%29" + - "&fq=-repo%3A%28hst_agent+system_message%29&facet=true&facet.mincount=1&facet.limit=-1&facet.pivot=reqUser%2Crepo&facet.pivot=resource%2Crepo", - query.toQueryString()); - } - - @Test - public void testConverterWithoutData() { - // GIVEN - UserExportRequest request = new UserExportRequest(); - // WHEN - SolrQuery query = new DefaultQueryParser().doConstructSolrQuery(underTest.convert(request)); - // THEN - assertEquals("?q=*%3A*&rows=0&fq=evtTime%3A%5B*+TO+*%5D&facet=true&facet.mincount=1&facet.limit=-1" + - "&facet.pivot=reqUser%2Crepo&facet.pivot=resource%2Crepo", - query.toQueryString()); - } -}