Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 405E8200CCF for ; Mon, 24 Jul 2017 19:28:07 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 8FF7D163816; Mon, 24 Jul 2017 17:28:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 1334516380D for ; Mon, 24 Jul 2017 19:28:04 +0200 (CEST) Received: (qmail 49164 invoked by uid 500); 24 Jul 2017 17:28:03 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 49145 invoked by uid 99); 24 Jul 2017 17:28:03 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Jul 2017 17:28:03 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B8A3FDFC25; Mon, 24 Jul 2017 17:28:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jonathanhurley@apache.org To: commits@ambari.apache.org Date: Mon, 24 Jul 2017 17:28:03 -0000 Message-Id: <7a28f583e388430886283c7a4ece8154@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/3] ambari git commit: AMBARI-21450 - Fixing Unit Test Logic From trunk Merge (jonathanhurley) archived-at: Mon, 24 Jul 2017 17:28:07 -0000 Repository: ambari Updated Branches: refs/heads/branch-feature-AMBARI-21450 51e3080ef -> 15cd3d837 http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd3d83/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java index 70f0332..2b4a008 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java @@ -1,4 +1,4 @@ -/** +/* * 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 @@ -145,14 +145,14 @@ public class ClusterResourceProviderTest { Set> requestProperties = createBlueprintRequestProperties(CLUSTER_NAME, BLUEPRINT_NAME); Map properties = requestProperties.iterator().next(); properties.put(BaseClusterRequest.PROVISION_ACTION_PROPERTY, "INSTALL_ONLY"); - Map requestInfoProperties = new HashMap(); + Map requestInfoProperties = new HashMap<>(); requestInfoProperties.put(Request.REQUEST_INFO_BODY_PROPERTY, "{}"); // set expectations expect(request.getProperties()).andReturn(requestProperties).anyTimes(); expect(request.getRequestInfoProperties()).andReturn(requestInfoProperties).anyTimes(); - expect(securityFactory.createSecurityConfigurationFromRequest(anyObject(HashMap.class), anyBoolean())).andReturn(null) + expect(securityFactory.createSecurityConfigurationFromRequest(EasyMock.>anyObject(), anyBoolean())).andReturn(null) .once(); expect(topologyFactory.createProvisionClusterRequest(properties, null)).andReturn(topologyRequest).once(); expect(topologyManager.provisionCluster(topologyRequest)).andReturn(requestStatusResponse).once(); @@ -174,7 +174,7 @@ public class ClusterResourceProviderTest { public void testCreateResource_blueprint_withInvalidSecurityConfiguration() throws Exception { Set> requestProperties = createBlueprintRequestProperties(CLUSTER_NAME, BLUEPRINT_NAME); Map properties = requestProperties.iterator().next(); - Map requestInfoProperties = new HashMap(); + Map requestInfoProperties = new HashMap<>(); requestInfoProperties.put(Request.REQUEST_INFO_BODY_PROPERTY, "{\"security\" : {\n\"type\" : \"NONE\"," + "\n\"kerberos_descriptor_reference\" : " + "\"testRef\"\n}}"); SecurityConfiguration blueprintSecurityConfiguration = new SecurityConfiguration(SecurityType.KERBEROS, "testRef", @@ -185,7 +185,7 @@ public class ClusterResourceProviderTest { expect(request.getProperties()).andReturn(requestProperties).anyTimes(); expect(request.getRequestInfoProperties()).andReturn(requestInfoProperties).anyTimes(); - expect(securityFactory.createSecurityConfigurationFromRequest(anyObject(HashMap.class), anyBoolean())).andReturn + expect(securityFactory.createSecurityConfigurationFromRequest(EasyMock.>anyObject(), anyBoolean())).andReturn (securityConfiguration).once(); expect(topologyFactory.createProvisionClusterRequest(properties, securityConfiguration)).andReturn(topologyRequest).once(); expect(topologyRequest.getBlueprint()).andReturn(blueprint).anyTimes(); @@ -203,7 +203,7 @@ public class ClusterResourceProviderTest { Map properties = requestProperties.iterator().next(); SecurityConfiguration securityConfiguration = new SecurityConfiguration(SecurityType.KERBEROS, "testRef", null); - Map requestInfoProperties = new HashMap(); + Map requestInfoProperties = new HashMap<>(); requestInfoProperties.put(Request.REQUEST_INFO_BODY_PROPERTY, "{\"security\" : {\n\"type\" : \"KERBEROS\",\n\"kerberos_descriptor_reference\" : " + "\"testRef\"\n}}"); @@ -212,7 +212,7 @@ public class ClusterResourceProviderTest { expect(request.getRequestInfoProperties()).andReturn(requestInfoProperties).anyTimes(); expect(topologyFactory.createProvisionClusterRequest(properties, securityConfiguration)).andReturn(topologyRequest).once(); - expect(securityFactory.createSecurityConfigurationFromRequest(anyObject(HashMap.class), anyBoolean())).andReturn + expect(securityFactory.createSecurityConfigurationFromRequest(EasyMock.>anyObject(), anyBoolean())).andReturn (securityConfiguration).once(); expect(topologyManager.provisionCluster(topologyRequest)).andReturn(requestStatusResponse).once(); expect(requestStatusResponse.getRequestId()).andReturn(5150L).anyTimes(); @@ -284,10 +284,10 @@ public class ClusterResourceProviderTest { ((ObservableResourceProvider)provider).addObserver(observer); // add the property map to a set for the request. add more maps for multiple creates - Set> propertySet = new LinkedHashSet>(); + Set> propertySet = new LinkedHashSet<>(); // Cluster 1: create a map of properties for the request - Map properties = new LinkedHashMap(); + Map properties = new LinkedHashMap<>(); // add the cluster name to the properties map properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, "Cluster100"); @@ -332,21 +332,21 @@ public class ClusterResourceProviderTest { AmbariManagementController managementController = createMock(AmbariManagementController.class); Clusters clusters = createMock(Clusters.class); - Set allResponse = new HashSet(); - allResponse.add(new ClusterResponse(100L, "Cluster100", State.INSTALLED, SecurityType.NONE, null, null, null, null)); - allResponse.add(new ClusterResponse(101L, "Cluster101", State.INSTALLED, SecurityType.NONE, null, null, null, null)); - allResponse.add(new ClusterResponse(102L, "Cluster102", State.INSTALLED, SecurityType.NONE, null, null, null, null)); - allResponse.add(new ClusterResponse(103L, "Cluster103", State.INSTALLED, SecurityType.NONE, null, null, null, null)); - allResponse.add(new ClusterResponse(104L, "Cluster104", State.INSTALLED, SecurityType.NONE, null, null, null, null)); + Set allResponse = new HashSet<>(); + allResponse.add(new ClusterResponse(100L, "Cluster100", State.INSTALLED, SecurityType.NONE, null, 0, null, null)); + allResponse.add(new ClusterResponse(101L, "Cluster101", State.INSTALLED, SecurityType.NONE, null, 0, null, null)); + allResponse.add(new ClusterResponse(102L, "Cluster102", State.INSTALLED, SecurityType.NONE, null, 0, null, null)); + allResponse.add(new ClusterResponse(103L, "Cluster103", State.INSTALLED, SecurityType.NONE, null, 0, null, null)); + allResponse.add(new ClusterResponse(104L, "Cluster104", State.INSTALLED, SecurityType.NONE, null, 0, null, null)); - Set nameResponse = new HashSet(); - nameResponse.add(new ClusterResponse(102L, "Cluster102", State.INSTALLED, SecurityType.NONE, null, null, null, null)); + Set nameResponse = new HashSet<>(); + nameResponse.add(new ClusterResponse(102L, "Cluster102", State.INSTALLED, SecurityType.NONE, null, 0, null, null)); - Set idResponse = new HashSet(); - idResponse.add(new ClusterResponse(103L, "Cluster103", State.INSTALLED, SecurityType.NONE, null, null, null, null)); + Set idResponse = new HashSet<>(); + idResponse.add(new ClusterResponse(103L, "Cluster103", State.INSTALLED, SecurityType.NONE, null, 0, null, null)); // set expectations - Capture> captureClusterRequests = new Capture>(); + Capture> captureClusterRequests = EasyMock.newCapture(); expect(managementController.getClusters(capture(captureClusterRequests))).andReturn(allResponse).once(); expect(managementController.getClusters(capture(captureClusterRequests))).andReturn(nameResponse).once(); @@ -365,7 +365,7 @@ public class ClusterResourceProviderTest { PropertyHelper.getKeyPropertyIds(type), managementController); - Set propertyIds = new HashSet(); + Set propertyIds = new HashSet<>(); propertyIds.add(ClusterResourceProvider.CLUSTER_ID_PROPERTY_ID); propertyIds.add(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID); @@ -452,40 +452,40 @@ public class ClusterResourceProviderTest { //todo: configuration properties are not being added to props private Set> createBlueprintRequestProperties(String clusterName, String blueprintName) { - Set> propertySet = new LinkedHashSet>(); - Map properties = new LinkedHashMap(); + Set> propertySet = new LinkedHashSet<>(); + Map properties = new LinkedHashMap<>(); properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, clusterName); properties.put(ClusterResourceProvider.BLUEPRINT_PROPERTY_ID, blueprintName); propertySet.add(properties); - Collection> hostGroups = new ArrayList>(); - Map hostGroupProperties = new HashMap(); + Collection> hostGroups = new ArrayList<>(); + Map hostGroupProperties = new HashMap<>(); hostGroups.add(hostGroupProperties); hostGroupProperties.put("name", "group1"); - Collection> hostGroupHosts = new ArrayList>(); + Collection> hostGroupHosts = new ArrayList<>(); hostGroupProperties.put("hosts", hostGroupHosts); - Map hostGroupHostProperties = new HashMap(); + Map hostGroupHostProperties = new HashMap<>(); hostGroupHostProperties.put("fqdn", "host.domain"); hostGroupHosts.add(hostGroupHostProperties); properties.put("host_groups", hostGroups); - Map mapGroupConfigProperties = new HashMap(); + Map mapGroupConfigProperties = new HashMap<>(); mapGroupConfigProperties.put("myGroupProp", "awesomeValue"); // blueprint core-site cluster configuration properties - Map blueprintCoreConfigProperties = new HashMap(); + Map blueprintCoreConfigProperties = new HashMap<>(); blueprintCoreConfigProperties.put("property1", "value2"); blueprintCoreConfigProperties.put("new.property", "new.property.value"); - Map blueprintGlobalConfigProperties = new HashMap(); + Map blueprintGlobalConfigProperties = new HashMap<>(); blueprintGlobalConfigProperties.put("hive_database", "New MySQL Database"); - Map oozieEnvConfigProperties = new HashMap(); + Map oozieEnvConfigProperties = new HashMap<>(); oozieEnvConfigProperties.put("property1","value2"); - Map hbaseEnvConfigProperties = new HashMap(); + Map hbaseEnvConfigProperties = new HashMap<>(); hbaseEnvConfigProperties.put("property1","value2"); - Map falconEnvConfigProperties = new HashMap(); + Map falconEnvConfigProperties = new HashMap<>(); falconEnvConfigProperties.put("property1","value2"); return propertySet; @@ -494,14 +494,14 @@ public class ClusterResourceProviderTest { private void testCreateResource_blueprint(Authentication authentication) throws Exception { Set> requestProperties = createBlueprintRequestProperties(CLUSTER_NAME, BLUEPRINT_NAME); Map properties = requestProperties.iterator().next(); - Map requestInfoProperties = new HashMap(); + Map requestInfoProperties = new HashMap<>(); requestInfoProperties.put(Request.REQUEST_INFO_BODY_PROPERTY, "{}"); // set expectations expect(request.getProperties()).andReturn(requestProperties).anyTimes(); expect(request.getRequestInfoProperties()).andReturn(requestInfoProperties).anyTimes(); - expect(securityFactory.createSecurityConfigurationFromRequest(anyObject(HashMap.class), anyBoolean())).andReturn(null) + expect(securityFactory.createSecurityConfigurationFromRequest(EasyMock.>anyObject(), anyBoolean())).andReturn(null) .once(); expect(topologyFactory.createProvisionClusterRequest(properties, null)).andReturn(topologyRequest).once(); expect(topologyManager.provisionCluster(topologyRequest)).andReturn(requestStatusResponse).once(); @@ -545,10 +545,10 @@ public class ClusterResourceProviderTest { ((ObservableResourceProvider)provider).addObserver(observer); // add the property map to a set for the request. add more maps for multiple creates - Set> propertySet = new LinkedHashSet>(); + Set> propertySet = new LinkedHashSet<>(); // Cluster 1: create a map of properties for the request - Map properties = new LinkedHashMap(); + Map properties = new LinkedHashMap<>(); // add the cluster name to the properties map properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, "Cluster100"); @@ -559,7 +559,7 @@ public class ClusterResourceProviderTest { propertySet.add(properties); // Cluster 2: create a map of properties for the request - properties = new LinkedHashMap(); + properties = new LinkedHashMap<>(); // add the cluster id to the properties map properties.put(ClusterResourceProvider.CLUSTER_ID_PROPERTY_ID, 99L); @@ -593,10 +593,10 @@ public class ClusterResourceProviderTest { AmbariManagementController managementController = createMock(AmbariManagementController.class); RequestStatusResponse response = createNiceMock(RequestStatusResponse.class); - Set nameResponse = new HashSet(); - nameResponse.add(new ClusterResponse(102L, "Cluster102", State.INIT, SecurityType.NONE, null, null, null, null)); + Set nameResponse = new HashSet<>(); + nameResponse.add(new ClusterResponse(102L, "Cluster102", State.INIT, SecurityType.NONE, null, 0, null, null)); - Map mapRequestProps = new HashMap(); + Map mapRequestProps = new HashMap<>(); mapRequestProps.put("context", "Called from a test"); // set expectations @@ -628,7 +628,7 @@ public class ClusterResourceProviderTest { ((ObservableResourceProvider)provider).addObserver(observer); - Map properties = new LinkedHashMap(); + Map properties = new LinkedHashMap<>(); properties.put(ClusterResourceProvider.CLUSTER_VERSION_PROPERTY_ID, "HDP-0.1"); @@ -661,10 +661,10 @@ public class ClusterResourceProviderTest { Clusters clusters = createMock(Clusters.class); RequestStatusResponse response = createNiceMock(RequestStatusResponse.class); - Set nameResponse = new HashSet(); - nameResponse.add(new ClusterResponse(100L, "Cluster100", State.INSTALLED, SecurityType.NONE, null, null, null, null)); + Set nameResponse = new HashSet<>(); + nameResponse.add(new ClusterResponse(100L, "Cluster100", State.INSTALLED, SecurityType.NONE, null, 0, null, null)); - Map mapRequestProps = new HashMap(); + Map mapRequestProps = new HashMap<>(); mapRequestProps.put("context", "Called from a test"); // set expectations @@ -680,7 +680,7 @@ public class ClusterResourceProviderTest { SecurityContextHolder.getContext().setAuthentication(authentication); - Map properties = new LinkedHashMap(); + Map properties = new LinkedHashMap<>(); properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, "Cluster100"); properties.put(PropertyHelper.getPropertyId("Clusters.desired_config", "type"), "global"); @@ -689,7 +689,7 @@ public class ClusterResourceProviderTest { properties.put(PropertyHelper.getPropertyId("Clusters.desired_config.properties", "x"), "y"); - Map properties2 = new LinkedHashMap(); + Map properties2 = new LinkedHashMap<>(); properties2.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, "Cluster100"); properties2.put(PropertyHelper.getPropertyId("Clusters.desired_config", "type"), "mapred-site"); @@ -697,7 +697,7 @@ public class ClusterResourceProviderTest { properties2.put(PropertyHelper.getPropertyId("Clusters.desired_config.properties", "foo"), "A1"); properties2.put(PropertyHelper.getPropertyId("Clusters.desired_config.properties", "bar"), "B2"); - Set> propertySet = new HashSet>(); + Set> propertySet = new HashSet<>(); propertySet.add(properties); propertySet.add(properties2); @@ -806,10 +806,10 @@ public class ClusterResourceProviderTest { managementController); // add the property map to a set for the request. add more maps for multiple creates - Set> propertySet = new LinkedHashSet>(); + Set> propertySet = new LinkedHashSet<>(); // Cluster 1: create a map of properties for the request - Map properties = new LinkedHashMap(); + Map properties = new LinkedHashMap<>(); properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, "Cluster100"); properties.put(ClusterResourceProvider.CLUSTER_VERSION_PROPERTY_ID, "HDP-0.1"); properties.put(ClusterResourceProvider.CLUSTER_REPO_VERSION, "2.1.1"); @@ -826,7 +826,6 @@ public class ClusterResourceProviderTest { assertTrue(cap.hasCaptured()); assertNotNull(cap.getValue()); - assertEquals("2.1.1", cap.getValue().getRepositoryVersion()); } @Test @@ -844,7 +843,7 @@ public class ClusterResourceProviderTest { expect(request.getProperties()).andReturn(requestProperties).anyTimes(); expect(request.getRequestInfoProperties()).andReturn(requestInfoProperties).anyTimes(); - expect(securityFactory.createSecurityConfigurationFromRequest(anyObject(HashMap.class), anyBoolean())).andReturn(null) + expect(securityFactory.createSecurityConfigurationFromRequest(EasyMock.>anyObject(), anyBoolean())).andReturn(null) .once(); expect(topologyFactory.createProvisionClusterRequest(properties, null)).andReturn(topologyRequest).once(); expect(topologyManager.provisionCluster(topologyRequest)).andReturn(requestStatusResponse).once(); @@ -861,4 +860,4 @@ public class ClusterResourceProviderTest { verifyAll(); } -} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd3d83/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java index f133784..fdd1dc5 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java @@ -124,8 +124,7 @@ public class JMXHostProviderTest { dStateStr = desiredState.toString(); } - ServiceRequest r1 = new ServiceRequest(clusterName, serviceName, STACK_ID.getStackId(), - REPO_VERSION, dStateStr); + ServiceRequest r1 = new ServiceRequest(clusterName, serviceName, m_repositoryVersion.getId(), dStateStr); Set requests = new HashSet<>(); requests.add(r1); http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd3d83/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java index 7fe888d..a0c58ea 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java @@ -153,7 +153,7 @@ public class ServiceResourceProviderTest { properties.put(ServiceResourceProvider.SERVICE_SERVICE_NAME_PROPERTY_ID, "Service100"); properties.put(ServiceResourceProvider.SERVICE_SERVICE_STATE_PROPERTY_ID, "INIT"); properties.put(ServiceResourceProvider.SERVICE_DESIRED_STACK_PROPERTY_ID, "HDP-1.1"); - properties.put(ServiceResourceProvider.SERVICE_DESIRED_REPO_VERSION_PROPERTY_ID, "1"); + properties.put(ServiceResourceProvider.SERVICE_DESIRED_REPO_VERSION_ID_PROPERTY_ID, "1"); propertySet.add(properties); http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd3d83/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java index d07ac15..2e216e6 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java @@ -91,7 +91,7 @@ public class ComponentVersionCheckActionTest { private static final StackId HDP_21_STACK = new StackId("HDP-2.1.1"); private static final StackId HDP_22_STACK = new StackId("HDP-2.2.0"); - private static final String HDP_211_CENTOS6_REPO_URL = "http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.0"; + private static final String HDP_211_CENTOS6_REPO_URL = "http://s3.amazonaws.com/dev.hortonworks.com/HDP/centos6/2.x/BUILDS/2.1.1.0-118"; private Injector m_injector; @@ -544,4 +544,4 @@ public class ComponentVersionCheckActionTest { configFactory.createNew(cluster, "core-site", "version1", properties, propertiesAttributes); configFactory.createNew(cluster, "foo-site", "version1", properties, propertiesAttributes); } -} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/15cd3d83/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ConfigureActionTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ConfigureActionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ConfigureActionTest.java index 731e100..e80b59b 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ConfigureActionTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ConfigureActionTest.java @@ -137,12 +137,9 @@ public class ConfigureActionTest { m_injector.getInstance(GuiceJpaInitializer.class); m_injector.injectMembers(this); - repoVersion2110 = m_helper.getOrCreateRepositoryVersion(new StackId("HDP-2.1.1"), - "2.1.1.0-1234"); - repoVersion2111 = m_helper.getOrCreateRepositoryVersion(new StackId("HDP-2.1.1"), - "2.1.1.1-5678"); - repoVersion2200 = m_helper.getOrCreateRepositoryVersion(new StackId("HDP-2.2.0"), - "2.2.0.0-1234"); + repoVersion2110 = m_helper.getOrCreateRepositoryVersion(new StackId("HDP-2.1.1"), "2.1.1.0-1234"); + repoVersion2111 = m_helper.getOrCreateRepositoryVersion(new StackId("HDP-2.1.1"), "2.1.1.1-5678"); + repoVersion2200 = m_helper.getOrCreateRepositoryVersion(new StackId("HDP-2.2.0"), "2.2.0.0-1234"); makeUpgradeCluster(); } @@ -170,7 +167,7 @@ public class ConfigureActionTest { } }; - Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties); + Config config = createConfig(c, "zoo.cfg", "version2", properties); c.addDesiredConfig("user", Collections.singleton(config)); assertEquals(2, c.getConfigsByType("zoo.cfg").size()); @@ -220,13 +217,16 @@ public class ConfigureActionTest { Cluster c = clusters.getCluster("c1"); assertEquals(1, c.getConfigsByType("zoo.cfg").size()); + c.setCurrentStackVersion(repoVersion2110.getStackId()); + c.setDesiredStackVersion(repoVersion2200.getStackId()); + Map properties = new HashMap() { { put("initLimit", "10"); } }; - Config config = createConfig(c, repoVersion2200, "zoo.cfg", "version2", properties); + Config config = createConfig(c, "zoo.cfg", "version2", properties); c.addDesiredConfig("user", Collections.singleton(config)); assertEquals(2, c.getConfigsByType("zoo.cfg").size()); @@ -282,7 +282,7 @@ public class ConfigureActionTest { } }; - Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties); + Config config = createConfig(c, "zoo.cfg", "version2", properties); c.addDesiredConfig("user", Collections.singleton(config)); assertEquals(2, c.getConfigsByType("zoo.cfg").size()); @@ -340,7 +340,7 @@ public class ConfigureActionTest { } }; - Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties); + Config config = createConfig(c, "zoo.cfg", "version2", properties); c.addDesiredConfig("user", Collections.singleton(config)); assertEquals(2, c.getConfigsByType("zoo.cfg").size()); @@ -470,7 +470,7 @@ public class ConfigureActionTest { } }; - Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties); + Config config = createConfig(c, "zoo.cfg", "version2", properties); c.addDesiredConfig("user", Collections.singleton(config)); assertEquals(2, c.getConfigsByType("zoo.cfg").size()); @@ -528,7 +528,7 @@ public class ConfigureActionTest { } }; - Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties); + Config config = createConfig(c, "zoo.cfg", "version2", properties); c.addDesiredConfig("user", Collections.singleton(config)); assertEquals(2, c.getConfigsByType("zoo.cfg").size()); @@ -594,7 +594,7 @@ public class ConfigureActionTest { } }; - Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties); + Config config = createConfig(c, "zoo.cfg", "version2", properties); c.addDesiredConfig("user", Collections.singleton(config)); assertEquals(2, c.getConfigsByType("zoo.cfg").size()); @@ -643,13 +643,16 @@ public class ConfigureActionTest { Cluster c = clusters.getCluster("c1"); assertEquals(1, c.getConfigsByType("zoo.cfg").size()); + c.setCurrentStackVersion(repoVersion2110.getStackId()); + c.setDesiredStackVersion(repoVersion2200.getStackId()); + Map properties = new HashMap() { { put("fooKey", "barValue"); } }; - Config config = createConfig(c, repoVersion2200, "zoo.cfg", "version2", properties); + Config config = createConfig(c, "zoo.cfg", "version2", properties); c.addDesiredConfig("user", Collections.singleton(config)); assertEquals(2, c.getConfigsByType("zoo.cfg").size()); @@ -701,6 +704,9 @@ public class ConfigureActionTest { Cluster c = clusters.getCluster("c1"); assertEquals(1, c.getConfigsByType("zoo.cfg").size()); + c.setCurrentStackVersion(repoVersion2110.getStackId()); + c.setDesiredStackVersion(repoVersion2200.getStackId()); + Map properties = new HashMap() { { put("set.key.1", "s1"); @@ -710,7 +716,7 @@ public class ConfigureActionTest { } }; - Config config = createConfig(c, repoVersion2200, "zoo.cfg", "version2", properties); + Config config = createConfig(c, "zoo.cfg", "version2", properties); c.addDesiredConfig("user", Collections.singleton(config)); assertEquals(2, c.getConfigsByType("zoo.cfg").size()); @@ -798,7 +804,7 @@ public class ConfigureActionTest { } }; - Config config = createConfig(c, repoVersion2200, "zoo.cfg", "version2", properties); + Config config = createConfig(c, "zoo.cfg", "version2", properties); c.addDesiredConfig("user", Collections.singleton(config)); assertEquals(2, c.getConfigsByType("zoo.cfg").size()); @@ -863,10 +869,12 @@ public class ConfigureActionTest { @Test public void testAllowedReplacment() throws Exception { - Cluster c = clusters.getCluster("c1"); assertEquals(1, c.getConfigsByType("zoo.cfg").size()); + c.setCurrentStackVersion(repoVersion2110.getStackId()); + c.setDesiredStackVersion(repoVersion2200.getStackId()); + Map properties = new HashMap() { { put("replace.key.1", "r1"); @@ -877,7 +885,7 @@ public class ConfigureActionTest { } }; - Config config = createConfig(c, repoVersion2200, "zoo.cfg", "version2", properties); + Config config = createConfig(c, "zoo.cfg", "version2", properties); c.addDesiredConfig("user", Collections.singleton(config)); assertEquals(2, c.getConfigsByType("zoo.cfg").size()); @@ -964,7 +972,7 @@ public class ConfigureActionTest { } }; - Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties); + Config config = createConfig(c, "zoo.cfg", "version2", properties); c.addDesiredConfig("user", Collections.singleton(config)); assertEquals(2, c.getConfigsByType("zoo.cfg").size()); @@ -1044,7 +1052,7 @@ public class ConfigureActionTest { } }; - Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties); + Config config = createConfig(c, "zoo.cfg", "version2", properties); c.addDesiredConfig("user", Collections.singleton(config)); assertEquals(2, c.getConfigsByType("zoo.cfg").size()); @@ -1153,7 +1161,7 @@ public class ConfigureActionTest { } }; - Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties); + Config config = createConfig(c, "zoo.cfg", "version2", properties); c.addDesiredConfig("user", Collections.singleton(config)); assertEquals(2, c.getConfigsByType("zoo.cfg").size()); @@ -1249,7 +1257,7 @@ public class ConfigureActionTest { } }; - Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties); + Config config = createConfig(c, "zoo.cfg", "version2", properties); c.addDesiredConfig("user", Collections.singleton(config)); assertEquals(2, c.getConfigsByType("zoo.cfg").size()); @@ -1351,7 +1359,7 @@ public class ConfigureActionTest { } }; - Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties); + Config config = createConfig(c, "zoo.cfg", "version2", properties); c.addDesiredConfig("user", Collections.singleton(config)); assertEquals(2, c.getConfigsByType("zoo.cfg").size()); @@ -1448,7 +1456,7 @@ public class ConfigureActionTest { } }; - Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties); + Config config = createConfig(c, "zoo.cfg", "version2", properties); c.addDesiredConfig("user", Collections.singleton(config)); assertEquals(2, c.getConfigsByType("zoo.cfg").size()); @@ -1542,7 +1550,7 @@ public class ConfigureActionTest { } }; - Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties); + Config config = createConfig(c, "zoo.cfg", "version2", properties); c.addDesiredConfig("user", Collections.singleton(config)); assertEquals(2, c.getConfigsByType("zoo.cfg").size()); @@ -1633,7 +1641,7 @@ public class ConfigureActionTest { } }; - Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version2", properties); + Config config = createConfig(c, "zoo.cfg", "version2", properties); c.addDesiredConfig("user", Collections.singleton(config)); assertEquals(2, c.getConfigsByType("zoo.cfg").size()); @@ -1735,7 +1743,7 @@ public class ConfigureActionTest { } }; - Config config = createConfig(c, repoVersion2110, "zoo.cfg", "version1", properties); + Config config = createConfig(c, "zoo.cfg", "version1", properties); c.addDesiredConfig("user", Collections.singleton(config)); @@ -1847,8 +1855,8 @@ public class ConfigureActionTest { return executionCommand; } - private Config createConfig(Cluster cluster, RepositoryVersionEntity repoVersion, String type, - String tag, Map properties) { + private Config createConfig(Cluster cluster, String type, String tag, + Map properties) { return configFactory.createNew(cluster, type, tag, properties, NO_ATTRIBUTES); }