-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make configPath unable to update at runtime (#6733)
* Make configPath unable to update at runtime * Make configPath unable to update at runtime * Add ASF header * Add ASF header * Pass the check style * Polish the response code * Polish the response code
- Loading branch information
1 parent
5dc2e20
commit 9d411cf
Showing
6 changed files
with
163 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
controller/src/test/java/org/apache/rocketmq/controller/ControllerRequestProcessorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* 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.rocketmq.controller; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
import java.util.Properties; | ||
import org.apache.rocketmq.common.ControllerConfig; | ||
import org.apache.rocketmq.common.MixAll; | ||
import org.apache.rocketmq.controller.processor.ControllerRequestProcessor; | ||
import org.apache.rocketmq.remoting.netty.NettyClientConfig; | ||
import org.apache.rocketmq.remoting.netty.NettyServerConfig; | ||
import org.apache.rocketmq.remoting.protocol.RemotingCommand; | ||
import org.apache.rocketmq.remoting.protocol.RequestCode; | ||
import org.apache.rocketmq.remoting.protocol.ResponseCode; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class ControllerRequestProcessorTest { | ||
|
||
private ControllerRequestProcessor controllerRequestProcessor; | ||
|
||
@Before | ||
public void init() throws Exception { | ||
controllerRequestProcessor = new ControllerRequestProcessor(new ControllerManager(new ControllerConfig(), new NettyServerConfig(), new NettyClientConfig())); | ||
} | ||
|
||
@Test | ||
public void testProcessRequest_UpdateConfigPath() throws Exception { | ||
final RemotingCommand updateConfigRequest = RemotingCommand.createRequestCommand(RequestCode.UPDATE_CONTROLLER_CONFIG, null); | ||
Properties properties = new Properties(); | ||
|
||
// Update allowed value | ||
properties.setProperty("notifyBrokerRoleChanged", "true"); | ||
updateConfigRequest.setBody(MixAll.properties2String(properties).getBytes(StandardCharsets.UTF_8)); | ||
|
||
RemotingCommand response = controllerRequestProcessor.processRequest(null, updateConfigRequest); | ||
|
||
assertThat(response).isNotNull(); | ||
assertThat(response.getCode()).isEqualTo(ResponseCode.SUCCESS); | ||
|
||
// Update disallowed value | ||
properties.clear(); | ||
properties.setProperty("configStorePath", "test/path"); | ||
updateConfigRequest.setBody(MixAll.properties2String(properties).getBytes(StandardCharsets.UTF_8)); | ||
|
||
response = controllerRequestProcessor.processRequest(null, updateConfigRequest); | ||
|
||
assertThat(response).isNotNull(); | ||
assertThat(response.getCode()).isEqualTo(ResponseCode.NO_PERMISSION); | ||
assertThat(response.getRemark()).contains("Can not update config path"); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters