Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dataroaring committed Sep 13, 2024
1 parent 4eca356 commit d1b77bb
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,6 @@ public void dropFrontend(FrontendNodeType role, String host, int port) throws Dd

@Override
public void modifyFrontendHostName(String srcHost, int srcPort, String destHost) throws DdlException {
throw new DdlException("modify frontend host name is not supported in cloud mode");
throw new DdlException("Modifying frontend hostname is not supported in cloud mode");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.doris.cloud.system;

import org.apache.doris.analysis.ModifyBackendClause;
import org.apache.doris.analysis.ModifyBackendHostNameClause;
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.ReplicaAllocation;
import org.apache.doris.cloud.catalog.CloudEnv;
Expand Down Expand Up @@ -407,6 +409,16 @@ public void decommissionBackend(Backend backend) throws UserException {
}
}

@Override
public void modifyBackends(ModifyBackendClause alterClause) throws UserException {
throw new UserException("Modifying backends is not supported in cloud mode");
}

@Override
public void modifyBackendHost(ModifyBackendHostNameClause clause) throws UserException {
throw new UserException("Modifying backend hostname is not supported in cloud mode");
}

@Override
public void replayAddBackend(Backend newBackend) {
super.replayAddBackend(newBackend);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// 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.

suite('test_not_allowed_op', 'p0') {
if (!isCloudMode()) {
return;
}

// Test modifying frontend is not allowed
try {
// Get current frontend information
def frontendResult = sql_return_maparray """SHOW FRONTENDS"""
logger.info("Current frontends: ${frontendResult}")

// Extract the first frontend's information
def firstFrontend = frontendResult[0]
def frontendHost = firstFrontend['Host']
def frontendEditLogPort = firstFrontend['EditLogPort']

// Construct the frontend address
def frontendAddress = "${frontendHost}:${frontendEditLogPort}"
logger.info("Attempting to modify frontend: ${frontendAddress}")
def result = sql """ ALTER SYSTEM MODIFY FRONTEND "${frontendAddress}" HOSTNAME 'localhost' """
logger.info("Modify frontend result: ${result}")
throw new IllegalStateException("Expected exception was not thrown")
} catch (Exception e) {
assertTrue(e.getMessage().contains("Modifying frontend hostname is not supported in cloud mode"))
}

// Get current backend information
def backendResult = sql_return_maparray """SHOW BACKENDS"""
logger.info("Current backends: ${backendResult}")

// Extract the first backend's information
def firstBackend = backendResult[0]
def backendHost = firstBackend['Host']
def backendHeartbeatPort = firstBackend['HeartbeatPort']

// Construct the backend address
def backendAddress = "${backendHost}:${backendHeartbeatPort}"
// Test modifying backend is not allowed
try {
logger.info("Attempting to modify backend: ${backendAddress}")
def result = sql """ ALTER SYSTEM MODIFY BACKEND '${backendAddress}' SET("tag.location" = "tag1") """
logger.info("Modify backend result: ${result}")
throw new IllegalStateException("Expected exception was not thrown")
} catch (Exception e) {
logger.info("Caught expected exception: ${e.getMessage()}")
assertTrue(e.getMessage().contains("Modifying backends is not supported in cloud mode"))
}

// Test modifying backend hostname is not allowed
try {
sql """ ALTER SYSTEM MODIFY BACKEND "${backendAddress}" HOSTNAME 'localhost' """
throw new IllegalStateException("Expected exception was not thrown")
} catch (Exception e) {
assertTrue(e.getMessage().contains("Modifying backend hostname is not supported in cloud mode"))
}

logger.info("All tests for disallowed operations in cloud mode passed successfully")
}

0 comments on commit d1b77bb

Please sign in to comment.