You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@helix.apache.org by dasahcc <gi...@git.apache.org> on 2017/04/11 01:40:54 UTC

[GitHub] helix pull request #85: Add test for testing submessage fail but update stat...

GitHub user dasahcc opened a pull request:

    https://github.com/apache/helix/pull/85

    Add test for testing submessage fail but update status.

    In this test, one batch message will be generated to one instance which holds 10 replicas. Thus it will have 10 submessages. But only 6 of them will transit to ONLINE and others will be ERROR.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/dasahcc/helix helix-0.6.x

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/helix/pull/85.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #85
    
----
commit 9cfaddafb07ebab42195e0ad9f28a68a02a14b24
Author: Junkai Xue <jx...@linkedin.com>
Date:   2017-04-11T01:23:24Z

    Add test for testing submessage fail but update status.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] helix pull request #85: Add test for testing submessage fail but update stat...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/helix/pull/85


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] helix pull request #85: Add test for testing submessage fail but update stat...

Posted by dasahcc <gi...@git.apache.org>.
Github user dasahcc commented on a diff in the pull request:

    https://github.com/apache/helix/pull/85#discussion_r111678271
  
    --- Diff: helix-core/src/test/java/org/apache/helix/integration/TestBatchMessageHandling.java ---
    @@ -0,0 +1,106 @@
    +package org.apache.helix.integration;
    +
    +/*
    + * 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.
    + */
    +
    +import org.apache.helix.HelixException;
    +import org.apache.helix.NotificationContext;
    +import org.apache.helix.model.ExternalView;
    +import org.apache.helix.model.IdealState;
    +import org.apache.helix.model.Message;
    +import org.apache.helix.model.builder.FullAutoModeISBuilder;
    +import org.apache.helix.participant.statemachine.StateModel;
    +import org.apache.helix.participant.statemachine.StateModelFactory;
    +import org.testng.Assert;
    +import org.testng.annotations.Test;
    +
    +public class TestBatchMessageHandling extends ZkStandAloneCMTestBase {
    +
    +  @Test
    +  public void testSubMessageFailed() throws InterruptedException {
    +    TestOnlineOfflineStateModel._numOfSuccessBeforeFail = 6;
    +
    +    // Let one instance handle all the batch messages.
    +    _participants[0].getStateMachineEngine().registerStateModelFactory("OnlineOffline",
    +        new TestOnlineOfflineStateModelFactory(), "TestFactory");
    +    for (int i = 1; i < _participants.length; i++) {
    +      _participants[i].syncStop();
    +    }
    +
    +    // Add 1 db with batch message enabled. Each db has 10 partitions.
    +    // So it will have 1 batch message and 10 sub messages.
    +
    +    String dbName = "TestDBSubMessageFail";
    +    IdealState idealState = new FullAutoModeISBuilder(dbName).setStateModel("OnlineOffline")
    +        .setStateModelFactoryName("TestFactory").setNumPartitions(10).setNumReplica(1).build();
    +    idealState.setBatchMessageMode(true);
    +    _setupTool.getClusterManagementTool().addResource(CLUSTER_NAME, dbName, idealState);
    +    _setupTool.rebalanceStorageCluster(CLUSTER_NAME, dbName, 1);
    +
    +    Thread.sleep(1000L);
    +
    +    int numOfOnlines = 0;
    +    int numOfErrors = 0;
    +    ExternalView externalView =
    +        _setupTool.getClusterManagementTool().getResourceExternalView(CLUSTER_NAME, dbName);
    +    for (String partition : externalView.getPartitionSet()) {
    +      if (externalView.getStateMap(partition).values().contains("ONLINE")) {
    +        numOfOnlines++;
    +      }
    +
    +      if (externalView.getStateMap(partition).values().contains("ERROR")) {
    +        numOfErrors++;
    +      }
    +    }
    +
    +    Assert.assertEquals(numOfErrors, 4);
    +    Assert.assertEquals(numOfOnlines, 6);
    +  }
    +
    +  public static class TestOnlineOfflineStateModelFactory extends
    +      StateModelFactory<TestOnlineOfflineStateModel> {
    +    @Override
    +    public TestOnlineOfflineStateModel createNewStateModel(String resourceName, String stateUnitKey) {
    +      TestOnlineOfflineStateModel model = new TestOnlineOfflineStateModel();
    +      return model;
    +    }
    +  }
    +
    +  public static class TestOnlineOfflineStateModel extends StateModel {
    +    public static int _numOfSuccessBeforeFail;
    +
    +    public synchronized void onBecomeOnlineFromOffline(Message message,
    +        NotificationContext context) {
    +      if (_numOfSuccessBeforeFail-- > 0) {
    +        System.out.println("State transition from Offline to Online");
    --- End diff --
    
    Sure! Will fix it!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] helix pull request #85: Add test for testing submessage fail but update stat...

Posted by kishoreg <gi...@git.apache.org>.
Github user kishoreg commented on a diff in the pull request:

    https://github.com/apache/helix/pull/85#discussion_r111673592
  
    --- Diff: helix-core/src/test/java/org/apache/helix/integration/TestBatchMessageHandling.java ---
    @@ -0,0 +1,106 @@
    +package org.apache.helix.integration;
    +
    +/*
    + * 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.
    + */
    +
    +import org.apache.helix.HelixException;
    +import org.apache.helix.NotificationContext;
    +import org.apache.helix.model.ExternalView;
    +import org.apache.helix.model.IdealState;
    +import org.apache.helix.model.Message;
    +import org.apache.helix.model.builder.FullAutoModeISBuilder;
    +import org.apache.helix.participant.statemachine.StateModel;
    +import org.apache.helix.participant.statemachine.StateModelFactory;
    +import org.testng.Assert;
    +import org.testng.annotations.Test;
    +
    +public class TestBatchMessageHandling extends ZkStandAloneCMTestBase {
    +
    +  @Test
    +  public void testSubMessageFailed() throws InterruptedException {
    +    TestOnlineOfflineStateModel._numOfSuccessBeforeFail = 6;
    +
    +    // Let one instance handle all the batch messages.
    +    _participants[0].getStateMachineEngine().registerStateModelFactory("OnlineOffline",
    +        new TestOnlineOfflineStateModelFactory(), "TestFactory");
    +    for (int i = 1; i < _participants.length; i++) {
    +      _participants[i].syncStop();
    +    }
    +
    +    // Add 1 db with batch message enabled. Each db has 10 partitions.
    +    // So it will have 1 batch message and 10 sub messages.
    +
    +    String dbName = "TestDBSubMessageFail";
    +    IdealState idealState = new FullAutoModeISBuilder(dbName).setStateModel("OnlineOffline")
    +        .setStateModelFactoryName("TestFactory").setNumPartitions(10).setNumReplica(1).build();
    +    idealState.setBatchMessageMode(true);
    +    _setupTool.getClusterManagementTool().addResource(CLUSTER_NAME, dbName, idealState);
    +    _setupTool.rebalanceStorageCluster(CLUSTER_NAME, dbName, 1);
    +
    +    Thread.sleep(1000L);
    +
    +    int numOfOnlines = 0;
    +    int numOfErrors = 0;
    +    ExternalView externalView =
    +        _setupTool.getClusterManagementTool().getResourceExternalView(CLUSTER_NAME, dbName);
    +    for (String partition : externalView.getPartitionSet()) {
    +      if (externalView.getStateMap(partition).values().contains("ONLINE")) {
    +        numOfOnlines++;
    +      }
    +
    +      if (externalView.getStateMap(partition).values().contains("ERROR")) {
    +        numOfErrors++;
    +      }
    +    }
    +
    +    Assert.assertEquals(numOfErrors, 4);
    +    Assert.assertEquals(numOfOnlines, 6);
    +  }
    +
    +  public static class TestOnlineOfflineStateModelFactory extends
    +      StateModelFactory<TestOnlineOfflineStateModel> {
    +    @Override
    +    public TestOnlineOfflineStateModel createNewStateModel(String resourceName, String stateUnitKey) {
    +      TestOnlineOfflineStateModel model = new TestOnlineOfflineStateModel();
    +      return model;
    +    }
    +  }
    +
    +  public static class TestOnlineOfflineStateModel extends StateModel {
    +    public static int _numOfSuccessBeforeFail;
    +
    +    public synchronized void onBecomeOnlineFromOffline(Message message,
    +        NotificationContext context) {
    +      if (_numOfSuccessBeforeFail-- > 0) {
    +        System.out.println("State transition from Offline to Online");
    --- End diff --
    
    lets use loggers


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---