AMBARI-20370 : tez view version and build removed and short url of auto instance used for property tez.tez-ui.history-url.base in tez-site (nitirajrathore)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9c7b290d Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9c7b290d Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9c7b290d Branch: refs/heads/branch-feature-AMBARI-12556 Commit: 9c7b290dd89aa6ea95ce47496f56f21a9fb40231 Parents: 785d7da Author: Nitiraj Singh Rathore <[email protected]> Authored: Tue Mar 14 07:26:20 2017 +0530 Committer: Nitiraj Singh Rathore <[email protected]> Committed: Tue Mar 14 07:26:20 2017 +0530 ---------------------------------------------------------------------- .../server/upgrade/AbstractUpgradeCatalog.java | 96 -------------------- .../server/upgrade/UpgradeCatalog250.java | 69 +++++++++++++- .../stacks/HDP/2.2/services/stack_advisor.py | 13 +-- .../stacks/HDP/2.3/services/stack_advisor.py | 13 +-- .../upgrade/AbstractUpgradeCatalogTest.java | 64 ------------- .../server/upgrade/UpgradeCatalog250Test.java | 20 ++++ .../stacks/2.2/common/test_stack_advisor.py | 8 +- .../stacks/2.3/common/test_stack_advisor.py | 2 +- 8 files changed, 103 insertions(+), 182 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/9c7b290d/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java index 20280fb..712e309 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java @@ -19,8 +19,6 @@ package org.apache.ambari.server.upgrade; import java.io.File; import java.io.FileReader; -import java.io.FilenameFilter; -import java.io.IOException; import java.io.StringReader; import java.lang.reflect.Type; import java.sql.ResultSet; @@ -39,11 +37,8 @@ import java.util.Set; import java.util.Stack; import java.util.StringTokenizer; import java.util.TreeMap; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import javax.persistence.EntityManager; -import javax.xml.bind.JAXBException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -84,8 +79,6 @@ import org.apache.ambari.server.state.kerberos.KerberosServiceDescriptor; import org.apache.ambari.server.state.stack.WidgetLayout; import org.apache.ambari.server.state.stack.WidgetLayoutInfo; import org.apache.ambari.server.utils.VersionUtils; -import org.apache.ambari.server.view.ViewArchiveUtility; -import org.apache.ambari.server.view.configuration.ViewConfig; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -111,8 +104,6 @@ public abstract class AbstractUpgradeCatalog implements UpgradeCatalog { protected Configuration configuration; @Inject protected StackUpgradeUtil stackUpgradeUtil; - @Inject - protected ViewArchiveUtility archiveUtility; protected Injector injector; @@ -951,95 +942,8 @@ public abstract class AbstractUpgradeCatalog implements UpgradeCatalog { @Override public void upgradeData() throws AmbariException, SQLException { executeDMLUpdates(); - updateTezHistoryUrlBase(); - } - - /** - * Version of the Tez view changes with every new version on Ambari. Hence the 'tez.tez-ui.history-url.base' in tez-site.xml - * has to be changed every time ambari update happens. This will read the latest tez-view jar file and find out the - * view version by reading the view.xml file inside it and update the 'tez.tez-ui.history-url.base' property in tez-site.xml - * with the proper value of the updated tez view version. - */ - private void updateTezHistoryUrlBase() throws AmbariException { - AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); - Clusters clusters = ambariManagementController.getClusters(); - - if (clusters != null) { - Map<String, Cluster> clusterMap = clusters.getClusters(); - if (clusterMap != null && !clusterMap.isEmpty()) { - for (final Cluster cluster : clusterMap.values()) { - Set<String> installedServices = cluster.getServices().keySet(); - if (installedServices.contains("TEZ")) { - Config tezSite = cluster.getDesiredConfigByType("tez-site"); - if (tezSite != null) { - String currentTezHistoryUrlBase = tezSite.getProperties().get("tez.tez-ui.history-url.base"); - if (!StringUtils.isEmpty(currentTezHistoryUrlBase)) { - LOG.info("Current Tez History URL base: {} ", currentTezHistoryUrlBase); - String newTezHistoryUrlBase = getUpdatedTezHistoryUrlBase(currentTezHistoryUrlBase); - LOG.info("New Tez History URL base: {} ", newTezHistoryUrlBase); - updateConfigurationProperties("tez-site", Collections.singletonMap("tez.tez-ui.history-url.base", newTezHistoryUrlBase), true, false); - } - } - } - } - } - } - } - - /** - * Transforms the existing tez history url base to the new url considering the latest tez view version. - * @param currentTezHistoryUrlBase Existing value of the tez history url base - * @return the updated tez history url base - * @throws AmbariException if currentTezHistoryUrlBase is malformed or is not compatible with the Tez View url REGEX - */ - protected String getUpdatedTezHistoryUrlBase(String currentTezHistoryUrlBase) throws AmbariException{ - String pattern = "(.*\\/TEZ\\/)(.*)(\\/.*)"; - Pattern regex = Pattern.compile(pattern); - Matcher matcher = regex.matcher(currentTezHistoryUrlBase); - String prefix; - String suffix; - String oldVersion; - if (matcher.find()) { - prefix = matcher.group(1); - oldVersion = matcher.group(2); - suffix = matcher.group(3); - } else { - throw new AmbariException("Cannot prepare the new value for property: 'tez.tez-ui.history-url.base' using the old value: '" + currentTezHistoryUrlBase + "'"); - } - - String latestTezViewVersion = getLatestTezViewVersion(oldVersion); - - return prefix + latestTezViewVersion + suffix; } - /** - * Given the old configured version, this method tries to get the new version of tez view by reading the tez-view jar. - * Assumption - only a single tez-view jar will be present in the views directory. - * @param oldVersion It is returned if there is a failure in finding the new version - * @return newVersion of the tez view. Returns oldVersion if there error encountered if finding the new version number. - */ - protected String getLatestTezViewVersion(String oldVersion) { - File viewsDirectory = configuration.getViewsDir(); - File[] files = viewsDirectory.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.startsWith("tez-view"); - } - }); - - if(files == null || files.length == 0) { - LOG.error("Could not file tez-view jar file in '{}'. Returning the old version", viewsDirectory.getAbsolutePath()); - return oldVersion; - } - File tezViewFile = files[0]; - try { - ViewConfig viewConfigFromArchive = archiveUtility.getViewConfigFromArchive(tezViewFile); - return viewConfigFromArchive.getVersion(); - } catch (JAXBException | IOException e) { - LOG.error("Failed to read the tez view version from: {}. Returning the old version", tezViewFile); - return oldVersion; - } - } @Override public final void updateDatabaseSchemaVersion() { http://git-wip-us.apache.org/repos/asf/ambari/blob/9c7b290d/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog250.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog250.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog250.java index e5b091b..7c6ca0f 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog250.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog250.java @@ -31,6 +31,8 @@ import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.concurrent.atomic.AtomicLong; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.apache.ambari.server.AmbariException; import org.apache.ambari.server.actionmanager.CommandExecutionType; @@ -59,6 +61,7 @@ import org.apache.ambari.server.state.kerberos.KerberosIdentityDescriptor; import org.apache.ambari.server.state.kerberos.KerberosKeytabDescriptor; import org.apache.ambari.server.state.kerberos.KerberosPrincipalDescriptor; import org.apache.ambari.server.state.kerberos.KerberosServiceDescriptor; +import org.apache.ambari.server.view.ViewArchiveUtility; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -107,6 +110,9 @@ public class UpgradeCatalog250 extends AbstractUpgradeCatalog { protected static final String HOST_COMPONENT_DESIREDSTATE_ID_COL = "id"; protected static final String HOST_COMPONENT_DESIREDSTATE_INDEX = "UQ_hcdesiredstate_name"; + @Inject + protected ViewArchiveUtility archiveUtility; + /** * Logger. */ @@ -197,6 +203,7 @@ public class UpgradeCatalog250 extends AbstractUpgradeCatalog { addManageAlertNotificationsPermissions(); updateKerberosDescriptorArtifacts(); fixHBaseMasterCPUUtilizationAlertDefinition(); + updateTezHistoryUrlBase(); } /** @@ -370,6 +377,66 @@ public class UpgradeCatalog250 extends AbstractUpgradeCatalog { } } + /** + * This will check if previous value of 'tez.tez-ui.history-url.base' contains tez view's url. + * If yes then it will point it to fixed url of tez view auto view as introduced in ambari-2.5.0.0. + * else it will log an error and move ahead. + */ + protected void updateTezHistoryUrlBase() throws AmbariException { + AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); + Clusters clusters = ambariManagementController.getClusters(); + + if (clusters != null) { + Map<String, Cluster> clusterMap = clusters.getClusters(); + if (clusterMap != null && !clusterMap.isEmpty()) { + for (final Cluster cluster : clusterMap.values()) { + Set<String> installedServices = cluster.getServices().keySet(); + if (installedServices.contains("TEZ")) { + Config tezSite = cluster.getDesiredConfigByType("tez-site"); + if (tezSite != null) { + String currentTezHistoryUrlBase = tezSite.getProperties().get("tez.tez-ui.history-url.base"); + if (!StringUtils.isEmpty(currentTezHistoryUrlBase)) { + LOG.info("Current Tez History URL base: {} ", currentTezHistoryUrlBase); + String newTezHistoryUrlBase = null; + try { + newTezHistoryUrlBase = getUpdatedTezHistoryUrlBase(currentTezHistoryUrlBase); + } catch (AmbariException e) { + LOG.error("Error occurred while creating updated URL of tez view using value in property tez.tez-ui.history-url.base." + + "The current value {} is not of standard format expected by Ambari. Skipping the updation of tez.tez-ui.history-url.base." + + "Please check validity of this property manually in tez site after upgrade.", currentTezHistoryUrlBase, e); + return; + } + LOG.info("New Tez History URL base: {} ", newTezHistoryUrlBase); + updateConfigurationProperties("tez-site", Collections.singletonMap("tez.tez-ui.history-url.base", newTezHistoryUrlBase), true, false); + } + } + } + } + } + } + } + + /** + * Transforms the existing tez history url base to the fixed short url for tez auto instance + * @param currentTezHistoryUrlBase Existing value of the tez history url base + * @return the updated tez history url base + * @throws AmbariException if currentTezHistoryUrlBase is malformed or is not compatible with the Tez View url REGEX + */ + protected String getUpdatedTezHistoryUrlBase(String currentTezHistoryUrlBase) throws AmbariException{ + String pattern = "(.*)(\\/views\\/TEZ\\/)(.*)"; + Pattern regex = Pattern.compile(pattern); + Matcher matcher = regex.matcher(currentTezHistoryUrlBase); + String prefix; + if (matcher.find()) { + prefix = matcher.group(1); + } else { + throw new AmbariException("Cannot prepare the new value for property: 'tez.tez-ui.history-url.base' using the old value: '" + currentTezHistoryUrlBase + "'"); + } + + // adding the auto tez instance short url name instead of the tez version and tez view instance name + return prefix + "/view/TEZ/tez_cluster_instance"; + } + protected void updateHostVersionTable() throws SQLException { LOG.info("Updating the {} table", HOST_VERSION_TABLE); @@ -1120,7 +1187,7 @@ public class UpgradeCatalog250 extends AbstractUpgradeCatalog { content = content.replace("<priority value=\"warn\"/>", "<priority value=\"info\"/>"); } - + content = SchemaUpgradeUtil.extractProperty(content, "logsearch_log_maxfilesize", "logsearch_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch.log\" />\n" + " <param name=\"Threshold\" value=\"info\" />\n" + http://git-wip-us.apache.org/repos/asf/ambari/blob/9c7b290d/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py index ede41fc..c2dda68 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py +++ b/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py @@ -887,6 +887,7 @@ class HDP22StackAdvisor(HDP21StackAdvisor): server_protocol = 'http' views_dir = '/var/lib/ambari-server/resources/views/' + has_tez_view = False if serverProperties: if 'client.api.port' in serverProperties: server_port = serverProperties['client.api.port'] @@ -899,20 +900,16 @@ class HDP22StackAdvisor(HDP21StackAdvisor): views_work_dir = os.path.join(views_dir, 'work') if os.path.exists(views_work_dir) and os.path.isdir(views_work_dir): - last_version = '0.0.0' for file in os.listdir(views_work_dir): if fnmatch.fnmatch(file, 'TEZ{*}'): - current_version = file.lstrip("TEZ{").rstrip("}") # E.g.: TEZ{0.7.0.2.3.0.0-2154} - if self.versionCompare(current_version.replace("-", "."), last_version.replace("-", ".")) >= 0: - latest_tez_jar_version = current_version - last_version = current_version - pass + has_tez_view = True # now used just to verify if the tez view exists + pass pass pass pass - if latest_tez_jar_version: - tez_url = '{0}://{1}:{2}/#/main/views/TEZ/{3}/TEZ_CLUSTER_INSTANCE'.format(server_protocol, server_host, server_port, latest_tez_jar_version) + if has_tez_view: + tez_url = '{0}://{1}:{2}/#/main/view/TEZ/tez_cluster_instance'.format(server_protocol, server_host, server_port) putTezProperty("tez.tez-ui.history-url.base", tez_url) pass http://git-wip-us.apache.org/repos/asf/ambari/blob/9c7b290d/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py index c36f96a..781ff13 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py +++ b/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py @@ -97,6 +97,7 @@ class HDP23StackAdvisor(HDP22StackAdvisor): server_protocol = 'http' views_dir = '/var/lib/ambari-server/resources/views/' + has_tez_view = False if serverProperties: if 'client.api.port' in serverProperties: server_port = serverProperties['client.api.port'] @@ -109,20 +110,16 @@ class HDP23StackAdvisor(HDP22StackAdvisor): views_work_dir = os.path.join(views_dir, 'work') if os.path.exists(views_work_dir) and os.path.isdir(views_work_dir): - last_version = '0.0.0' for file in os.listdir(views_work_dir): if fnmatch.fnmatch(file, 'TEZ{*}'): - current_version = file.lstrip("TEZ{").rstrip("}") # E.g.: TEZ{0.7.0.2.3.0.0-2154} - if self.versionCompare(current_version.replace("-", "."), last_version.replace("-", ".")) >= 0: - latest_tez_jar_version = current_version - last_version = current_version - pass + has_tez_view = True # now used just to verify if the tez view exists + pass pass pass pass - if latest_tez_jar_version: - tez_url = '{0}://{1}:{2}/#/main/views/TEZ/{3}/TEZ_CLUSTER_INSTANCE'.format(server_protocol, server_host, server_port, latest_tez_jar_version) + if has_tez_view: + tez_url = '{0}://{1}:{2}/#/main/view/TEZ/tez_cluster_instance'.format(server_protocol, server_host, server_port) putTezProperty("tez.tez-ui.history-url.base", tez_url) pass http://git-wip-us.apache.org/repos/asf/ambari/blob/9c7b290d/ambari-server/src/test/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalogTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalogTest.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalogTest.java index 5fa7cac..96ccc57 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalogTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalogTest.java @@ -17,20 +17,14 @@ */ package org.apache.ambari.server.upgrade; -import static junit.framework.Assert.assertEquals; -import static org.easymock.EasyMock.anyObject; import static org.easymock.EasyMock.anyString; import static org.easymock.EasyMock.createNiceMock; import static org.easymock.EasyMock.createStrictMock; import static org.easymock.EasyMock.eq; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.reset; import static org.easymock.EasyMock.verify; -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; import java.sql.SQLException; import java.util.Collections; import java.util.HashMap; @@ -38,7 +32,6 @@ import java.util.HashSet; import java.util.Map; import org.apache.ambari.server.AmbariException; -import org.apache.ambari.server.configuration.Configuration; import org.apache.ambari.server.controller.AmbariManagementController; import org.apache.ambari.server.state.Cluster; import org.apache.ambari.server.state.Clusters; @@ -48,8 +41,6 @@ import org.apache.ambari.server.state.PropertyInfo; import org.apache.ambari.server.state.PropertyUpgradeBehavior; import org.apache.ambari.server.state.Service; import org.apache.ambari.server.state.ServiceInfo; -import org.apache.ambari.server.view.ViewArchiveUtility; -import org.apache.ambari.server.view.configuration.ViewConfig; import org.junit.Before; import org.junit.Test; @@ -188,61 +179,6 @@ public class AbstractUpgradeCatalogTest { verify(configHelper, amc, cluster, clusters, serviceInfo, oldConfig); } - @Test - public void shouldReturnLatestTezViewVersion() throws Exception { - Configuration configuration = createNiceMock(Configuration.class); - ViewArchiveUtility archiveUtility = createNiceMock(ViewArchiveUtility.class); - File viewDirectory = createNiceMock(File.class); - File viewJarFile = createNiceMock(File.class); - ViewConfig viewConfig = createNiceMock(ViewConfig.class); - expect(configuration.getViewsDir()).andReturn(viewDirectory).anyTimes(); - expect(viewDirectory.listFiles(anyObject(FilenameFilter.class))).andReturn(new File[] {viewJarFile}).anyTimes(); - expect(archiveUtility.getViewConfigFromArchive(viewJarFile)).andReturn(viewConfig).anyTimes(); - expect(viewConfig.getVersion()).andReturn("2.2").anyTimes(); - - replay(configuration, archiveUtility, viewDirectory, viewJarFile, viewConfig); - - upgradeCatalog.archiveUtility = archiveUtility; - upgradeCatalog.configuration = configuration; - - assertEquals("2.2", upgradeCatalog.getLatestTezViewVersion("2.1")); - assertEquals("http://ambari:8080/#/main/views/TEZ/2.2/TEZ_CLUSTER_INSTANCE", - upgradeCatalog.getUpdatedTezHistoryUrlBase("http://ambari:8080/#/main/views/TEZ/0.7.0.2.5.0.0-665/TEZ_CLUSTER_INSTANCE")); - - assertEquals("http://ambari:8080/#/main/views/TEZ/2.2/tezView", - upgradeCatalog.getUpdatedTezHistoryUrlBase("http://ambari:8080/#/main/views/TEZ/0.7.0.2.5.0.0-665/tezView")); - - reset(viewDirectory, archiveUtility); - - expect(viewDirectory.listFiles(anyObject(FilenameFilter.class))).andReturn(new File[] {viewJarFile}).anyTimes(); - expect(archiveUtility.getViewConfigFromArchive(viewJarFile)).andThrow(new IOException()).anyTimes(); - replay(viewDirectory, archiveUtility); - assertEquals("2.1", upgradeCatalog.getLatestTezViewVersion("2.1")); - assertEquals("http://ambari:8080/#/main/views/TEZ/0.7.0.2.5.0.0-665/TEZ_CLUSTER_INSTANCE", - upgradeCatalog.getUpdatedTezHistoryUrlBase("http://ambari:8080/#/main/views/TEZ/0.7.0.2.5.0.0-665/TEZ_CLUSTER_INSTANCE")); - - reset(viewDirectory); - - expect(viewDirectory.listFiles(anyObject(FilenameFilter.class))).andReturn(null).anyTimes(); - replay(viewDirectory); - assertEquals("2.1", upgradeCatalog.getLatestTezViewVersion("2.1")); - assertEquals("http://ambari:8080/#/main/views/TEZ/0.7.0.2.5.0.0-665/TEZ_CLUSTER_INSTANCE", - upgradeCatalog.getUpdatedTezHistoryUrlBase("http://ambari:8080/#/main/views/TEZ/0.7.0.2.5.0.0-665/TEZ_CLUSTER_INSTANCE")); - - reset(viewDirectory); - - expect(viewDirectory.listFiles(anyObject(FilenameFilter.class))).andReturn(new File[] {}).anyTimes(); - replay(viewDirectory); - assertEquals("2.1", upgradeCatalog.getLatestTezViewVersion("2.1")); - assertEquals("http://ambari:8080/#/main/views/TEZ/0.7.0.2.5.0.0-665/TEZ_CLUSTER_INSTANCE", - upgradeCatalog.getUpdatedTezHistoryUrlBase("http://ambari:8080/#/main/views/TEZ/0.7.0.2.5.0.0-665/TEZ_CLUSTER_INSTANCE")); - } - - @Test(expected = AmbariException.class) - public void shouldThrowExceptionWhenOldTezViewUrlIsInvalid() throws Exception { - upgradeCatalog.getUpdatedTezHistoryUrlBase("Invalid URL"); - } - private static PropertyInfo createProperty(String filename, String name, boolean add, boolean update, boolean delete) { PropertyInfo propertyInfo = new PropertyInfo(); propertyInfo.setFilename(filename); http://git-wip-us.apache.org/repos/asf/ambari/blob/9c7b290d/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog250Test.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog250Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog250Test.java index 67806a0..2bb75da 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog250Test.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog250Test.java @@ -160,6 +160,8 @@ public class UpgradeCatalog250Test { @Mock(type = MockType.NICE) private Injector injector; + private UpgradeCatalog250 upgradeCatalog250; + @Before public void init() { reset(entityManagerProvider, injector); @@ -171,6 +173,8 @@ public class UpgradeCatalog250Test { expect(injector.getInstance(KerberosHelper.class)).andReturn(kerberosHelper).anyTimes(); replay(entityManagerProvider, injector); + + upgradeCatalog250 = new UpgradeCatalog250(injector); } @After @@ -394,6 +398,7 @@ public class UpgradeCatalog250Test { Method updateLogSearchAlert = UpgradeCatalog250.class.getDeclaredMethod("updateLogSearchAlert"); Method updateAmbariInfraConfigs = UpgradeCatalog250.class.getDeclaredMethod("updateAmbariInfraConfigs"); Method updateRangerUrlConfigs = UpgradeCatalog250.class.getDeclaredMethod("updateRangerUrlConfigs"); + Method updateTezHistoryUrlBase = UpgradeCatalog250.class.getDeclaredMethod("updateTezHistoryUrlBase"); Method updateYarnSite = UpgradeCatalog250.class.getDeclaredMethod("updateYarnSite"); Method updateAlerts = UpgradeCatalog250.class.getDeclaredMethod("updateStormAlerts"); Method removeAlertDuplicates = UpgradeCatalog250.class.getDeclaredMethod("removeAlertDuplicates"); @@ -421,6 +426,7 @@ public class UpgradeCatalog250Test { .addMockedMethod(removeAlertDuplicates) .addMockedMethod(updateKerberosDescriptorArtifacts) .addMockedMethod(fixHBaseMasterCPUUtilizationAlertDefinition) + .addMockedMethod(updateTezHistoryUrlBase) .createMock(); upgradeCatalog250.updateAMSConfigs(); @@ -465,6 +471,9 @@ public class UpgradeCatalog250Test { upgradeCatalog250.addManageAlertNotificationsPermissions(); expectLastCall().once(); + upgradeCatalog250.updateTezHistoryUrlBase(); + expectLastCall().once(); + upgradeCatalog250.updateYarnSite(); expectLastCall().once(); @@ -1982,6 +1991,17 @@ public class UpgradeCatalog250Test { Assert.assertEquals(2, ambariAdministratorPermissionEntity.getAuthorizations().size()); } + @Test(expected = AmbariException.class) + public void shouldThrowExceptionWhenOldTezViewUrlIsInvalid() throws Exception { + upgradeCatalog250.getUpdatedTezHistoryUrlBase("Invalid URL"); + } + + @Test + public void shouldCreateRightTezAutoUrl() throws Exception { + String newUrl = upgradeCatalog250.getUpdatedTezHistoryUrlBase("http://hostname:8080/#/main/views/TEZ/0.7.0.2.6.0.0-561/tez1"); + Assert.assertEquals("incorrect tez view url create.", "http://hostname:8080/#/main/view/TEZ/tez_cluster_instance", newUrl); + } + @Test public void testUpdateRangerUrlConfigs() throws Exception { Map<String, String> oldHdfsProperties = new HashMap<String, String>(); http://git-wip-us.apache.org/repos/asf/ambari/blob/9c7b290d/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py b/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py index c3fd51f..a2b7714 100644 --- a/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py +++ b/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py @@ -162,7 +162,7 @@ class TestHDP22StackAdvisor(TestCase): for host in hosts["items"]: if server_host == host["Hosts"]["host_name"]: server_host = host["Hosts"]["public_host_name"] - tez_ui_url = "http://" + server_host + ":8080/#/main/views/TEZ/0.7.0.2.3.0.0-2155/TEZ_CLUSTER_INSTANCE" + tez_ui_url = "http://" + server_host + ":8080/#/main/view/TEZ/tez_cluster_instance" services['ambari-server-properties'] = {'api.ssl': 'false'} expected['tez-site']['properties']['tez.tez-ui.history-url.base'] = tez_ui_url @@ -3479,19 +3479,19 @@ class TestHDP22StackAdvisor(TestCase): 'tez.runtime.io.sort.mb' : '256', 'tez.runtime.unordered.output.buffer.size-mb' : '256', 'tez.am.resource.memory.mb' : '1024', - 'tez.tez-ui.history-url.base' : 'https://host:8443/#/main/views/TEZ/0.7.0.2.3.0.0-2155/TEZ_CLUSTER_INSTANCE'} + 'tez.tez-ui.history-url.base' : 'https://host:8443/#/main/view/TEZ/tez_cluster_instance'} properties = {'tez.task.resource.memory.mb': '2050', 'tez.runtime.io.sort.mb' : '256', 'tez.runtime.unordered.output.buffer.size-mb' : '256', 'tez.am.resource.memory.mb' : '2050', - 'tez.tez-ui.history-url.base' : 'http://host:8080/#/main/views/TEZ/0.7.0.2.3.0.0-2155/TEZ_CLUSTER_INSTANCE'} + 'tez.tez-ui.history-url.base' : 'http://host:8080/#/main/view/TEZ/tez_cluster_instance'} res_expected = [{'config-name': 'tez.tez-ui.history-url.base', 'config-type': 'tez-site', 'level': 'WARN', - 'message': "It is recommended to set value https://host:8443/#/main/views/TEZ/0.7.0.2.3.0.0-2155/TEZ_CLUSTER_INSTANCE for property tez.tez-ui.history-url.base", + 'message': "It is recommended to set value https://host:8443/#/main/view/TEZ/tez_cluster_instance for property tez.tez-ui.history-url.base", 'type': 'configuration'}, {'config-name': 'tez.am.resource.memory.mb', 'config-type': 'tez-site', http://git-wip-us.apache.org/repos/asf/ambari/blob/9c7b290d/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py b/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py index 443331a..c28ee2a 100644 --- a/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py +++ b/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py @@ -1310,7 +1310,7 @@ class TestHDP23StackAdvisor(TestCase): for host in hosts["items"]: if server_host == host["Hosts"]["host_name"]: server_host = host["Hosts"]["public_host_name"] - tez_ui_url = "http://" + server_host + ":8080/#/main/views/TEZ/0.7.0.2.3.0.0-2155/TEZ_CLUSTER_INSTANCE" + tez_ui_url = "http://" + server_host + ":8080/#/main/view/TEZ/tez_cluster_instance" # Test JDK1.7 services['ambari-server-properties'] = {'java.home': '/usr/jdk64/jdk1.7.3_23'}
