[ 
https://issues.apache.org/jira/browse/GEODE-3292?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16112982#comment-16112982
 ] 

ASF GitHub Bot commented on GEODE-3292:
---------------------------------------

Github user jinmeiliao commented on a diff in the pull request:

    https://github.com/apache/geode/pull/664#discussion_r131182711
  
    --- Diff: 
geode-pulse/src/test/java/org/apache/geode/tools/pulse/internal/PulseAppListenerTest.java
 ---
    @@ -0,0 +1,91 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
    + * agreements. See the NOTICE file distributed with this work for 
additional information regarding
    + * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance with the 
License. You may obtain a
    + * copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software 
distributed under the License
    + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 
ANY KIND, either express
    + * or implied. See the License for the specific language governing 
permissions and limitations under
    + * the License.
    + *
    + */
    +
    +package org.apache.geode.tools.pulse.internal;
    +
    +import javax.servlet.ServletContextEvent;
    +import static org.mockito.Mockito.*;
    +
    +import org.junit.After;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Rule;
    +import org.junit.Test;
    +import org.junit.contrib.java.lang.system.RestoreSystemProperties;
    +import org.junit.experimental.categories.Category;
    +import org.junit.rules.TestRule;
    +
    +import org.apache.geode.test.junit.categories.UnitTest;
    +import org.apache.geode.tools.pulse.internal.data.PulseConstants;
    +import org.apache.geode.tools.pulse.internal.data.Repository;
    +
    +@Category(UnitTest.class)
    +public class PulseAppListenerTest {
    +  private Repository repository;
    +  private PulseAppListener appListener;
    +
    +  @Rule
    +  public final TestRule restoreSystemProperties = new 
RestoreSystemProperties();
    +
    +  @Before
    +  public void setUp() {
    +    repository = Repository.get();
    +    appListener = new PulseAppListener();
    +  }
    +
    +  @Test
    +  public void embeddedModeDefaultPropertiesRepositoryInitializationTest() {
    +    System.setProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_EMBEDDED, 
"true");
    +    appListener.contextInitialized(mock(ServletContextEvent.class));
    +
    +    Assert.assertEquals(false, repository.getJmxUseLocator());
    +    Assert.assertEquals(false, repository.isUseSSLManager());
    +    Assert.assertEquals(false, repository.isUseSSLLocator());
    +    Assert.assertEquals(PulseConstants.GEMFIRE_DEFAULT_PORT, 
repository.getPort());
    +    Assert.assertEquals(PulseConstants.GEMFIRE_DEFAULT_HOST, 
repository.getHost());
    +
    +  }
    +
    +  @Test
    +  public void 
embeddedModeNonDefaultPropertiesRepositoryInitializationTest() {
    +    System.setProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_EMBEDDED, 
"true");
    +    System.setProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_PORT, "9999");
    +    System.setProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_HOST, 
"nonDefaultBindAddress");
    +    System.setProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_USESSL_MANAGER,
    +        Boolean.TRUE.toString());
    +    System.setProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_USESSL_LOCATOR,
    +        Boolean.TRUE.toString());
    +
    +    appListener.contextInitialized(mock(ServletContextEvent.class));
    +
    +    Assert.assertEquals(false, repository.getJmxUseLocator());
    +    Assert.assertEquals(true, repository.isUseSSLManager());
    +    Assert.assertEquals(true, repository.isUseSSLLocator());
    +    Assert.assertEquals("9999", repository.getPort());
    +    Assert.assertEquals("nonDefaultBindAddress", repository.getHost());
    +  }
    +
    +  @After
    +  public void tearDown() {
    +    if (repository != null) {
    --- End diff --
    
    this looks familiar, can you use EmbeddedPulseRule for this?


> Embedded PULSE Connection Failure When jmx-manager-bind-address != localhost
> ----------------------------------------------------------------------------
>
>                 Key: GEODE-3292
>                 URL: https://issues.apache.org/jira/browse/GEODE-3292
>             Project: Geode
>          Issue Type: Bug
>          Components: pulse
>            Reporter: Juan José Ramos Cassella
>            Assignee: Juan José Ramos Cassella
>            Priority: Minor
>
> The PULSE webApp (embedded mode) fails to connect to the jmx-manager when a 
> non-default {{jmx-manager-bind-address}} is configured. The app tries to 
> connect by default to 
> {{service:jmx:rmi://localhost/jndi/rmi://localhost:17991/jmxrmi}} whenever it 
> detects it's running in embedded mode, instead of getting the local hostname 
> through {{InetAddress.getLocalHost().getCanonicalHostName()}} as it used to 
> do before.
> The problem was introduced by 
> [GEODE-2927|https://issues.apache.org/jira/browse/GEODE-2927], commit 
> [0f978a6df711d04e0c7c1926fb1e297d07c21aa3|https://git-wip-us.apache.org/repos/asf?p=geode.git;h=0f978a6].
> Steps to reproduce:
> {code:none}
> $ export JAVA_ARGS="-Dgfsh.log-level=config -Dgfsh.log-dir=$(pwd)"
> $ gfsh start locator --name=locator1 --force=true --connect=false \
>     --J=-Dpulse.Log-Level=debug --J=-Dpulse.Log-File-Name=pulse.log 
> --J=-Dpulse.Log-FileLocation=$(pwd) \
>     --J=-Dgemfire.jmx-manager=true --J=-Dgemfire.jmx-manager-start=true 
> --J=-Dgemfire.jmx-manager-port=17991 \
>     --J=-Dgemfire.jmx-manager-bind-address=$(ipconfig getifaddr en0)
> $ gfsh start pulse
> {code}
> At this point, and after a successful login to PULSE, the application doesn't 
> show any cluster data and the exception can be seen (both in the logs and in 
> the PULSE screen).
> The easiest solution would be to revert back some lines of the changes made 
> by commit 
> [0f978a6df711d04e0c7c1926fb1e297d07c21aa3|https://git-wip-us.apache.org/repos/asf?p=geode.git;h=0f978a6],
>  as follows:
> {code:title=PulseAppListener.java|borderStyle=solid}
> @Override
>   public void contextInitialized(ServletContextEvent event) {
>       (...)
>     boolean sysIsEmbedded = 
> Boolean.getBoolean(PulseConstants.SYSTEM_PROPERTY_PULSE_EMBEDDED);
>     if (sysIsEmbedded) {
>       // jmx connection parameters
>       
> logger.info(resourceBundle.getString("LOG_MSG_APP_RUNNING_EMBEDDED_MODE"));
>       repository.setJmxUseLocator(false);
>       
> //----------------------------------------------------------------------------------------
>         String sysPulseHost;
>       try {
>         // Get host name of machine running pulse in embedded mode
>         sysPulseHost = InetAddress.getLocalHost().getCanonicalHostName();
>       } catch (Exception e) {
>         
> logger.debug(resourceBundle.getString("LOG_MSG_JMX_CONNECTION_UNKNOWN_HOST"), 
> e);
>         // Set default host name
>         sysPulseHost = PulseConstants.GEMFIRE_DEFAULT_HOST;
>       }
>       repository.setHost(sysPulseHost);
>       
> //----------------------------------------------------------------------------------------
>       
> repository.setPort(System.getProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_PORT,
>           PulseConstants.GEMFIRE_DEFAULT_PORT));
>       // SSL, all the other system properties are already set in the embedded 
> VM
>       repository.setUseSSLManager(
>           
> Boolean.valueOf(System.getProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_USESSL_MANAGER)));
>       repository.setUseSSLLocator(
>           
> Boolean.valueOf(System.getProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_USESSL_LOCATOR)));
>       (...)
>   }
> {code}
> I can make the changes and submit a PR if someone assigns me this ticket.
> Cheers.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to