http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/resources/webapps/static/yarn.css ---------------------------------------------------------------------- diff --git a/slider-core/src/main/resources/webapps/static/yarn.css b/slider-core/src/main/resources/webapps/static/yarn.css deleted file mode 100644 index 1e9ca94..0000000 --- a/slider-core/src/main/resources/webapps/static/yarn.css +++ /dev/null @@ -1,65 +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. -*/ - -/* Styles for YARN */ -* { margin: 0; border: 0 } -html, body { height: 100% } -body { padding: 0; font: 90% sans-serif } -.content { padding-right: 1em } -.content h1, .content h2, .content h3 { margin: 0 0 0.3em; } -/*.content h1, .content h2, .content h3 { margin: 0 0 0.3em; font-weight: normal }*/ -table { border-collapse: collapse; border-spacing: 0; width: 100% } -table br { display: none } -table.info th { text-align: right } -.info-wrap { margin: 0 0 1em } -th, td { padding: 0.2em 0.5em 0 } -td.table { padding: 0 } -.ui-dialog, .shadow { - -moz-box-shadow: 0 8px 38px #000; - -webkit-box-shadow: 0 8px 38px #000; - box-shadow: 0 8px 38px #000 } -/* styles for common objects */ -#logo { float: left; position: relative; line-height: 0.5em; top: -1.3em } -#user { float: right; position: relative; top: -1.5em; font-size: 0.77em } -#header { padding: 1.5em 0.5em; text-align: center } -#nav h3 { padding: 0 0 0 1.6em } -#nav ul { - padding: 0.3em 1em 0.8em 2em; line-height: 0.5em; list-style: none; - line-height: 1.2em; font-size: 90% } -#themeswitcher { margin: 1em 0.25em } -#footer { padding: 1em; text-align: center } -.bold { font-weight: bold; } - - -div.role-info { width: 700px; padding-left: 15px; padding-top: 15px; margin-bottom: 2em; } - -div.role-stats-containers { width: 350px; margin-left: 2em; margin-bottom: 2em; } -div.role-stats-containers table { margin-left: 0.5em; } -div.role-stats-wrap { margin-bottom: 2em; margin-left: 2em; width: 200px; } -div.role-stats-wrap table { margin-left: 0.5em; width: 200px } -div.role-options-wrap { margin-left: 2em; margin-bottom: 2em; width: 350px; } -div.role-options-wrap table { margin-left: 0.5em; } - -.no-table-contents { padding-left: 0.5em; } - -h1.index_header { margin-bottom: 15px; } -div.general_info { margin-bottom: 15px; } -div.container_instances { margin-bottom: 15px; } -div.diagnostics { margin-bottom: 15px; } -div.provider_info { margin-bottom: 15px; } - -div.cluster_json pre { white-space: pre-wrap; }
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/main/resources/webapps/static/yarn.dt.plugins.js ---------------------------------------------------------------------- diff --git a/slider-core/src/main/resources/webapps/static/yarn.dt.plugins.js b/slider-core/src/main/resources/webapps/static/yarn.dt.plugins.js deleted file mode 100644 index 6b8d16c..0000000 --- a/slider-core/src/main/resources/webapps/static/yarn.dt.plugins.js +++ /dev/null @@ -1,146 +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. - - -if (!jQuery.fn.dataTableExt.fnVersionCheck("1.7.5")) { - alert("These plugins requires dataTables 1.7.5+"); -} - -// don't filter on hidden html elements for an sType of title-numeric -$.fn.dataTableExt.ofnSearch['title-numeric'] = function ( sData ) { - return sData.replace(/\n/g," ").replace( /<.*?>/g, "" ); -}; - -// 'title-numeric' sort type -jQuery.fn.dataTableExt.oSort['title-numeric-asc'] = function(a,b) { - var x = a.match(/title=["']?(-?\d+\.?\d*)/)[1]; - var y = b.match(/title=["']?(-?\d+\.?\d*)/)[1]; - x = parseFloat( x ); - y = parseFloat( y ); - return ((x < y) ? -1 : ((x > y) ? 1 : 0)); -}; - -jQuery.fn.dataTableExt.oSort['title-numeric-desc'] = function(a,b) { - var x = a.match(/title=["']?(-?\d+\.?\d*)/)[1]; - var y = b.match(/title=["']?(-?\d+\.?\d*)/)[1]; - x = parseFloat( x ); - y = parseFloat( y ); - return ((x < y) ? 1 : ((x > y) ? -1 : 0)); -}; - -jQuery.fn.dataTableExt.oApi.fnSetFilteringDelay = function ( oSettings, iDelay ) { - var - _that = this, - iDelay = (typeof iDelay == 'undefined') ? 250 : iDelay; - - this.each( function ( i ) { - $.fn.dataTableExt.iApiIndex = i; - var - $this = this, - oTimerId = null, - sPreviousSearch = null, - anControl = $( 'input', _that.fnSettings().aanFeatures.f ); - - anControl.unbind( 'keyup' ).bind( 'keyup', function() { - var $$this = $this; - - if (sPreviousSearch === null || sPreviousSearch != anControl.val()) { - window.clearTimeout(oTimerId); - sPreviousSearch = anControl.val(); - oSettings.oApi._fnProcessingDisplay(oSettings, true); - oTimerId = window.setTimeout(function() { - $.fn.dataTableExt.iApiIndex = i; - _that.fnFilter( anControl.val() ); - oSettings.oApi._fnProcessingDisplay(oSettings, false); - }, iDelay); - } - }); - return this; - } ); - return this; -}; - -function renderHadoopDate(data, type, full) { - if (type === 'display' || type === 'filter') { - if(data === '0') { - return "N/A"; - } - return new Date(parseInt(data)).toUTCString(); - } - // 'sort', 'type' and undefined all just use the number - // If date is 0, then for purposes of sorting it should be consider max_int - return data === '0' ? '9007199254740992' : data; -} - -function renderHadoopElapsedTime(data, type, full) { - if (type === 'display' || type === 'filter') { - var timeDiff = parseInt(data); - if(timeDiff < 0) - return "N/A"; - - var hours = Math.floor(timeDiff / (60*60*1000)); - var rem = (timeDiff % (60*60*1000)); - var minutes = Math.floor(rem / (60*1000)); - rem = rem % (60*1000); - var seconds = Math.floor(rem / 1000); - - var toReturn = ""; - if (hours != 0){ - toReturn += hours; - toReturn += "hrs, "; - } - if (minutes != 0){ - toReturn += minutes; - toReturn += "mins, "; - } - toReturn += seconds; - toReturn += "sec"; - return toReturn; - } - // 'sort', 'type' and undefined all just use the number - return data; -} - -function parseHadoopID(data, type, full) { - if (type === 'display') { - return data; - } - //Return the visible string rather than the entire HTML tag - if (type === 'filter') { - return data.split('>')[1].split('<')[0]; - } - //Parse the ID for 'sort', 'type' and undefined - //The number after the last '_' and before the end tag '<' - var splits = data.split('_'); - return splits[parseInt(splits.length-1)].split('<')[0]; -} - -//JSON array element is "20000 attempt_1360183373897_0001_m_000002_0" -function parseHadoopAttemptID(data, type, full) { - if (type === 'display' || type === 'filter') { - return data.split(' ')[1]; - } - //For sorting use the order as defined in the JSON element - return data.split(' ')[0]; -} - -function parseHadoopProgress(data, type, full) { - if (type === 'display') { - return data; - } - //Return the title attribute for 'sort', 'filter', 'type' and undefined - return data.split("'")[1]; -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/scripts/slider_keytabs.sh ---------------------------------------------------------------------- diff --git a/slider-core/src/scripts/slider_keytabs.sh b/slider-core/src/scripts/slider_keytabs.sh deleted file mode 100644 index f0a8fc2..0000000 --- a/slider-core/src/scripts/slider_keytabs.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env 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. - -# This script exists to create the keytab set for a node on the cluster -# including hbase and ZK alongside then YARN cores. - -# usage -# keytabs <realm> <hostname> -# validate the args - -num_vars=$# -if [[ $num_vars < 2 ]] -then - echo "Usage: $0 <realm> <hostname>" - exit -2 -fi - -realm="$1" -hostname="$2" -dest="." - -kadmin=kadmin.local - -${kadmin} <<EOF -addprinc -randkey hdfs/${hostname}@${realm} -addprinc -randkey yarn/${hostname}@${realm} -addprinc -randkey HTTP/${hostname}@${realm} -addprinc -randkey hbase/${hostname}@${realm} -addprinc -randkey zookeeper/${hostname}@${realm} - -ktadd -norandkey -k ${dest}/hdfs.keytab \ - hdfs/${hostname}@${realm} \ - HTTP/${hostname}@${realm} - -ktadd -norandkey -k ${dest}/yarn.keytab \ - yarn/${hostname}@${realm} \ - HTTP/${hostname}@${realm} - -ktadd -norandkey -k ${dest}/hbase.keytab \ - hbase/${hostname}@${realm} - -ktadd -norandkey -k ${dest}/zookeeper.keytab \ - zookeeper/${hostname}@${realm} -EOF - -exitcode=$? -if [[ $exitcode != 0 ]] -then - echo "keytab generation from ${kadmin} failed with exit code $exitcode" - exit $exitcode -else - echo "keytab files for ${hostname}@${realm} created" -fi http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/scripts/yarnservice.py ---------------------------------------------------------------------- diff --git a/slider-core/src/scripts/yarnservice.py b/slider-core/src/scripts/yarnservice.py deleted file mode 100644 index 1208c28..0000000 --- a/slider-core/src/scripts/yarnservice.py +++ /dev/null @@ -1,383 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# 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. - - -"""Launches a yarn service - -WORK IN PROGRESS, IGNORE - -This is as work in progress project to build as new launcher script for -any Hadoop service -A key feature here is that the configs are defined in JSON files - -files that are read in the order passed down, and merged into each other. - -The final merged file is used to define the java command to execute --and hadoop XML files. - - -It uses a JSON config file - --jfile configuration file (JSON format) - -class classname - -Dname=value -arbitrary value to pass down to the JVM - --java: any JVM arg - -javaX: javaX value - - - after an -- , all following commands are passed straight down to the invoked process. - # -xJ name=value JVM options. No: this is just another param - -xF file file to load next. Files are loaded in order. - -xD name=value again, values are loaded in order - -xU undefine - -xX main class, 'eXecute' - - -- end of arguments - - -""" - -import sys -# see : http://simplejson.readthedocs.org/en/latest/ -# and install w/ easy_install simplejson -import simplejson - -KEY_JFILE = "-xF" -KEY_DEF = "-xD" -KEY_UNDEF = "-xU" -KEY_EXEC = "-xX" -KEY_ARGS = "--" - -COMMANDS = [KEY_JFILE, KEY_DEF, KEY_EXEC] - -# - -def debug(string) : - print string - - -def pop_required_arg(arglist, previousArg) : - """ - Pop the first element off the list and return it. - If the list is empty, raise an exception about a missing argument after the $previousArgument - """ - if not len(arglist) : - raise Exception, "Missing required parameter after %s" % previousArg - head = arglist[0] - del arglist[0] - return head - - -def parse_one_jfile(filename) : - """ - read in the given config file - """ - parsed = simplejson.load(open(filename, "r")) - return parsed - -# hand down sys.argv: -def extract_jfiles(args) : - """ takes a list of arg strings and separates them into jfile references - and other arguments. - """ - l = len(args) - stripped = [] - jfiles = [] - index = 0 - while index < l : - elt = args[index] - index += 1 - if KEY_JFILE == elt : - # a match - if index == l : - #overshoot - raise Exception("Missing filename after " + KEY_JFILE) - filename = args[index] - debug("jfile " + filename) - jfiles.append(filename) - index += 1 - else : - stripped.append(elt) - return jfiles, stripped - - -def extract_args(args) : - """ - Take a list of args, parse them or fail, generating a dictionary of actions - Return: dictionary and all leftover arguments - """ - jfiles = [] - execs = [] - defs = [] - remainder = [] - while len(args) : - # the next call cannot fail, because of the len(args) - arg = pop_required_arg(args, "") - if KEY_JFILE == arg : - jfiles.append(pop_required_arg(args, KEY_JFILE)) - elif KEY_DEF == arg : - defs.append((KEY_DEF, pop_required_arg(args, KEY_DEF))) - elif KEY_UNDEF == arg : - defs.append((KEY_UNDEF, pop_required_arg(args, KEY_UNDEF))) - elif KEY_EXEC == arg : - execs.append(pop_required_arg(args, KEY_EXEC)) - elif KEY_ARGS == arg : - remainder += args - args = [] - else : - remainder.append(arg) - #build the action list - actions = { - KEY_JFILE : jfiles, - KEY_EXEC : execs, - KEY_DEF : defs, - KEY_ARGS : remainder - } - #end of the run, there's a dictionary and a list of unparsed values - return actions - - -def get(conf, key, defVal) : - if conf.has_key(key) : - return conf[key] - else : - return defVal - - -def merge_json(conf, json) : - """ merge in a json dict with the existing one - in: configuration dict, json dict - out: configuration' - """ - for (key, val) in json.items() : - if key in conf : - #there's a match, do a more detailed merge - oldval = conf[key] - if type(oldval) == dict and type(val) == dict : - # two dictionary instances -merge - merge_json(oldval, val) - else : - conf[key] = val - else : - conf[key] = val - return conf - - -def merge_jfile(conf, filename) : - json = parse_one_jfile(filename) - return merge_json(conf, json) - - -def merge_jfile_list(conf, jfiles) : - """ merge a list of jfiles on top of a conf dict - """ - for jfile in jfiles : - conf = merge_jfile(conf, jfile) - return conf - - -def split_to_keyval_tuple(param) : - """ - Split a key=value string into the (key,value) tuple - * an exception is raised on any string "=value" - * if there is no string: exception. - * a key only definition maps to (key, None) - * a "key=" definition maps to (key, "") - """ - if not len(param) : - raise Exception, "Empty string cannot be a key=value definition" - equalsPos = param.find("=") - if equalsPos < 0 : - return param, None - elif not equalsPos : - raise Exception, "no key in argument %s" % param - else : - key = param[:(equalsPos - 1)] - value = param[(equalsPos + 1) :] - return key, value - - -def recursive_define(conf, path, value) : - if not len(path) : - #fallen off the end of the world - return - entry = path[0] - if len(path) == 1 : - #end of list, apply it. - conf[entry] = value - else : - #there's 1+ elements below, yet there's a subdir here. - if conf.has_key(entry) and type(conf[entry]) == dict : - #it's a subdir, simple: recurse. - recursive_define(conf[entry], path[1 :], value) - else : - #either there is an entry that isn't a conf, or its not there. Same outcome. - subconf = {} - conf[entry] = subconf - recursive_define(subconf, path[1 :], value) - -def recursive_undef(conf, path) : - if not len(path) : - #fallen off the end of the world - return - entry = path[0] - if len(path) == 1 : - #end of list, apply it. - del conf[entry] - else : - #there's 1+ elements below, yet there's a subdir here. - if conf.has_key(entry) and type(conf[entry]) == dict : - #it's a subdir, simple: recurse. - recursive_undef(conf[entry], path[1 :]) - else : - #either there is an entry that isn't a conf, or its not there. Same outcome. - pass - -def apply_action(conf, action, key, value) : - """ - Apply either a def or undef action; splitting the key into a path and running through it. - """ - keypath = key.split("/") - #now have a split key, - if KEY_DEF == action : - recursive_define(conf, keypath, value) - elif KEY_UNDEF == action : - recursive_undef(conf, keypath) - - -def apply_local_definitions(conf, definitions) : - """ - Run through the definition actions and apply them one by one - """ - for defn in definitions : - # split into key=value; no value -> empty string - (action, param) = defn - if KEY_DEF == action : - (key, val) = split_to_keyval_tuple(param) - apply_action(conf, KEY_DEF, key, val) - - return conf - - -#def parse_args(conf, args) : -# """ -# split an arg string, parse the jfiles & merge over the conf -# (configuration, args[]) -> (conf', stripped, jfiles[]) -# """ -# (jfiles, stripped) = extract_jfiles(args) -# -# actions = extract_args(args) -# jfiles = actions[KEY_JFILE] -# conf = merge_jfile_list(conf, jfiles) -# return conf, actions - - -def print_conf(conf) : - """ dump the configuration to the console - """ - print "{" - for (key, val) in conf.items() : - if type(val) == dict : - print key - print_conf(val) - else : - print "" + key + " => " + str(val) - print "}" - - -def list_to_str(l, spacer) : - result = "" - for elt in l : - if len(result) > 0 : - result += spacer - result += elt - return result - - -def list_to_hxml_str(l) : - return list_to_str(l, ",") - - -def export_kv_xml(output, key, value) : - line = "<property><name>" + key + "</name><value>" + str(value) + "</value>\n" - print line - output.write(line) - - -def export_to_hadoop_xml(output, conf) : - """ export the conf to hadoop XML - dictionaries are skipped. - """ - output.write("<configuration>\n") - for (key, value) in conf.items() : - if type(value) is list : - # list print - export_kv_xml(output, key, list_to_hxml_str(value)) - else : - if type(value) is dict : - print "skipping dict " + key - else : - export_kv_xml(output, key, value) - output.write("</configuration>\n") - - -def start(conf, stripped_args) : - """ - start the process by grabbing exec/args for the arguments - """ - ex = conf["exec"] - args = [] - jsonargs = get(ex, "args", []) - args.extend(jsonargs) - args.extend(stripped_args) - classname = get(ex, "classname", "") - if not len(classname) : - raise Exception, "No classname supplied" - classname = get(ex, "classname", "") - commandline = ["java"] - classpath = [] - jvmargs = [] - commandline.extend(jvmargs) - commandline.append("-classpath") - commandline.append(list_to_str(classpath, ":")) - commandline.append("org.apache.hadoop.yarn.service.launcher.ServiceLauncher") - commandline.append(classname) - commandline.extend(args) - print "ready to exec : %s" % commandline - - -def main() : -# (conf, stripped, jfiles) = parse_args({}, sys.argv[1 :]) - actions = extract_args(sys.argv[1 :]) - jfiles = actions[KEY_JFILE] - conf = merge_jfile_list({}, jfiles) - apply_local_definitions(conf, actions[KEY_DEF]) - exec_args = actions[KEY_ARGS] - - print_conf(conf) - # if len(stripped) > 0 : - #got an output file - # filename = stripped[0] - # print "Writing XML configuration to " + filename - # output = open(filename, "w") - # export_to_hadoop_xml(output, conf["site"]) - start(conf, exec_args) - - -if __name__ == "__main__" : - main() - - http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/site/site.xml ---------------------------------------------------------------------- diff --git a/slider-core/src/site/site.xml b/slider-core/src/site/site.xml deleted file mode 100644 index 8dd81d4..0000000 --- a/slider-core/src/site/site.xml +++ /dev/null @@ -1,49 +0,0 @@ -<?xml version="1.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. - --> - -<project name="Slider"> -<!-- - - <skin> - <groupId>org.apache.maven.skins</groupId> - <artifactId>maven-fluido-skin</artifactId> - <version>1.3.0</version> - </skin> ---> -<!-- - - <custom> - <fluidoSkin> - <topBarEnabled>true</topBarEnabled> - <sideBarEnabled>false</sideBarEnabled> - </fluidoSkin> - </custom> ---> - - <version position="right"/> - - <body> - <menu ref="reports"/> - - - - </body> - - -</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentAM.groovy ---------------------------------------------------------------------- diff --git a/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentAM.groovy b/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentAM.groovy index ff95130..75dfcf4 100644 --- a/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentAM.groovy +++ b/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentAM.groovy @@ -32,7 +32,7 @@ import org.apache.slider.common.SliderKeys import org.apache.slider.common.params.ActionRegistryArgs import org.apache.slider.common.params.ActionDestroyArgs import org.apache.slider.common.tools.Duration -import org.apache.slider.core.build.InstanceBuilder +import org.apache.slider.core.buildutils.InstanceBuilder import org.apache.slider.core.conf.AggregateConf import org.apache.slider.core.exceptions.SliderException import org.apache.slider.core.launch.LaunchedApplication http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/test/groovy/org/apache/slider/client/TestSliderClientMethods.groovy ---------------------------------------------------------------------- diff --git a/slider-core/src/test/groovy/org/apache/slider/client/TestSliderClientMethods.groovy b/slider-core/src/test/groovy/org/apache/slider/client/TestSliderClientMethods.groovy index e244923..40a5441 100644 --- a/slider-core/src/test/groovy/org/apache/slider/client/TestSliderClientMethods.groovy +++ b/slider-core/src/test/groovy/org/apache/slider/client/TestSliderClientMethods.groovy @@ -24,7 +24,7 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration import org.apache.hadoop.yarn.exceptions.YarnException import org.apache.slider.common.SliderXmlConfKeys import org.apache.slider.common.tools.SliderUtils -import org.apache.slider.core.build.InstanceBuilder +import org.apache.slider.core.buildutils.InstanceBuilder import org.apache.slider.core.conf.AggregateConf import org.apache.slider.core.exceptions.SliderException import org.apache.slider.core.launch.LaunchedApplication http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/test/groovy/org/apache/slider/providers/agent/TestAgentAMManagementWS.groovy ---------------------------------------------------------------------- diff --git a/slider-core/src/test/groovy/org/apache/slider/providers/agent/TestAgentAMManagementWS.groovy b/slider-core/src/test/groovy/org/apache/slider/providers/agent/TestAgentAMManagementWS.groovy index 7eb1d17..af6f5f3 100644 --- a/slider-core/src/test/groovy/org/apache/slider/providers/agent/TestAgentAMManagementWS.groovy +++ b/slider-core/src/test/groovy/org/apache/slider/providers/agent/TestAgentAMManagementWS.groovy @@ -28,7 +28,7 @@ import org.apache.slider.api.StatusKeys import org.apache.slider.client.SliderClient import org.apache.slider.common.SliderKeys import static org.apache.slider.common.SliderXmlConfKeys.KEY_KEYSTORE_LOCATION -import org.apache.slider.core.build.InstanceBuilder +import org.apache.slider.core.buildutils.InstanceBuilder import org.apache.slider.core.conf.AggregateConf import org.apache.slider.core.conf.MapOperations import org.apache.slider.core.exceptions.SliderException http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/test/groovy/org/apache/slider/server/appmaster/TestDelayInContainerLaunch.groovy ---------------------------------------------------------------------- diff --git a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/TestDelayInContainerLaunch.groovy b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/TestDelayInContainerLaunch.groovy index 51e01d5..72410db 100644 --- a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/TestDelayInContainerLaunch.groovy +++ b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/TestDelayInContainerLaunch.groovy @@ -26,7 +26,7 @@ import org.apache.slider.api.ClusterDescription import org.apache.slider.api.ResourceKeys import org.apache.slider.client.SliderClient import org.apache.slider.common.params.ActionKillContainerArgs -import org.apache.slider.core.build.InstanceBuilder +import org.apache.slider.core.buildutils.InstanceBuilder import org.apache.slider.core.conf.AggregateConf import org.apache.slider.core.exceptions.SliderException import org.apache.slider.core.launch.LaunchedApplication http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/mock/MockContainer.groovy ---------------------------------------------------------------------- diff --git a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/mock/MockContainer.groovy b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/mock/MockContainer.groovy index ad586cd..32cfc0f 100644 --- a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/mock/MockContainer.groovy +++ b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/mock/MockContainer.groovy @@ -20,6 +20,7 @@ package org.apache.slider.server.appmaster.model.mock import org.apache.hadoop.yarn.api.records.Container import org.apache.hadoop.yarn.api.records.ContainerId +import org.apache.hadoop.yarn.api.records.ExecutionType import org.apache.hadoop.yarn.api.records.NodeId import org.apache.hadoop.yarn.api.records.Priority import org.apache.hadoop.yarn.api.records.Resource @@ -28,6 +29,7 @@ import org.apache.hadoop.yarn.api.records.Token class MockContainer extends Container { ContainerId id; + ExecutionType executionType NodeId nodeId String nodeHttpAddress; Resource resource @@ -53,4 +55,12 @@ class MockContainer extends Container { ", nodeHttpAddress='$nodeHttpAddress'," + " priority=$priority }" } + + public ExecutionType getExecutionType() { + return executionType; + } + + public void setExecutionType(ExecutionType executionType) { + this.executionType = executionType + } } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/test/java/org/apache/slider/common/tools/TestSliderUtils.java ---------------------------------------------------------------------- diff --git a/slider-core/src/test/java/org/apache/slider/common/tools/TestSliderUtils.java b/slider-core/src/test/java/org/apache/slider/common/tools/TestSliderUtils.java deleted file mode 100644 index 20e72c0..0000000 --- a/slider-core/src/test/java/org/apache/slider/common/tools/TestSliderUtils.java +++ /dev/null @@ -1,159 +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.slider.common.tools; - -import org.apache.commons.io.FileUtils; -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.fs.FileSystem; -import org.apache.hadoop.fs.Path; -import org.apache.hadoop.yarn.api.records.ApplicationReport; -import org.apache.hadoop.yarn.api.records.YarnApplicationState; -import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationReportPBImpl; -import org.apache.slider.tools.TestUtility; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -/** Test slider util methods. */ -public class TestSliderUtils { - protected static final Logger log = - LoggerFactory.getLogger(TestSliderUtils.class); - @Rule - public TemporaryFolder folder = new TemporaryFolder(); - - @Test - public void testGetMetaInfoStreamFromZip() throws Exception { - String zipFileName = TestUtility.createAppPackage( - folder, - "testpkg", - "test.zip", - "target/test-classes/org/apache/slider/common/tools/test"); - Configuration configuration = new Configuration(); - FileSystem fs = FileSystem.getLocal(configuration); - log.info("fs working dir is {}", fs.getWorkingDirectory().toString()); - SliderFileSystem sliderFileSystem = new SliderFileSystem(fs, configuration); - - InputStream stream = SliderUtils.getApplicationResourceInputStream( - sliderFileSystem.getFileSystem(), - new Path(zipFileName), - "metainfo.xml"); - Assert.assertTrue(stream != null); - Assert.assertTrue(stream.available() > 0); - } - - @Test - public void testTruncate() { - Assert.assertEquals(SliderUtils.truncate(null, 5), null); - Assert.assertEquals(SliderUtils.truncate("323", -1), "323"); - Assert.assertEquals(SliderUtils.truncate("3232", 5), "3232"); - Assert.assertEquals(SliderUtils.truncate("1234567890", 0), "1234567890"); - Assert.assertEquals(SliderUtils.truncate("123456789012345", 15), "123456789012345"); - Assert.assertEquals(SliderUtils.truncate("123456789012345", 14), "12345678901..."); - Assert.assertEquals(SliderUtils.truncate("1234567890", 1), "1"); - Assert.assertEquals(SliderUtils.truncate("1234567890", 10), "1234567890"); - Assert.assertEquals(SliderUtils.truncate("", 10), ""); - } - - @Test - public void testApplicationReportComparison() { - List<ApplicationReport> instances = getApplicationReports(); - - SliderUtils.sortApplicationsByMostRecent(instances); - - Assert.assertEquals(1000, instances.get(0).getStartTime()); - Assert.assertEquals(1000, instances.get(1).getStartTime()); - Assert.assertEquals(1000, instances.get(2).getStartTime()); - Assert.assertEquals(1000, instances.get(3).getStartTime()); - - instances = getApplicationReports(); - - SliderUtils.sortApplicationReport(instances); - Assert.assertEquals(1000, instances.get(0).getStartTime()); - Assert.assertEquals(1000, instances.get(1).getStartTime()); - Assert.assertEquals(1000, instances.get(2).getStartTime()); - Assert.assertEquals(1000, instances.get(3).getStartTime()); - - Assert.assertTrue(instances.get(0).getYarnApplicationState() == YarnApplicationState.ACCEPTED || - instances.get(0).getYarnApplicationState() == YarnApplicationState.RUNNING); - Assert.assertTrue(instances.get(1).getYarnApplicationState() == YarnApplicationState.ACCEPTED || - instances.get(1).getYarnApplicationState() == YarnApplicationState.RUNNING); - Assert.assertTrue(instances.get(2).getYarnApplicationState() == YarnApplicationState.ACCEPTED || - instances.get(2).getYarnApplicationState() == YarnApplicationState.RUNNING); - Assert.assertTrue(instances.get(3).getYarnApplicationState() == YarnApplicationState.KILLED); - } - - private List<ApplicationReport> getApplicationReports() { - List<ApplicationReport> instances = new ArrayList<ApplicationReport>(); - instances.add(getApplicationReport(1000, 0, "app1", YarnApplicationState.ACCEPTED)); - instances.add(getApplicationReport(900, 998, "app1", YarnApplicationState.KILLED)); - instances.add(getApplicationReport(900, 998, "app2", YarnApplicationState.FAILED)); - instances.add(getApplicationReport(1000, 0, "app2", YarnApplicationState.RUNNING)); - instances.add(getApplicationReport(800, 837, "app3", YarnApplicationState.FINISHED)); - instances.add(getApplicationReport(1000, 0, "app3", YarnApplicationState.RUNNING)); - instances.add(getApplicationReport(900, 998, "app3", YarnApplicationState.KILLED)); - instances.add(getApplicationReport(800, 837, "app4", YarnApplicationState.FINISHED)); - instances.add(getApplicationReport(1000, 1050, "app4", YarnApplicationState.KILLED)); - instances.add(getApplicationReport(900, 998, "app4", YarnApplicationState.FINISHED)); - - Assert.assertEquals("app1", instances.get(0).getApplicationType()); - Assert.assertEquals("app1", instances.get(1).getApplicationType()); - Assert.assertEquals("app2", instances.get(2).getApplicationType()); - Assert.assertEquals("app2", instances.get(3).getApplicationType()); - return instances; - } - - private ApplicationReportPBImpl getApplicationReport(long startTime, - long finishTime, - String name, - YarnApplicationState state) { - ApplicationReportPBImpl ar = new ApplicationReportPBImpl(); - ar.setFinishTime(finishTime); - ar.setStartTime(startTime); - ar.setApplicationType(name); - ar.setYarnApplicationState(state); - return ar; - } - - - @Test - public void testGetHdpVersion() { - String hdpVersion = "2.3.2.0-2766"; - Assert.assertEquals("Version should be empty", null, - SliderUtils.getHdpVersion()); - } - - @Test - public void testIsHdp() { - Assert.assertFalse("Should be false", SliderUtils.isHdp()); - } - - @Test - public void testWrite() throws IOException { - File testWriteFile = folder.newFile("testWrite"); - SliderUtils.write(testWriteFile, "test".getBytes("UTF-8"), true); - Assert.assertTrue(FileUtils.readFileToString(testWriteFile, "UTF-8").equals("test")); - } -} http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/test/java/org/apache/slider/core/launch/TestAppMasterLauncher.java ---------------------------------------------------------------------- diff --git a/slider-core/src/test/java/org/apache/slider/core/launch/TestAppMasterLauncher.java b/slider-core/src/test/java/org/apache/slider/core/launch/TestAppMasterLauncher.java deleted file mode 100644 index eae9658..0000000 --- a/slider-core/src/test/java/org/apache/slider/core/launch/TestAppMasterLauncher.java +++ /dev/null @@ -1,157 +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.slider.core.launch; - -import java.lang.reflect.Method; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; -import org.apache.hadoop.yarn.api.records.LogAggregationContext; -import org.apache.hadoop.yarn.client.api.YarnClientApplication; -import org.apache.slider.api.ResourceKeys; -import org.apache.slider.client.SliderYarnClientImpl; -import org.apache.slider.common.SliderKeys; -import org.easymock.EasyMock; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -public class TestAppMasterLauncher { - SliderYarnClientImpl mockYarnClient; - YarnClientApplication yarnClientApp; - ApplicationSubmissionContext appSubmissionContext; - Set<String> tags = Collections.emptySet(); - AppMasterLauncher appMasterLauncher = null; - boolean isOldApi = true; - Method rolledLogsIncludeMethod = null; - Method rolledLogsExcludeMethod = null; - - @Before - public void initialize() throws Exception { - mockYarnClient = EasyMock.createNiceMock(SliderYarnClientImpl.class); - yarnClientApp = EasyMock.createNiceMock(YarnClientApplication.class); - appSubmissionContext = EasyMock - .createNiceMock(ApplicationSubmissionContext.class); - EasyMock.expect(yarnClientApp.getApplicationSubmissionContext()) - .andReturn(appSubmissionContext).once(); - EasyMock.expect(mockYarnClient.createApplication()) - .andReturn(yarnClientApp).once(); - - try { - LogAggregationContext.class.getMethod("newInstance", String.class, - String.class, String.class, String.class); - isOldApi = false; - rolledLogsIncludeMethod = LogAggregationContext.class - .getMethod("getRolledLogsIncludePattern"); - rolledLogsExcludeMethod = LogAggregationContext.class - .getMethod("getRolledLogsExcludePattern"); - } catch (Exception e) { - isOldApi = true; - } - } - - /** - * These tests will probably fail when compiled against hadoop 2.7+. Please - * refer to SLIDER-810. It has been purposely not modified so that it fails - * and that someone needs to modify the code in - * {@code AbstractLauncher#extractLogAggregationContext(Map)}. Comments are - * provided in that method as to what needs to be done. - * - * @throws Exception - */ - @Test - public void testExtractLogAggregationContext() throws Exception { - Map<String, String> options = new HashMap<String, String>(); - options.put(ResourceKeys.YARN_LOG_INCLUDE_PATTERNS, - " | slider*.txt |agent.out| |"); - options.put(ResourceKeys.YARN_LOG_EXCLUDE_PATTERNS, - "command*.json| agent.log* | "); - - EasyMock.replay(mockYarnClient, appSubmissionContext, yarnClientApp); - appMasterLauncher = new AppMasterLauncher("cl1", SliderKeys.APP_TYPE, null, - null, mockYarnClient, false, null, options, tags, null); - - // Verify the include/exclude patterns - String expectedInclude = "slider*.txt|agent.out"; - String expectedExclude = "command*.json|agent.log*"; - assertPatterns(expectedInclude, expectedExclude); - - EasyMock.verify(mockYarnClient, appSubmissionContext, yarnClientApp); - - } - - @Test - public void testExtractLogAggregationContextEmptyIncludePattern() - throws Exception { - Map<String, String> options = new HashMap<String, String>(); - options.put(ResourceKeys.YARN_LOG_INCLUDE_PATTERNS, " "); - options.put(ResourceKeys.YARN_LOG_EXCLUDE_PATTERNS, - "command*.json| agent.log* | "); - - EasyMock.replay(mockYarnClient, appSubmissionContext, yarnClientApp); - appMasterLauncher = new AppMasterLauncher("cl1", SliderKeys.APP_TYPE, null, - null, mockYarnClient, false, null, options, tags, null); - - // Verify the include/exclude patterns - String expectedInclude = isOldApi ? "" : ".*"; - String expectedExclude = "command*.json|agent.log*"; - assertPatterns(expectedInclude, expectedExclude); - - EasyMock.verify(mockYarnClient, appSubmissionContext, yarnClientApp); - } - - @Test - public void testExtractLogAggregationContextEmptyIncludeAndExcludePattern() - throws Exception { - Map<String, String> options = new HashMap<String, String>(); - options.put(ResourceKeys.YARN_LOG_INCLUDE_PATTERNS, ""); - options.put(ResourceKeys.YARN_LOG_EXCLUDE_PATTERNS, " "); - - EasyMock.replay(mockYarnClient, appSubmissionContext, yarnClientApp); - appMasterLauncher = new AppMasterLauncher("cl1", SliderKeys.APP_TYPE, null, - null, mockYarnClient, false, null, options, tags, null); - - // Verify the include/exclude patterns - String expectedInclude = isOldApi ? "" : ".*"; - String expectedExclude = ""; - assertPatterns(expectedInclude, expectedExclude); - - EasyMock.verify(mockYarnClient, appSubmissionContext, yarnClientApp); - } - - private void assertPatterns(String expectedIncludePattern, - String expectedExcludePattern) throws Exception { - if (isOldApi) { - Assert.assertEquals(expectedIncludePattern, - appMasterLauncher.logAggregationContext.getIncludePattern()); - Assert.assertEquals(expectedExcludePattern, - appMasterLauncher.logAggregationContext.getExcludePattern()); - } else { - Assert.assertEquals(expectedIncludePattern, - (String) rolledLogsIncludeMethod - .invoke(appMasterLauncher.logAggregationContext)); - Assert.assertEquals(expectedExcludePattern, - (String) rolledLogsExcludeMethod - .invoke(appMasterLauncher.logAggregationContext)); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/test/java/org/apache/slider/core/launch/TestAppMasterLauncherWithAmReset.java ---------------------------------------------------------------------- diff --git a/slider-core/src/test/java/org/apache/slider/core/launch/TestAppMasterLauncherWithAmReset.java b/slider-core/src/test/java/org/apache/slider/core/launch/TestAppMasterLauncherWithAmReset.java deleted file mode 100644 index a8f6b26..0000000 --- a/slider-core/src/test/java/org/apache/slider/core/launch/TestAppMasterLauncherWithAmReset.java +++ /dev/null @@ -1,92 +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.slider.core.launch; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationResponse; -import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; -import org.apache.hadoop.yarn.client.api.YarnClientApplication; -import org.apache.hadoop.yarn.util.Records; -import org.apache.slider.api.ResourceKeys; -import org.apache.slider.client.SliderYarnClientImpl; -import org.apache.slider.common.SliderKeys; -import org.easymock.EasyMock; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -public class TestAppMasterLauncherWithAmReset { - SliderYarnClientImpl mockYarnClient; - YarnClientApplication yarnClientApp; - ApplicationSubmissionContext appSubmissionContext; - GetNewApplicationResponse newApp; - Set<String> tags = Collections.emptySet(); - AppMasterLauncher appMasterLauncher = null; - boolean isOldApi = true; - - @Before - public void initialize() throws Exception { - mockYarnClient = EasyMock.createNiceMock(SliderYarnClientImpl.class); - yarnClientApp = EasyMock.createNiceMock(YarnClientApplication.class); - newApp = EasyMock.createNiceMock(GetNewApplicationResponse.class); - EasyMock.expect(mockYarnClient.createApplication()) - .andReturn(new YarnClientApplication(newApp, - Records.newRecord(ApplicationSubmissionContext.class))); - } - - @Test - public void testExtractYarnResourceManagerAmRetryCountWindowMs() throws - Exception { - Map<String, String> options = new HashMap<String, String>(); - final String expectedInterval = Integer.toString (120000); - options.put(ResourceKeys.YARN_RESOURCEMANAGER_AM_RETRY_COUNT_WINDOW_MS, - expectedInterval); - EasyMock.replay(mockYarnClient, yarnClientApp); - - appMasterLauncher = new AppMasterLauncher("am1", SliderKeys.APP_TYPE, null, - null, mockYarnClient, false, null, options, tags, null); - - ApplicationSubmissionContext ctx = appMasterLauncher.application - .getApplicationSubmissionContext(); - String retryIntervalWindow = Long.toString(ctx - .getAttemptFailuresValidityInterval()); - Assert.assertEquals(expectedInterval, retryIntervalWindow); - } - - @Test - public void testExtractYarnResourceManagerAmRetryCountWindowMsDefaultValue() - throws Exception { - Map<String, String> options = new HashMap<String, String>(); - EasyMock.replay(mockYarnClient, yarnClientApp); - - appMasterLauncher = new AppMasterLauncher("am1", SliderKeys.APP_TYPE, null, - null, mockYarnClient, false, null, options, tags, null); - - ApplicationSubmissionContext ctx = appMasterLauncher.application - .getApplicationSubmissionContext(); - long retryIntervalWindow = ctx.getAttemptFailuresValidityInterval(); - Assert.assertEquals(ResourceKeys.DEFAULT_AM_RETRY_COUNT_WINDOW_MS, - retryIntervalWindow); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/test/java/org/apache/slider/core/registry/docstore/TestPublishedConfigurationOutputter.java ---------------------------------------------------------------------- diff --git a/slider-core/src/test/java/org/apache/slider/core/registry/docstore/TestPublishedConfigurationOutputter.java b/slider-core/src/test/java/org/apache/slider/core/registry/docstore/TestPublishedConfigurationOutputter.java deleted file mode 100644 index 63d5961..0000000 --- a/slider-core/src/test/java/org/apache/slider/core/registry/docstore/TestPublishedConfigurationOutputter.java +++ /dev/null @@ -1,221 +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.slider.core.registry.docstore; - -import com.google.common.base.Charsets; -import org.apache.commons.io.FileUtils; -import org.apache.hadoop.fs.Path; -import org.apache.slider.common.tools.SliderFileSystem; -import org.codehaus.jackson.map.ObjectMapper; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import org.powermock.api.easymock.PowerMock; -import org.yaml.snakeyaml.Yaml; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import static org.easymock.EasyMock.anyObject; -import static org.easymock.EasyMock.expect; -import static org.mockito.Matchers.anyString; -import static org.powermock.api.easymock.PowerMock.createNiceMock; - -public class TestPublishedConfigurationOutputter { - private static HashMap<String, String> config = new HashMap<>(); - - @Rule - public TemporaryFolder tmpDir = new TemporaryFolder(); - - @Before - public void setup() { - config.put("key1", "val1"); - } - - @Test - public void testJson() throws IOException { - PublishedConfigurationOutputter configurationOutputter = - PublishedConfigurationOutputter.createOutputter(ConfigFormat.JSON, - new PublishedConfiguration("description", - config.entrySet())); - - String output = configurationOutputter.asString().replaceAll("( |\\r|\\n)", - ""); - assert "{\"key1\":\"val1\"}".equals(output); - - File file = tmpDir.newFile(); - configurationOutputter.save(file); - - ObjectMapper mapper = new ObjectMapper(); - Map<String, String> read = mapper.readValue(file, Map.class); - assert 1 == read.size(); - assert "val1".equals(read.get("key1")); - } - - @Test - public void testXml() throws IOException { - PublishedConfigurationOutputter configurationOutputter = - PublishedConfigurationOutputter.createOutputter(ConfigFormat.XML, - new PublishedConfiguration("description", - config.entrySet())); - - String output = configurationOutputter.asString().replaceAll("( |\\r|\\n)", - ""); - assert output.contains( - "<configuration><property><name>key1</name><value>val1</value><source/></property></configuration>"); - - File file = tmpDir.newFile(); - configurationOutputter.save(file); - - assert FileUtils.readFileToString(file, Charsets.UTF_8) - .replaceAll("( |\\r|\\n)", "") - .contains( - "<configuration><property><name>key1</name><value>val1</value><source/></property></configuration>"); - } - - @Test - public void testHadoopXml() throws IOException { - PublishedConfigurationOutputter configurationOutputter = - PublishedConfigurationOutputter.createOutputter(ConfigFormat.HADOOP_XML, - new PublishedConfiguration("description", - config.entrySet())); - - String output = configurationOutputter.asString().replaceAll("( |\\r|\\n)", - ""); - assert output.contains("<configuration><property><name>key1</name><value>val1</value><source/></property></configuration>"); - - File file = tmpDir.newFile(); - configurationOutputter.save(file); - - assert FileUtils.readFileToString(file, Charsets.UTF_8) - .replaceAll("( |\\r|\\n)", "") - .contains( "<configuration><property><name>key1</name><value>val1</value><source/></property></configuration>"); - } - - @Test - public void testProperties() throws IOException { - PublishedConfigurationOutputter configurationOutputter = - PublishedConfigurationOutputter.createOutputter(ConfigFormat.PROPERTIES, - new PublishedConfiguration("description", - config.entrySet())); - - String output = configurationOutputter.asString(); - assert output.contains("key1=val1"); - - File file = tmpDir.newFile(); - configurationOutputter.save(file); - - Properties properties = new Properties(); - FileInputStream fis = null; - try { - fis = new FileInputStream(file); - properties.load(fis); - } finally { - if (fis != null) { - fis.close(); - } - } - assert 1 == properties.size(); - assert "val1".equals(properties.getProperty("key1")); - } - - @Test - public void testYaml() throws IOException { - PublishedConfigurationOutputter configurationOutputter = - PublishedConfigurationOutputter.createOutputter(ConfigFormat.YAML, - new PublishedConfiguration("description", - config.entrySet())); - - String output = configurationOutputter.asString().replaceAll("(\\r|\\n)", - ""); - assert "key1: val1".equals(output); - - File file = tmpDir.newFile(); - configurationOutputter.save(file); - - Yaml yaml = new Yaml(); - FileInputStream fis = null; - Map<String, String> read; - try { - fis = new FileInputStream(file); - read = (Map<String, String>) yaml.load(fis); - } finally { - if (fis != null) { - fis.close(); - } - } - assert 1 == read.size(); - assert "val1".equals(read.get("key1")); - } - - @Test - public void testEnv() throws IOException { - HashMap<String, String> envConfig = new HashMap<>(config); - envConfig.put("content", "content {{key1}} "); - - PublishedConfigurationOutputter configurationOutputter = - PublishedConfigurationOutputter.createOutputter(ConfigFormat.ENV, - new PublishedConfiguration("description", - envConfig.entrySet())); - - String output = configurationOutputter.asString(); - assert "content val1 ".equals(output); - - File file = tmpDir.newFile(); - configurationOutputter.save(file); - - assert "content val1 ".equals(FileUtils.readFileToString(file, - Charsets.UTF_8)); - } - - @Test - public void testTemplate1() throws IOException { - HashMap<String, String> templateConfig = new HashMap<>(config); - templateConfig.put(ConfigUtils.TEMPLATE_FILE, "templateFileName"); - - SliderFileSystem fileSystem = createNiceMock(SliderFileSystem.class); - expect(fileSystem.buildResourcePath(anyString())).andReturn(new Path("path")).anyTimes(); - expect(fileSystem.isFile(anyObject(Path.class))).andReturn(true).anyTimes(); - expect(fileSystem.cat(anyObject(Path.class))).andReturn("content {{key1}}\n more ${key1} content").anyTimes(); - - PowerMock.replay(fileSystem); - - ConfigUtils.prepConfigForTemplateOutputter(ConfigFormat.TEMPLATE, - templateConfig, fileSystem, "clusterName", null); - PublishedConfigurationOutputter configurationOutputter = - PublishedConfigurationOutputter.createOutputter(ConfigFormat.TEMPLATE, - new PublishedConfiguration("description", - templateConfig.entrySet())); - - String output = configurationOutputter.asString(); - assert "content val1\n more val1 content".equals(output); - - File file = tmpDir.newFile(); - configurationOutputter.save(file); - - PowerMock.verify(fileSystem); - - assert "content val1\n more val1 content".equals( - FileUtils.readFileToString(file, Charsets.UTF_8)); - } -} http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentClientProvider.java ---------------------------------------------------------------------- diff --git a/slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentClientProvider.java b/slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentClientProvider.java deleted file mode 100644 index 0bea8fa..0000000 --- a/slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentClientProvider.java +++ /dev/null @@ -1,77 +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.slider.providers.agent; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.fs.FileSystem; -import org.apache.slider.common.tools.SliderFileSystem; -import org.apache.slider.core.conf.AggregateConf; -import org.apache.slider.core.exceptions.BadConfigException; -import org.apache.slider.tools.TestUtility; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Set; - -/** - * - */ -public class TestAgentClientProvider { - protected static final Logger log = - LoggerFactory.getLogger(TestAgentClientProvider.class); - @Rule - public TemporaryFolder folder = new TemporaryFolder(); - - @Test - public void testGetApplicationTags() throws Exception { - Configuration configuration = new Configuration(); - FileSystem fs = FileSystem.getLocal(configuration); - SliderFileSystem sliderFileSystem = new SliderFileSystem(fs, configuration); - - AgentClientProvider provider = new AgentClientProvider(null); - String zipFileName = TestUtility.createAppPackage( - folder, - "testpkg", - "test.zip", - "target/test-classes/org/apache/slider/common/tools/test"); - Set<String> tags = provider.getApplicationTags(sliderFileSystem, zipFileName); - assert tags != null; - assert !tags.isEmpty(); - assert tags.contains("Name: STORM"); - assert tags.contains("Description: Apache Hadoop Stream processing framework"); - assert tags.contains("Version: 0.9.1.2.1"); - - } - - @Test - public void testValidateInstanceDefinition() throws Exception { - AgentClientProvider provider = new AgentClientProvider(null); - AggregateConf instanceDefinition = new AggregateConf(); - - try { - provider.validateInstanceDefinition(instanceDefinition, null); - Assert.assertFalse("Should fail with BadConfigException", true); - } catch (BadConfigException e) { - log.info(e.toString()); - Assert.assertTrue(e.getMessage().contains("Application definition must be provided")); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentLaunchParameter.java ---------------------------------------------------------------------- diff --git a/slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentLaunchParameter.java b/slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentLaunchParameter.java deleted file mode 100644 index ec62b54..0000000 --- a/slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentLaunchParameter.java +++ /dev/null @@ -1,76 +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.slider.providers.agent; - -import org.junit.Assert; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * - */ -public class TestAgentLaunchParameter { - protected static final Logger log = - LoggerFactory.getLogger(TestAgentLaunchParameter.class); - - @Test - public void testTestAgentLaunchParameter() throws Exception { - AgentLaunchParameter alp = new AgentLaunchParameter(""); - Assert.assertEquals("", alp.getNextLaunchParameter("abc")); - Assert.assertEquals("", alp.getNextLaunchParameter("HBASE_MASTER")); - - alp = new AgentLaunchParameter("a:1:2:3|b:5:6:NONE"); - Assert.assertEquals("1", alp.getNextLaunchParameter("a")); - Assert.assertEquals("2", alp.getNextLaunchParameter("a")); - Assert.assertEquals("3", alp.getNextLaunchParameter("a")); - Assert.assertEquals("3", alp.getNextLaunchParameter("a")); - - Assert.assertEquals("5", alp.getNextLaunchParameter("b")); - Assert.assertEquals("6", alp.getNextLaunchParameter("b")); - Assert.assertEquals("", alp.getNextLaunchParameter("b")); - Assert.assertEquals("", alp.getNextLaunchParameter("b")); - Assert.assertEquals("", alp.getNextLaunchParameter("c")); - - alp = new AgentLaunchParameter("|a:1:3|b::5:NONE:"); - Assert.assertEquals("1", alp.getNextLaunchParameter("a")); - Assert.assertEquals("3", alp.getNextLaunchParameter("a")); - Assert.assertEquals("3", alp.getNextLaunchParameter("a")); - - Assert.assertEquals("", alp.getNextLaunchParameter("b")); - Assert.assertEquals("5", alp.getNextLaunchParameter("b")); - Assert.assertEquals("", alp.getNextLaunchParameter("b")); - Assert.assertEquals("", alp.getNextLaunchParameter("b")); - - alp = new AgentLaunchParameter("|:"); - Assert.assertEquals("", alp.getNextLaunchParameter("b")); - Assert.assertEquals("", alp.getNextLaunchParameter("a")); - - alp = new AgentLaunchParameter("HBASE_MASTER:a,b:DO_NOT_REGISTER:"); - Assert.assertEquals("a,b", alp.getNextLaunchParameter("HBASE_MASTER")); - Assert.assertEquals("DO_NOT_REGISTER", alp.getNextLaunchParameter("HBASE_MASTER")); - Assert.assertEquals("DO_NOT_REGISTER", alp.getNextLaunchParameter("HBASE_MASTER")); - - alp = new AgentLaunchParameter("HBASE_MASTER:a,b:DO_NOT_REGISTER::c:::"); - Assert.assertEquals("a,b", alp.getNextLaunchParameter("HBASE_MASTER")); - Assert.assertEquals("DO_NOT_REGISTER", alp.getNextLaunchParameter("HBASE_MASTER")); - Assert.assertEquals("", alp.getNextLaunchParameter("HBASE_MASTER")); - Assert.assertEquals("c", alp.getNextLaunchParameter("HBASE_MASTER")); - Assert.assertEquals("c", alp.getNextLaunchParameter("HBASE_MASTER")); - } -} http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentUtils.java ---------------------------------------------------------------------- diff --git a/slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentUtils.java b/slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentUtils.java deleted file mode 100644 index 5e1dc7f..0000000 --- a/slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentUtils.java +++ /dev/null @@ -1,94 +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.slider.providers.agent; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.fs.FileSystem; -import org.apache.slider.common.tools.SliderFileSystem; -import org.apache.slider.providers.agent.application.metadata.Metainfo; -import org.apache.slider.tools.TestUtility; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TestAgentUtils { - protected static final Logger log = - LoggerFactory.getLogger(TestAgentUtils.class); - @Rule - public TemporaryFolder folder = new TemporaryFolder(); - private static final String metainfo_str = "<metainfo>\n" - + " <schemaVersion>2.0</schemaVersion>\n" - + " <application>\n" - + " <name>MYTESTAPPLICATION</name>\n" - + " <comment>\n" - + " My Test Application\n" - + " </comment>\n" - + " <version>1.0</version>\n" - + " <type>YARN-APP</type>\n" - + " <components>\n" - + " <component>\n" - + " <name>REST</name>\n" - + " <category>MASTER</category>\n" - + " <commandScript>\n" - + " <script>scripts/rest.py</script>\n" - + " <scriptType>PYTHON</scriptType>\n" - + " <timeout>600</timeout>\n" - + " </commandScript>\n" - + " </component>\n" - + " </components>\n" - + " </application>\n" - + "</metainfo>"; - - @Test - public void testGetApplicationMetainfo() throws Exception { - String zipFileName = TestUtility.createAppPackage( - folder, - "testpkg", - "test.zip", - "target/test-classes/org/apache/slider/common/tools/test"); - Configuration configuration = new Configuration(); - FileSystem fs = FileSystem.getLocal(configuration); - log.info("fs working dir is {}", fs.getWorkingDirectory().toString()); - SliderFileSystem sliderFileSystem = new SliderFileSystem(fs, configuration); - - // Without accompany metainfo file, read metainfo from the zip file - Metainfo metainfo = AgentUtils.getApplicationMetainfo( - sliderFileSystem, zipFileName, false); - Assert.assertNotNull(metainfo.getApplication()); - Assert.assertEquals("STORM", metainfo.getApplication().getName()); - - // With accompany metainfo file, read metainfo from the accompany file - String acompanyFileName = zipFileName + ".metainfo.xml"; - File f = new File(acompanyFileName); - try (BufferedWriter writer = new BufferedWriter(new FileWriter(f))) { - writer.write(metainfo_str); - } - metainfo = AgentUtils.getApplicationMetainfo( - sliderFileSystem, zipFileName, false); - Assert.assertNotNull(metainfo.getApplication()); - Assert.assertEquals("MYTESTAPPLICATION", metainfo.getApplication().getName()); - } -} http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/test/java/org/apache/slider/providers/agent/TestAppDefinitionPersister.java ---------------------------------------------------------------------- diff --git a/slider-core/src/test/java/org/apache/slider/providers/agent/TestAppDefinitionPersister.java b/slider-core/src/test/java/org/apache/slider/providers/agent/TestAppDefinitionPersister.java deleted file mode 100644 index dedf4f6..0000000 --- a/slider-core/src/test/java/org/apache/slider/providers/agent/TestAppDefinitionPersister.java +++ /dev/null @@ -1,264 +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.slider.providers.agent; - -import com.google.common.io.Files; -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.fs.FileSystem; -import org.apache.slider.common.params.ActionCreateArgs; -import org.apache.slider.common.params.AddonArgsDelegate; -import org.apache.slider.common.tools.SliderFileSystem; -import org.apache.slider.core.conf.ConfTree; -import org.apache.slider.core.conf.ConfTreeOperations; -import org.apache.slider.core.exceptions.BadConfigException; -import org.apache.slider.core.persist.AppDefinitionPersister; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.List; - -/** - * - */ -public class TestAppDefinitionPersister { - protected static final Logger log = - LoggerFactory.getLogger(TestAppDefinitionPersister.class); - @Rule - public TemporaryFolder folder = new TemporaryFolder(); - - /** - * @BeforeClass public static void initialize() { BasicConfigurator.resetConfiguration(); - * BasicConfigurator.configure(); }* - */ - - - @Test - public void testAppDefinitionPersister() throws Exception { - Configuration configuration = new Configuration(); - FileSystem fs = FileSystem.getLocal(configuration); - log.info("fs working dir is {}", fs.getWorkingDirectory().toString()); - SliderFileSystem sliderFileSystem = new SliderFileSystem(fs, configuration); - - AppDefinitionPersister adp = new AppDefinitionPersister(sliderFileSystem); - String clustername = "c1"; - ActionCreateArgs buildInfo = new ActionCreateArgs(); - buildInfo.appMetaInfo = null; - buildInfo.appDef = null; - buildInfo.addonDelegate = new AddonArgsDelegate(); - - // nothing to do - adp.processSuppliedDefinitions(clustername, buildInfo, null); - adp.persistPackages(); - List<AppDefinitionPersister.AppDefinition> appDefinitions = adp.getAppDefinitions(); - Assert.assertTrue(appDefinitions.size() == 0); - - ConfTree ct = new ConfTree(); - ConfTreeOperations appConf = new ConfTreeOperations(ct); - final File tempDir = Files.createTempDir(); - final File metainfo = new File(tempDir, "metainfo.json"); - - // unreadable metainfo - buildInfo.appMetaInfo = metainfo; - - try { - adp.processSuppliedDefinitions(clustername, buildInfo, appConf); - } catch (BadConfigException bce) { - log.info(bce.getMessage()); - Assert.assertTrue(bce.getMessage().contains( - "Path specified with " - + "--metainfo either cannot be read or is not a file")); - } - - try (PrintWriter writer = new PrintWriter(metainfo.getAbsolutePath(), "UTF-8")) { - writer.println("{"); - writer.println("}"); - } - buildInfo.appDef = metainfo; - - try { - adp.processSuppliedDefinitions(clustername, buildInfo, appConf); - } catch (BadConfigException bce) { - log.info(bce.getMessage()); - Assert.assertTrue(bce.getMessage().contains( - "Both --metainfo and --appdef cannot be specified")); - } - - // both --metainfojson and --appdef cannot be specified - buildInfo.appMetaInfo = null; - buildInfo.appMetaInfoJson = "{}"; - try { - adp.processSuppliedDefinitions(clustername, buildInfo, appConf); - } catch (BadConfigException bce) { - log.info(bce.getMessage()); - Assert.assertTrue(bce.getMessage().contains( - "Both --metainfojson and --appdef cannot be specified")); - } - - buildInfo.appDef = null; - - buildInfo.appMetaInfoJson = ""; - try { - adp.processSuppliedDefinitions(clustername, buildInfo, appConf); - } catch (BadConfigException bce) { - log.info(bce.getMessage()); - Assert.assertTrue(bce.getMessage().contains( - "Empty string specified with --metainfojson")); - } - buildInfo.appMetaInfo = metainfo; - - // both --metainfo and --metainfojson cannot be specified - buildInfo.appMetaInfoJson = "{}"; - try { - adp.processSuppliedDefinitions(clustername, buildInfo, appConf); - } catch (BadConfigException bce) { - log.info(bce.getMessage()); - Assert.assertTrue(bce.getMessage().contains( - "Both --metainfo and --metainfojson cannot be specified")); - } - buildInfo.appMetaInfoJson = null; - - appConf.getGlobalOptions().set(AgentKeys.APP_DEF, metainfo.getAbsolutePath()); - - try { - adp.processSuppliedDefinitions(clustername, buildInfo, appConf); - } catch (BadConfigException bce) { - log.info(bce.getMessage()); - Assert.assertTrue(bce.getMessage().contains( - "application.def cannot " - + "not be set if --metainfo is specified in the cmd line")); - } - - appConf.getGlobalOptions().remove(AgentKeys.APP_DEF); - - adp.processSuppliedDefinitions(clustername, buildInfo, appConf); - appDefinitions = adp.getAppDefinitions(); - Assert.assertTrue(appDefinitions.size() == 1); - Assert.assertTrue(appConf.getGlobalOptions().get(AgentKeys.APP_DEF).contains("appdef/appPkg.zip")); - log.info(appDefinitions.get(0).toString()); - Assert.assertTrue(appDefinitions.get(0).appDefPkgOrFolder.toString().endsWith("default")); - Assert.assertTrue(appDefinitions.get(0).targetFolderInFs.toString().contains("cluster/c1/appdef")); - Assert.assertEquals("appPkg.zip", appDefinitions.get(0).pkgName); - - buildInfo.appDef = tempDir; - buildInfo.appMetaInfo = null; - - appConf.getGlobalOptions().set(AgentKeys.APP_DEF, metainfo.getAbsolutePath()); - - try { - adp.processSuppliedDefinitions(clustername, buildInfo, appConf); - } catch (BadConfigException bce) { - log.info(bce.getMessage()); - Assert.assertTrue(bce.getMessage().contains("application.def must not be set if --appdef is provided")); - } - - adp.getAppDefinitions().clear(); - appConf.getGlobalOptions().remove(AgentKeys.APP_DEF); - adp.processSuppliedDefinitions(clustername, buildInfo, appConf); - appDefinitions = adp.getAppDefinitions(); - Assert.assertTrue(appDefinitions.size() == 1); - Assert.assertTrue(appConf.getGlobalOptions().get(AgentKeys.APP_DEF).contains("appdef/appPkg.zip")); - log.info(appDefinitions.get(0).toString()); - Assert.assertTrue(appDefinitions.get(0).appDefPkgOrFolder.toString().endsWith(tempDir.toString())); - Assert.assertTrue(appDefinitions.get(0).targetFolderInFs.toString().contains("cluster/c1/appdef")); - Assert.assertEquals("appPkg.zip", appDefinitions.get(0).pkgName); - - adp.getAppDefinitions().clear(); - buildInfo.appDef = null; - buildInfo.appMetaInfo = null; - appConf.getGlobalOptions().remove(AgentKeys.APP_DEF); - - ArrayList<String> list = new ArrayList<String>() {{ - add("addon1"); - add(""); - add("addon2"); - add(metainfo.getAbsolutePath()); - }}; - - buildInfo.addonDelegate.addonTuples = list; - try { - adp.processSuppliedDefinitions(clustername, buildInfo, appConf); - } catch (BadConfigException bce) { - log.info(bce.getMessage()); - Assert.assertTrue(bce.getMessage().contains("addon package can only be specified if main app package is specified")); - } - - buildInfo.appMetaInfo = metainfo; - - try { - adp.processSuppliedDefinitions(clustername, buildInfo, appConf); - } catch (BadConfigException bce) { - log.info(bce.getMessage()); - Assert.assertTrue(bce.getMessage().contains("Invalid path for addon package addon1")); - } - - appConf.getGlobalOptions().remove(AgentKeys.APP_DEF); - - list = new ArrayList<String>() {{ - add("addon1"); - add(tempDir.getAbsolutePath()); - add("addon2"); - add(metainfo.getAbsolutePath()); - }}; - - buildInfo.addonDelegate.addonTuples = list; - adp.getAppDefinitions().clear(); - - adp.processSuppliedDefinitions(clustername, buildInfo, appConf); - appDefinitions = adp.getAppDefinitions(); - - Assert.assertTrue(appDefinitions.size() == 3); - Assert.assertTrue(appConf.getGlobalOptions().get(AgentKeys.APP_DEF).contains("appdef/appPkg.zip")); - Assert.assertTrue(appConf.getGlobalOptions().get("application.addon.addon1").contains( - "addons/addon1/addon_addon1.zip")); - Assert.assertTrue(appConf.getGlobalOptions().get("application.addon.addon2").contains( - "addons/addon2/addon_addon2.zip")); - log.info(appConf.getGlobalOptions().get("application.addons")); - Assert.assertTrue(appConf.getGlobalOptions().get("application.addons").contains( - "application.addon.addon2,application.addon.addon1") - || appConf.getGlobalOptions().get("application.addons").contains( - "application.addon.addon1,application.addon.addon2")); - int seen = 0; - for (AppDefinitionPersister.AppDefinition adp_ad : appDefinitions) { - if (adp_ad.pkgName.equals("appPkg.zip")) { - log.info(adp_ad.toString()); - Assert.assertTrue(adp_ad.appDefPkgOrFolder.toString().endsWith("default")); - Assert.assertTrue(adp_ad.targetFolderInFs.toString().contains("cluster/c1/appdef")); - seen++; - } - if (adp_ad.pkgName.equals("addon_addon1.zip")) { - log.info(adp_ad.toString()); - Assert.assertTrue(adp_ad.appDefPkgOrFolder.toString().endsWith(tempDir.toString())); - Assert.assertTrue(adp_ad.targetFolderInFs.toString().contains("addons/addon1")); - seen++; - } - if (adp_ad.pkgName.equals("addon_addon2.zip")) { - log.info(adp_ad.toString()); - Assert.assertTrue(adp_ad.appDefPkgOrFolder.toString().endsWith("metainfo.json")); - Assert.assertTrue(adp_ad.targetFolderInFs.toString().contains("addons/addon2")); - seen++; - } - } - Assert.assertEquals(3, seen); - } -} http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/test/java/org/apache/slider/providers/agent/TestComponentTagProvider.java ---------------------------------------------------------------------- diff --git a/slider-core/src/test/java/org/apache/slider/providers/agent/TestComponentTagProvider.java b/slider-core/src/test/java/org/apache/slider/providers/agent/TestComponentTagProvider.java deleted file mode 100644 index 7b38ee3..0000000 --- a/slider-core/src/test/java/org/apache/slider/providers/agent/TestComponentTagProvider.java +++ /dev/null @@ -1,115 +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.slider.providers.agent; - -import org.junit.Assert; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class TestComponentTagProvider { - protected static final Logger log = - LoggerFactory.getLogger(TestComponentTagProvider.class); - - @Test - public void testTagProvider() throws Exception { - ComponentTagProvider ctp = new ComponentTagProvider(); - Assert.assertEquals("", ctp.getTag(null, null)); - Assert.assertEquals("", ctp.getTag(null, "cid")); - Assert.assertEquals("", ctp.getTag("comp1", null)); - - Assert.assertEquals("1", ctp.getTag("comp1", "cid1")); - Assert.assertEquals("2", ctp.getTag("comp1", "cid2")); - Assert.assertEquals("3", ctp.getTag("comp1", "cid3")); - ctp.releaseTag("comp1", "cid2"); - Assert.assertEquals("2", ctp.getTag("comp1", "cid22")); - - ctp.releaseTag("comp1", "cid4"); - ctp.recordAssignedTag("comp1", "cid5", "5"); - Assert.assertEquals("4", ctp.getTag("comp1", "cid4")); - Assert.assertEquals("4", ctp.getTag("comp1", "cid4")); - Assert.assertEquals("6", ctp.getTag("comp1", "cid6")); - - ctp.recordAssignedTag("comp1", "cid55", "5"); - Assert.assertEquals("5", ctp.getTag("comp1", "cid55")); - - ctp.recordAssignedTag("comp2", "cidb3", "3"); - Assert.assertEquals("1", ctp.getTag("comp2", "cidb1")); - Assert.assertEquals("2", ctp.getTag("comp2", "cidb2")); - Assert.assertEquals("4", ctp.getTag("comp2", "cidb4")); - - ctp.recordAssignedTag("comp2", "cidb5", "six"); - ctp.recordAssignedTag("comp2", "cidb5", "-55"); - ctp.recordAssignedTag("comp2", "cidb5", "tags"); - ctp.recordAssignedTag("comp2", "cidb5", null); - ctp.recordAssignedTag("comp2", "cidb5", ""); - ctp.recordAssignedTag("comp2", "cidb5", "5"); - Assert.assertEquals("6", ctp.getTag("comp2", "cidb6")); - - ctp.recordAssignedTag("comp2", null, "5"); - ctp.recordAssignedTag(null, null, "5"); - ctp.releaseTag("comp1", null); - ctp.releaseTag(null, "cid4"); - ctp.releaseTag(null, null); - } - - @Test - public void testTagProviderWithThread() throws Exception { - ComponentTagProvider ctp = new ComponentTagProvider(); - Thread thread = new Thread(new Taggged(ctp)); - Thread thread2 = new Thread(new Taggged(ctp)); - Thread thread3 = new Thread(new Taggged(ctp)); - thread.start(); - thread2.start(); - thread3.start(); - ctp.getTag("comp1", "cid50"); - thread.join(); - thread2.join(); - thread3.join(); - Assert.assertEquals("101", ctp.getTag("comp1", "cid101")); - } - - public class Taggged implements Runnable { - private final ComponentTagProvider ctp; - - public Taggged(ComponentTagProvider ctp) { - this.ctp = ctp; - } - - public void run() { - for (int i = 0; i < 100; i++) { - String containerId = "cid" + (i + 1); - this.ctp.getTag("comp1", containerId); - } - for (int i = 0; i < 100; i++) { - String containerId = "cid" + (i + 1); - this.ctp.getTag("comp1", containerId); - } - for (int i = 0; i < 100; i += 2) { - String containerId = "cid" + (i + 1); - this.ctp.releaseTag("comp1", containerId); - } - for (int i = 0; i < 100; i += 2) { - String containerId = "cid" + (i + 1); - this.ctp.getTag("comp1", containerId); - } - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/51c2b92c/slider-core/src/test/java/org/apache/slider/providers/agent/TestState.java ---------------------------------------------------------------------- diff --git a/slider-core/src/test/java/org/apache/slider/providers/agent/TestState.java b/slider-core/src/test/java/org/apache/slider/providers/agent/TestState.java deleted file mode 100644 index 6a2e5ab..0000000 --- a/slider-core/src/test/java/org/apache/slider/providers/agent/TestState.java +++ /dev/null @@ -1,33 +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.slider.providers.agent; - -import org.junit.Assert; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TestState { - protected static final Logger log = LoggerFactory.getLogger(TestState.class); - - @Test - public void testState() throws Exception { - State state = State.STARTED; - Assert.assertEquals(Command.STOP, state.getSupportedCommand(false, true)); - } -}