Updated Branches: refs/heads/trunk 45f1a86de -> 8780e308f
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/8780e308 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/8780e308 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/8780e308 Branch: refs/heads/trunk Commit: 8780e308f11af08acde72388d1d32924bc4e52f8 Parents: 45f1a86 Author: Oleg Nechiporenko <cv_git...@yahoo.com> Authored: Tue Nov 12 16:52:55 2013 +0200 Committer: Oleg Nechiporenko <cv_git...@yahoo.com> Committed: Tue Nov 12 16:56:01 2013 +0200 ---------------------------------------------------------------------- ambari-web/app/assets/test/test.html | 2 + ambari-web/app/assets/test/tests.js | 1 + .../yarn_defaults_provider.js | 102 +++---- .../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 | 102 ++++--- .../service_configs_validator_test.js | 81 +++++ 11 files changed, 195 insertions(+), 455 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8780e308/ambari-web/app/assets/test/test.html ---------------------------------------------------------------------- diff --git a/ambari-web/app/assets/test/test.html b/ambari-web/app/assets/test/test.html index 32d584d..193e4d0 100644 --- a/ambari-web/app/assets/test/test.html +++ b/ambari-web/app/assets/test/test.html @@ -33,6 +33,8 @@ <script src="../../node_modules/sinon/lib/sinon.js"></script> <script src="../../node_modules/sinon/lib/sinon/spy.js"></script> <script src="../../node_modules/sinon/lib/sinon/stub.js"></script> +<script src="../../node_modules/sinon/lib/sinon/util/fake_server.js"></script> +<script src="../../node_modules/sinon/lib/sinon/util/fake_xml_http_request.js"></script> <script> $.mocho = true; $.hostName = 'localhost:3333'; http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8780e308/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/8780e308/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 4b49f0f..7b4d365 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 @@ -41,7 +41,7 @@ App.YARNDefaultsProvider = App.DefaultsProvider.create({ * Example: * { * disk: 12, - * ram: 48 * 1024, // MB + * ram: 48, * cpu: 12, * hBaseInstalled: false * } @@ -50,15 +50,11 @@ App.YARNDefaultsProvider = App.DefaultsProvider.create({ /** * Reserved for system memory - * - * Value in MB! */ reservedRam: null, /** * Reserved for HBase memory - * - * Value in MB! */ hBaseRam: null, @@ -72,22 +68,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): return 256; + case (ram >= 4 && ram < 8): return 512; + case (ram >= 8 && ram < 24): return 1024; + case (ram >= 24): + 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,9 +89,9 @@ 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; @@ -118,10 +110,13 @@ 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'); } // On low memory systems, memory left over after // removing reserved-RAM and HBase might be @@ -135,7 +130,7 @@ App.YARNDefaultsProvider = App.DefaultsProvider.create({ // If container memory is greater than 1GB, // we use multiples of 512 as value return container_ram > this.get('GB') ? (Math.floor(container_ram / 512) * 512) : container_ram; - }.property('recommendedMinimumContainerSize', 'containers', 'clusterData.ram', 'clusterData.hBaseInstalled', 'hBaseRam', 'reservedRam'), + }.property('containers', 'clusterData.ram', 'clusterData.hBaseInstalled', 'hBaseRam', 'reservedRam'), mapMemory: function () { return this.get('ramPerContainer'); @@ -153,40 +148,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'); + 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); + this.set('hBaseRam', table[index].hbase); }.observes('clusterData.ram'), /** @@ -225,6 +218,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')); http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8780e308/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/8780e308/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/8780e308/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/8780e308/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/8780e308/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/8780e308/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/8780e308/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..ab4304e 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 @@ -21,17 +21,29 @@ require('utils/configs/defaults_providers/yarn_defaults_provider'); describe('YARNDefaultsProvider', function() { + afterEach(function() { + App.YARNDefaultsProvider.set('clusterData', null); + App.YARNDefaultsProvider.set('reservedRam', null); + App.YARNDefaultsProvider.set('hBaseRam', null); + App.YARNDefaultsProvider.set('containers', null); + App.YARNDefaultsProvider.set('recommendedMinimumContainerSize', null); + App.YARNDefaultsProvider.set('ramPerContainer', null); + App.YARNDefaultsProvider.set('mapMemory', null); + App.YARNDefaultsProvider.set('reduceMemory', null); + App.YARNDefaultsProvider.set('amMemory', null); + }); + describe('#clusterDataIsValid', function() { var tests = [ - {clusterData: {disk: 12,ram: 48 * 1024,cpu: 12,hBaseInstalled: false},e: true}, - {clusterData: {disk: null,ram: 48 * 1024,cpu: 12,hBaseInstalled: false},e: false}, + {clusterData: {disk: 12,ram: 48,cpu: 12,hBaseInstalled: false},e: true}, + {clusterData: {disk: null,ram: 48,cpu: 12,hBaseInstalled: false},e: false}, {clusterData: {disk: 12,ram: null,cpu: 12,hBaseInstalled: false},e: false}, - {clusterData: {disk: 12,ram: 48 * 1024,cpu: null,hBaseInstalled: false},e: false}, - {clusterData: {disk: 12,ram: 48 * 1024,cpu: 12,hBaseInstalled: null},e: false}, - {clusterData: {disk: 12,ram: 48 * 1024,cpu: 12},e: false}, - {clusterData: {disk: 12,ram: 48 * 1024,hBaseInstalled: true},e: false}, + {clusterData: {disk: 12,ram: 48,cpu: null,hBaseInstalled: false},e: false}, + {clusterData: {disk: 12,ram: 48,cpu: 12,hBaseInstalled: null},e: false}, + {clusterData: {disk: 12,ram: 48,cpu: 12},e: false}, + {clusterData: {disk: 12,ram: 48,hBaseInstalled: true},e: false}, {clusterData: {disk: 12,cpu: 12,hBaseInstalled: true},e: false}, - {clusterData: {ram: 48 * 1024,cpu: 12,hBaseInstalled: false},e: false} + {clusterData: {ram: 48,cpu: 12,hBaseInstalled: false},e: false} ]; tests.forEach(function(test) { it((test.e?'valid':'invalid') + ' clusterData', function() { @@ -71,14 +83,17 @@ describe('YARNDefaultsProvider', function() { App.YARNDefaultsProvider.set('clusterData'); tests.forEach(function(test) { it('ram: ' + test.ram + ' GB', function() { + sinon.spy(App.YARNDefaultsProvider, 'reservedMemoryRecommendations'); App.YARNDefaultsProvider.set('clusterData', { disk: 12, - ram: test.ram * 1024, + ram: test.ram, cpu: 12, hBaseInstalled: false }); - expect(App.YARNDefaultsProvider.get('reservedRam')).to.equal(test.e.os * 1024); - expect(App.YARNDefaultsProvider.get('hBaseRam')).to.equal(test.e.hbase * 1024); + expect(App.YARNDefaultsProvider.get('reservedRam')).to.equal(test.e.os); + expect(App.YARNDefaultsProvider.get('hBaseRam')).to.equal(test.e.hbase); + expect(App.YARNDefaultsProvider.reservedMemoryRecommendations.calledOnce).to.be.true; + App.YARNDefaultsProvider.reservedMemoryRecommendations.restore(); }); }); }); @@ -106,7 +121,7 @@ describe('YARNDefaultsProvider', function() { it('ram: ' + test.ram + ' GB', function() { App.YARNDefaultsProvider.set('clusterData', { disk: 12, - ram: test.ram * 1024, + ram: test.ram, cpu: 12, hBaseInstalled: false }); @@ -134,7 +149,7 @@ describe('YARNDefaultsProvider', function() { { clusterData: { disk: 12, - ram: 48 * 1024, + ram: 48, cpu: 12, hBaseInstalled: false }, @@ -142,12 +157,12 @@ describe('YARNDefaultsProvider', function() { }, { clusterData: { - disk: 12, - ram: 48 * 1024, - cpu: 12, + disk: 6, + ram: 48, + cpu: 6, hBaseInstalled: true }, - e: 17 + e: 11 } ]; @@ -169,7 +184,7 @@ describe('YARNDefaultsProvider', function() { { clusterData: { disk: 12, - ram: 48 * 1024, + ram: 48, cpu: 12, hBaseInstalled: false }, @@ -178,7 +193,7 @@ describe('YARNDefaultsProvider', function() { { clusterData: { disk: 12, - ram: 16 * 1024, + ram: 16, cpu: 12, hBaseInstalled: true }, @@ -218,12 +233,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 +246,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 +276,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 } } ]; http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8780e308/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) + } + }); + }); + }); + +});