You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by on...@apache.org on 2013/11/08 15:14:38 UTC
git commit: AMBARI-3722. Dynamic configs code needs testcases.
(onechiporenko)
Updated Branches:
refs/heads/trunk dace05a7c -> 0e350e10b
AMBARI-3722. Dynamic configs code needs testcases. (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/0e350e10
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/0e350e10
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/0e350e10
Branch: refs/heads/trunk
Commit: 0e350e10bd0873cb1bded66be2c3f49210e510c5
Parents: dace05a
Author: Oleg Nechiporenko <cv...@yahoo.com>
Authored: Fri Nov 8 16:10:52 2013 +0200
Committer: Oleg Nechiporenko <cv...@yahoo.com>
Committed: Fri Nov 8 16:14:32 2013 +0200
----------------------------------------------------------------------
ambari-web/app/assets/test/tests.js | 1 +
.../yarn_defaults_provider.js | 103 +++----
.../validators/mapreduce2_configs_validator.js | 5 -
.../validators/service_configs_validator.js | 5 +-
.../validators/yarn_configs_validator.js | 5 -
ambari-web/test/mappers/hosts_mapper_test.js | 306 -------------------
ambari-web/test/mappers/status_mapper_test.js | 28 --
ambari-web/test/models/host_test.js | 13 -
.../yarn_defaults_provider_test.js | 58 ++--
.../service_configs_validator_test.js | 81 +++++
10 files changed, 164 insertions(+), 441 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/0e350e10/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index 7e07585..6ebff8d 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -62,6 +62,7 @@ require('test/mappers/service_mapper_test');
require('test/mappers/status_mapper_test');
require('test/mappers/users_mapper_test');
require('test/utils/configs/defaults_providers/yarn_defaults_provider_test');
+require('test/utils/configs/validators/service_configs_validator_test');
require('test/utils/config_test');
require('test/utils/date_test');
require('test/utils/config_test');
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/0e350e10/ambari-web/app/utils/configs/defaults_providers/yarn_defaults_provider.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/configs/defaults_providers/yarn_defaults_provider.js b/ambari-web/app/utils/configs/defaults_providers/yarn_defaults_provider.js
index 7a37f0b..40553db 100644
--- a/ambari-web/app/utils/configs/defaults_providers/yarn_defaults_provider.js
+++ b/ambari-web/app/utils/configs/defaults_providers/yarn_defaults_provider.js
@@ -62,7 +62,6 @@ App.YARNDefaultsProvider = App.DefaultsProvider.create({
*/
hBaseRam: null,
- GB: 1024,
/**
* Minimum container size (in RAM).
* This value is dependent on the amount of RAM available, as in smaller memory nodes the minimum container size should also be smaller
@@ -72,22 +71,18 @@ App.YARNDefaultsProvider = App.DefaultsProvider.create({
recommendedMinimumContainerSize: function () {
if (!this.clusterDataIsValid()) return null;
var ram = this.get('clusterData.ram');
- switch (true) {
- case (ram <=4 ):
- return 256;
- case (ram <= 8):
- return 512;
- case (ram <= 24):
- return 1024;
- default:
- return 2048;
+ switch(true) {
+ case (ram < 4*1024): return 256;
+ case (ram >= 4*1024 && ram < 8*1024): return 512;
+ case (ram >= 8*1024 && ram < 24*1024): return 1024;
+ case (ram >= 24*1024):
+ default: return 2048;
}
}.property('clusterData.ram'),
/**
* Maximum number of containers allowed per node
- * max (2*cores,min (1.8*DISKS,(Total available RAM) / MIN_CONTAINER_SIZE)))
- * min (2*CORES, 1.8*DISKS, (Total available RAM) / MIN_CONTAINER_SIZE)
+ * min (2*cores,min (1.8*DISKS,(Total available RAM) / MIN_CONTAINER_SIZE)))
*/
containers: function () {
if (!this.clusterDataIsValid()) return null;
@@ -97,14 +92,13 @@ App.YARNDefaultsProvider = App.DefaultsProvider.create({
var containerSize = this.get('recommendedMinimumContainerSize');
cpu *= 2;
disk = Math.ceil(disk * 1.8);
- ram = (ram - this.get('reservedRam'));
+ ram -= this.get('reservedRam');
if (this.get('clusterData.hBaseInstalled')) {
- ram -= this.get('hBaseRam')
+ ram -= this.get('hBaseRam');
}
if (ram < 1) {
ram = 1;
}
- ram *= this.get('GB');
ram /= containerSize;
return Math.round(Math.min(cpu, Math.min(disk, ram)));
}.property('clusterData.cpu', 'clusterData.ram', 'clusterData.hBaseInstalled', 'clusterData.disk', 'reservedRam', 'hBaseRam', 'recommendedMinimumContainerSize'),
@@ -117,18 +111,20 @@ App.YARNDefaultsProvider = App.DefaultsProvider.create({
*/
ramPerContainer: function () {
var containers = this.get('containers');
+ if (!containers) {
+ return null;
+ }
var ram = this.get('clusterData.ram');
ram = (ram - this.get('reservedRam'));
if (this.get('clusterData.hBaseInstalled')) {
- ram -= this.get('hBaseRam')
+ ram -= this.get('hBaseRam');
}
if (ram < 1) {
ram = 1;
}
- ram *= this.get('GB');
var container_ram = Math.abs(ram / containers);
- return container_ram > this.get('GB') ? container_ram / (512 * 512) : container_ram;
- }.property('recommendedMinimumContainerSize', 'containers', 'clusterData.ram', 'clusterData.hBaseInstalled', 'hBaseRam', 'reservedRam'),
+ return container_ram;
+ }.property('containers', 'clusterData.ram', 'clusterData.hBaseInstalled', 'hBaseRam', 'reservedRam'),
mapMemory: function () {
return this.get('ramPerContainer');
@@ -146,40 +142,38 @@ App.YARNDefaultsProvider = App.DefaultsProvider.create({
/**
* Reserved for HBase and system memory is based on total available memory
*/
-
-
-
- reservedStackRecommendations: function () {
- var memory = this.get('clusterData.ram');
- var reservedStack = { 4: 1, 8: 2, 16: 2, 24: 4, 48: 6, 64: 8, 72: 8, 96: 12,
- 128: 24, 256: 32, 512: 64};
-
- if (memory in reservedStack) {
- this.set('reservedRam', reservedStack[memory]);
- }
- if (memory <= 4)
- this.set('reservedRam', 1);
- else if (memory >= 512)
- this.set('reservedRam', 64);
- else
- this.set('reservedRam', 1);
- }.observes('clusterData.ram'),
-
- hbaseMemRecommendations: function () {
- var memory = this.get('clusterData.ram');
- var reservedHBase = {4:1, 8:1, 16:2, 24:4, 48:8, 64:8, 72:8, 96:16,
- 128:24, 256:32, 512:64};
-
- if (memory in reservedHBase) {
- this.set('reservedRam', reservedHBase[memory]);
+ reservedMemoryRecommendations: function() {
+ var table = [
+ {os:1,hbase:1},
+ {os:2,hbase:1},
+ {os:2,hbase:2},
+ {os:4,hbase:4},
+ {os:6,hbase:8},
+ {os:8,hbase:8},
+ {os:8,hbase:8},
+ {os:12,hbase:16},
+ {os:24,hbase:24},
+ {os:32,hbase:32},
+ {os:64,hbase:64}
+ ];
+ var ram = this.get('clusterData.ram') / 1024;
+ var index = 0;
+ switch (true) {
+ case (ram <= 4): index = 0; break;
+ case (ram > 4 && ram <= 8): index = 1; break;
+ case (ram > 8 && ram <= 16): index = 2; break;
+ case (ram > 16 && ram <= 24): index = 3; break;
+ case (ram > 24 && ram <= 48): index = 4; break;
+ case (ram > 48 && ram <= 64): index = 5; break;
+ case (ram > 64 && ram <= 72): index = 6; break;
+ case (ram > 72 && ram <= 96): index = 7; break;
+ case (ram > 96 && ram <= 128): index = 8; break;
+ case (ram > 128 && ram <= 256): index = 9; break;
+ case (ram > 256 && ram <= 512): index = 10; break;
+ default: index = 10; break;
}
- if (memory <= 4)
- this.set('hBaseRam', 1);
- else if (memory >= 512)
- this.set('hBaseRam', 64);
- else
- this.set('hBaseRam', 2);
-
+ this.set('reservedRam', table[index].os * 1024);
+ this.set('hBaseRam', table[index].hbase * 1024);
}.observes('clusterData.ram'),
/**
@@ -218,6 +212,9 @@ App.YARNDefaultsProvider = App.DefaultsProvider.create({
this.getClusterData(localDB);
var configs = {};
jQuery.extend(configs, this.get('configsTemplate'));
+ if (!this.clusterDataIsValid()) {
+ return configs;
+ }
configs['yarn.nodemanager.resource.memory-mb'] = Math.round(this.get('containers') * this.get('ramPerContainer'));
configs['yarn.scheduler.minimum-allocation-mb'] = Math.round(this.get('ramPerContainer'));
configs['yarn.scheduler.maximum-allocation-mb'] = Math.round(this.get('containers') * this.get('ramPerContainer'));
@@ -277,7 +274,7 @@ App.YARNDefaultsProvider = App.DefaultsProvider.create({
}
},this);
clusterData.disk = length;
- clusterData.ram = Math.round(parseFloat(host.memory) / (1024 * 1024));
+ clusterData.ram = Math.round(parseFloat(host.memory) / 1024 );
}
this.set('clusterData', clusterData);
},
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/0e350e10/ambari-web/app/utils/configs/validators/mapreduce2_configs_validator.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/configs/validators/mapreduce2_configs_validator.js b/ambari-web/app/utils/configs/validators/mapreduce2_configs_validator.js
index b1e2583..c5803d7 100644
--- a/ambari-web/app/utils/configs/validators/mapreduce2_configs_validator.js
+++ b/ambari-web/app/utils/configs/validators/mapreduce2_configs_validator.js
@@ -33,11 +33,6 @@ App.MapReduce2ConfigsValidator = App.ServiceConfigsValidator.create({
'yarn.app.mapreduce.am.command-opts': 'yarnAppMapreduceAmCommandOpts'
},
- /**
- * List of the real configProperty objects
- */
- configProperties: [],
-
mapreduceMapJavaOpts: function(config) {
return null;
},
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/0e350e10/ambari-web/app/utils/configs/validators/service_configs_validator.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/configs/validators/service_configs_validator.js b/ambari-web/app/utils/configs/validators/service_configs_validator.js
index c9e2a90..a14108c 100644
--- a/ambari-web/app/utils/configs/validators/service_configs_validator.js
+++ b/ambari-web/app/utils/configs/validators/service_configs_validator.js
@@ -56,8 +56,11 @@ App.ServiceConfigsValidator = Em.Object.extend({
* @param {object} config - configProperty name
*/
validatorLessThenDefaultValue: function(config) {
- var defaultValue = this.recommendedDefaults[config.get('name')];
+ var defaultValue = this.get('recommendedDefaults')[config.get('name')];
var currentValue = parseInt(config.get('value').toString().replace( /\D+/g, ''));
+ if (!defaultValue) {
+ return null;
+ }
defaultValue = parseInt(defaultValue.toString().replace( /\D+/g, ''));
if (defaultValue && currentValue && currentValue < defaultValue) {
return "Value is less than the recommended default of "+defaultValue;
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/0e350e10/ambari-web/app/utils/configs/validators/yarn_configs_validator.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/configs/validators/yarn_configs_validator.js b/ambari-web/app/utils/configs/validators/yarn_configs_validator.js
index dda3f10..a51bd7c 100644
--- a/ambari-web/app/utils/configs/validators/yarn_configs_validator.js
+++ b/ambari-web/app/utils/configs/validators/yarn_configs_validator.js
@@ -28,11 +28,6 @@ App.YARNConfigsValidator = App.ServiceConfigsValidator.create({
'yarn.scheduler.maximum-allocation-mb': 'yarnSchedulerMaximumAllocationMb'
},
- /**
- * List of the real configProperty objects
- */
- configProperties: [],
-
yarnNodemanagerResourceMemoryMb: function(config) {
return this.validatorLessThenDefaultValue(config);
},
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/0e350e10/ambari-web/test/mappers/hosts_mapper_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mappers/hosts_mapper_test.js b/ambari-web/test/mappers/hosts_mapper_test.js
index a11bfdb..032578e 100644
--- a/ambari-web/test/mappers/hosts_mapper_test.js
+++ b/ambari-web/test/mappers/hosts_mapper_test.js
@@ -66,310 +66,4 @@ describe('App.hostsMapper', function () {
});
});
- var hosts = {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts?fields=Hosts/host_name,Hosts/public_host_name,Hosts/disk_info,Hosts/cpu_count,Hosts/total_mem,Hosts/host_status,Hosts/last_heartbeat_time,Hosts/os_arch,Hosts/os_type,Hosts/ip,host_components,metrics/disk,metrics/load/load_one",
- "items" : [
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal",
- "metrics" : {
- "disk" : {
- "disk_total" : 896.17,
- "disk_free" : 846.304936111
- },
- "load" : {
- "load_one" : 0.786194444444
- },
- "memory" : {
- "mem_total" : 7514116.0,
- "swap_free" : 0.0,
- "mem_buffers" : 114389.877778,
- "mem_shared" : 0.0,
- "mem_free" : 4320263.07778,
- "swap_total" : 0.0,
- "mem_cached" : 2229920.77778
- },
- "cpu" : {
- "cpu_speed" : 2266.0,
- "cpu_num" : 2.0,
- "cpu_wio" : 0.393055555556,
- "cpu_idle" : 85.9025,
- "cpu_nice" : 0.0,
- "cpu_aidle" : 0.0,
- "cpu_system" : 2.75111111111,
- "cpu_user" : 10.9405555556
- }
- },
- "Hosts" : {
- "host_status" : "HEALTHY",
- "cluster_name" : "tdk",
- "public_host_name" : "ec2-107-21-192-172.compute-1.amazonaws.com",
- "cpu_count" : 2,
- "total_mem" : 7518289,
- "os_arch" : "x86_64",
- "host_name" : "ip-10-83-54-214.ec2.internal",
- "disk_info" : [
- {
- "available" : "5431780",
- "used" : "2403168",
- "percent" : "31%",
- "size" : "8254240",
- "type" : "ext4",
- "mountpoint" : "/"
- },
- {
- "available" : "3757056",
- "used" : "0",
- "percent" : "0%",
- "size" : "3757056",
- "type" : "tmpfs",
- "mountpoint" : "/dev/shm"
- },
- {
- "available" : "411234588",
- "used" : "203012",
- "percent" : "1%",
- "size" : "433455904",
- "type" : "ext3",
- "mountpoint" : "/grid/0"
- },
- {
- "available" : "411234588",
- "used" : "203012",
- "percent" : "1%",
- "size" : "433455904",
- "type" : "ext3",
- "mountpoint" : "/grid/1"
- }
- ],
- "ip" : "10.83.54.214",
- "os_type" : "centos6",
- "last_heartbeat_time" : 1369829865123
- },
- "host_components" : [
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/HDFS_CLIENT",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "component_name" : "HDFS_CLIENT",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- },
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/HBASE_REGIONSERVER",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "component_name" : "HBASE_REGIONSERVER",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- },
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/HIVE_METASTORE",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "component_name" : "HIVE_METASTORE",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- },
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/DATANODE",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "component_name" : "DATANODE",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- },
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/HIVE_SERVER",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "component_name" : "HIVE_SERVER",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- },
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/HBASE_MASTER",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "ha_status" : "passive",
- "component_name" : "HBASE_MASTER",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- },
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/MYSQL_SERVER",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "component_name" : "MYSQL_SERVER",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- },
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/ZOOKEEPER_SERVER",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "component_name" : "ZOOKEEPER_SERVER",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- },
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/OOZIE_SERVER",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "component_name" : "OOZIE_SERVER",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- },
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/MAPREDUCE_CLIENT",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "component_name" : "MAPREDUCE_CLIENT",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- },
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/NAMENODE",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "component_name" : "NAMENODE",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- },
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/GANGLIA_SERVER",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "component_name" : "GANGLIA_SERVER",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- },
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/TASKTRACKER",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "component_name" : "TASKTRACKER",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- },
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/SQOOP",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "component_name" : "SQOOP",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- },
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/GANGLIA_MONITOR",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "component_name" : "GANGLIA_MONITOR",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- },
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/HIVE_CLIENT",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "component_name" : "HIVE_CLIENT",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- },
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/JOBTRACKER",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "component_name" : "JOBTRACKER",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- },
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/ZOOKEEPER_CLIENT",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "component_name" : "ZOOKEEPER_CLIENT",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- },
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/SECONDARY_NAMENODE",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "component_name" : "SECONDARY_NAMENODE",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- },
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/HBASE_CLIENT",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "component_name" : "HBASE_CLIENT",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- },
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/OOZIE_CLIENT",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "component_name" : "OOZIE_CLIENT",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- },
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/WEBHCAT_SERVER",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "component_name" : "WEBHCAT_SERVER",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- },
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/HCAT",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "component_name" : "HCAT",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- },
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/PIG",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "component_name" : "PIG",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- },
- {
- "href" : "http://ec2-107-21-192-172.compute-1.amazonaws.com:8080/api/v1/clusters/tdk/hosts/ip-10-83-54-214.ec2.internal/host_components/NAGIOS_SERVER",
- "HostRoles" : {
- "cluster_name" : "tdk",
- "component_name" : "NAGIOS_SERVER",
- "host_name" : "ip-10-83-54-214.ec2.internal"
- }
- }
- ]
- }
- ]
- };
-
- describe('#parse', function() {
- var result = App.hostsMapper.parse(hosts.items);
- it('Hosts are loaded', function() {
- expect(result.length).to.equal(1);
- });
- var host = result[0];
- it('Disk Usage calculated', function() {
- expect(host.disk_usage).to.equal('5.6');
- });
- it('CPU Usage calculated', function() {
- expect(host.cpu_usage).to.equal('13.7');
- });
- it('Memory Usage calculated', function() {
- expect(host.memory_usage).to.equal('42.5');
- });
- it('Host Complonents loaded', function() {
- expect(host.host_components.length).to.equal(hosts.items[0].host_components.length);
- });
- });
-
});
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/0e350e10/ambari-web/test/mappers/status_mapper_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mappers/status_mapper_test.js b/ambari-web/test/mappers/status_mapper_test.js
index f07757c..65fa6e6 100644
--- a/ambari-web/test/mappers/status_mapper_test.js
+++ b/ambari-web/test/mappers/status_mapper_test.js
@@ -24,33 +24,5 @@ require('mappers/status_mapper');
describe('App.statusMapper', function () {
- describe('#parse_host_components', function() {
- var test_data = {
- items: [
- {
- components: [
- {
- host_components: [
- {
- HostRoles : {
- component_name: "OOZIE_CLIENT",
- host_name: "ip-10-40-35-199.ec2.internal",
- state: "STATE"
- }
- }
- ]
- }
- ]
- }
- ]
- };
- var result = App.statusMapper.parse_host_components(test_data);
- var k = 'OOZIE_CLIENT_ip-10-40-35-199.ec2.internal';
- var e = 'STATE';
- console.log(result);
- it('get host_component id', function() {
- expect(result[k].work_status).to.equal(e);
- });
- });
});
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/0e350e10/ambari-web/test/models/host_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/host_test.js b/ambari-web/test/models/host_test.js
index c8df524..3e32279 100644
--- a/ambari-web/test/models/host_test.js
+++ b/ambari-web/test/models/host_test.js
@@ -118,17 +118,4 @@ describe('App.Host', function () {
});
});
- describe('#updateHealthClass', function () {
-
- it('host1 has status health-status-DEAD-YELLOW', function () {
- var host = App.Host.find().findProperty('hostName', 'host1');
- host.updateHealthClass();
- expect(host.get('healthClass')).to.equal('health-status-DEAD-YELLOW');
- });
- it('host3 has status health-status-DEAD-YELLOW', function () {
- var host = App.Host.find().findProperty('hostName', 'host3');
- host.updateHealthClass();
- expect(host.get('healthClass')).to.equal('health-status-DEAD-YELLOW');
- });
- });
});
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/0e350e10/ambari-web/test/utils/configs/defaults_providers/yarn_defaults_provider_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/configs/defaults_providers/yarn_defaults_provider_test.js b/ambari-web/test/utils/configs/defaults_providers/yarn_defaults_provider_test.js
index c8e36f0..9981f1d 100644
--- a/ambari-web/test/utils/configs/defaults_providers/yarn_defaults_provider_test.js
+++ b/ambari-web/test/utils/configs/defaults_providers/yarn_defaults_provider_test.js
@@ -142,12 +142,12 @@ describe('YARNDefaultsProvider', function() {
},
{
clusterData: {
- disk: 12,
+ disk: 6,
ram: 48 * 1024,
- cpu: 12,
+ cpu: 6,
hBaseInstalled: true
},
- e: 17
+ e: 11
}
];
@@ -218,12 +218,10 @@ describe('YARNDefaultsProvider', function() {
{
localDB: {
"hosts": {
- "host1": {"name": "host1","cpu": 8,"memory": "25165824.00","disk_info": [{},{},{},{},{},{},{},{}]},
- "host2": {"name": "host2","cpu": 4,"memory": "25165824.00","disk_info": [{},{},{},{}]}
+ "host1": {"name": "host1","cpu": 8,"memory": "25165824.00","disk_info": [{mountpoint:'/'},{mountpoint:'/'},{mountpoint:'/'},{mountpoint:'/'},{mountpoint:'/'},{mountpoint:'/'},{mountpoint:'/'},{mountpoint:'/'}]},
+ "host2": {"name": "host2","cpu": 4,"memory": "25165824.00","disk_info": [{mountpoint:'/'},{mountpoint:'/'},{mountpoint:'/'},{mountpoint:'/'}]}
},
- "masterComponentHosts": [
- {"component": "RESOURCEMANAGER","hostName": "host1","serviceId": "HDFS"}
- ],
+ "masterComponentHosts": [],
"slaveComponentHosts": [
{
"componentName": "NODEMANAGER",
@@ -233,25 +231,25 @@ describe('YARNDefaultsProvider', function() {
},
m: 'Without HBase',
e: {
- 'mapreduce.map.java.opts': 1638,
- 'mapreduce.map.memory.mb': 2048,
- 'mapreduce.reduce.java.opts': 3277,
- 'mapreduce.reduce.memory.mb': 4096,
- 'yarn.app.mapreduce.am.command-opts': 3277,
- 'yarn.app.mapreduce.am.resource.mb': 4096,
- 'yarn.nodemanager.resource.memory-mb': 43008,
- 'yarn.scheduler.maximum-allocation-mb': 43008,
- 'yarn.scheduler.minimum-allocation-mb': 2048
+ 'mapreduce.map.java.opts': '-Xmx2048m',
+ 'mapreduce.map.memory.mb': 2560,
+ 'mapreduce.reduce.java.opts': '-Xmx2048m',
+ 'mapreduce.reduce.memory.mb': 2560,
+ 'yarn.app.mapreduce.am.command-opts': '-Xmx2048m',
+ 'yarn.app.mapreduce.am.resource.mb': 2560,
+ 'yarn.nodemanager.resource.memory-mb': 20480,
+ 'yarn.scheduler.maximum-allocation-mb': 20480,
+ 'yarn.scheduler.minimum-allocation-mb': 2560,
+ 'mapreduce.task.io.sort.mb': 1024
}
},
{
localDB: {
"hosts": {
- "host1": {"name": "host1","cpu": 8,"memory": "25165824.00","disk_info": [{},{},{},{},{},{},{},{}]},
- "host2": {"name": "host2","cpu": 4,"memory": "12582912.00","disk_info": [{},{},{},{}]}
+ "host1": {"name": "host1","cpu": 8,"memory": "25165824.00","disk_info": [{mountpoint:'/'},{mountpoint:'/'},{mountpoint:'/'},{mountpoint:'/'},{mountpoint:'/'},{mountpoint:'/'},{mountpoint:'/'},{mountpoint:'/'}]},
+ "host2": {"name": "host2","cpu": 4,"memory": "12582912.00","disk_info": [{mountpoint:'/'},{mountpoint:'/'},{mountpoint:'/'},{mountpoint:'/'}]}
},
"masterComponentHosts": [
- {"component": "RESOURCEMANAGER","hostName": "host1","serviceId": "HDFS"},
{"component": "HBASE_MASTER","hostName": "host1","serviceId": "HDFS"}
],
"slaveComponentHosts": [
@@ -263,15 +261,16 @@ describe('YARNDefaultsProvider', function() {
},
m: 'With HBase',
e: {
- 'mapreduce.map.java.opts': 1638,
- 'mapreduce.map.memory.mb': 2048,
- 'mapreduce.reduce.java.opts': 3277,
- 'mapreduce.reduce.memory.mb': 4096,
- 'yarn.app.mapreduce.am.command-opts': 3277,
- 'yarn.app.mapreduce.am.resource.mb': 4096,
- 'yarn.nodemanager.resource.memory-mb': 22528,
- 'yarn.scheduler.maximum-allocation-mb': 22528,
- 'yarn.scheduler.minimum-allocation-mb': 2048
+ 'mapreduce.map.java.opts': '-Xmx819m',
+ 'mapreduce.map.memory.mb': 1024,
+ 'mapreduce.reduce.java.opts': '-Xmx1638m',
+ 'mapreduce.reduce.memory.mb': 2048,
+ 'yarn.app.mapreduce.am.command-opts': '-Xmx1638m',
+ 'yarn.app.mapreduce.am.resource.mb': 2048,
+ 'yarn.nodemanager.resource.memory-mb': 8192,
+ 'yarn.scheduler.maximum-allocation-mb': 8192,
+ 'yarn.scheduler.minimum-allocation-mb': 1024,
+ 'mapreduce.task.io.sort.mb': 410
}
}
];
@@ -279,7 +278,6 @@ describe('YARNDefaultsProvider', function() {
it(test.m, function() {
App.YARNDefaultsProvider.set('clusterData', null);
var configs = App.YARNDefaultsProvider.getDefaults(test.localDB);
-
for(var config in configs) {
if (test.e) {
expect(configs[config]).to.equal(test.e[config]);
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/0e350e10/ambari-web/test/utils/configs/validators/service_configs_validator_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/configs/validators/service_configs_validator_test.js b/ambari-web/test/utils/configs/validators/service_configs_validator_test.js
new file mode 100644
index 0000000..744053f
--- /dev/null
+++ b/ambari-web/test/utils/configs/validators/service_configs_validator_test.js
@@ -0,0 +1,81 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+require('utils/configs/validators/service_configs_validator');
+
+describe('App.ServiceConfigsValidator', function() {
+
+ describe('#validateConfig', function() {
+ it('No config validator', function() {
+ var v = App.ServiceConfigsValidator.create({});
+ expect(v.validateConfig(Em.Object.create({name:'name'}))).to.equal(null);
+ });
+ });
+
+ describe('#validatorLessThenDefaultValue', function() {
+ var tests = [
+ {
+ recommendedDefaults: {
+ 'property1': 100500
+ },
+ config: Em.Object.create({
+ value: 100000,
+ name: 'property1'
+ }),
+ m: 'Numeric value',
+ e: 'string'
+ },
+ {
+ recommendedDefaults: {
+ 'property1': 'xx100500x'
+ },
+ config: Em.Object.create({
+ value: 'xx100000x',
+ name: 'property1'
+ }),
+ m: 'String value',
+ e: 'string'
+ },
+ {
+ recommendedDefaults: {
+ 'property1': null
+ },
+ config: Em.Object.create({
+ value: 100000,
+ name: 'property1'
+ }),
+ m: 'No default value for property',
+ e: null
+ }
+ ];
+ tests.forEach(function(test) {
+ it(test.m, function() {
+ var v = App.ServiceConfigsValidator.create({});
+ v.set('recommendedDefaults', test.recommendedDefaults);
+ var r = v.validatorLessThenDefaultValue(test.config);
+ if (test.e) {
+ expect(r).to.be.a(test.e);
+ }
+ else {
+ expect(r).to.equal(null)
+ }
+ });
+ });
+ });
+
+});