ARTEMIS-3417 AutoDelete false by default on the created broker.xml
This commit is contained in:
parent
dfca54cedd
commit
8442c9b9d6
|
@ -223,6 +223,9 @@ public class Create extends InputAbstract {
|
||||||
@Option(name = "--autocreate", description = "Auto create addresses. (default: true)")
|
@Option(name = "--autocreate", description = "Auto create addresses. (default: true)")
|
||||||
private Boolean autoCreate;
|
private Boolean autoCreate;
|
||||||
|
|
||||||
|
@Option(name = "--autodelete", description = "If set, the default broker.xml will allow auto deletion of queues and addresses")
|
||||||
|
private boolean autoDelete;
|
||||||
|
|
||||||
@Option(name = "--user", description = "The username (Default: input)")
|
@Option(name = "--user", description = "The username (Default: input)")
|
||||||
private String user;
|
private String user;
|
||||||
|
|
||||||
|
@ -429,6 +432,15 @@ public class Create extends InputAbstract {
|
||||||
this.etc = etc;
|
this.etc = etc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAutoDelete() {
|
||||||
|
return autoDelete;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Create setAutoDelete(boolean autoDelete) {
|
||||||
|
this.autoDelete = autoDelete;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
private String getClusterUser() {
|
private String getClusterUser() {
|
||||||
if (clusterUser == null) {
|
if (clusterUser == null) {
|
||||||
clusterUser = input("--cluster-user", "Please provide the username:", "cluster-admin");
|
clusterUser = input("--cluster-user", "Please provide the username:", "cluster-admin");
|
||||||
|
@ -819,6 +831,7 @@ public class Create extends InputAbstract {
|
||||||
|
|
||||||
|
|
||||||
filters.put("${auto-create}", isAutoCreate() ? "true" : "false");
|
filters.put("${auto-create}", isAutoCreate() ? "true" : "false");
|
||||||
|
filters.put("${auto-delete}", autoDelete ? "true" : "false");
|
||||||
|
|
||||||
if (jdbc) {
|
if (jdbc) {
|
||||||
noAutoTune = true;
|
noAutoTune = true;
|
||||||
|
|
|
@ -151,6 +151,8 @@ ${cluster-security.settings}${cluster.settings}${replicated.settings}${shared-st
|
||||||
<auto-create-addresses>${auto-create}</auto-create-addresses>
|
<auto-create-addresses>${auto-create}</auto-create-addresses>
|
||||||
<auto-create-jms-queues>${auto-create}</auto-create-jms-queues>
|
<auto-create-jms-queues>${auto-create}</auto-create-jms-queues>
|
||||||
<auto-create-jms-topics>${auto-create}</auto-create-jms-topics>
|
<auto-create-jms-topics>${auto-create}</auto-create-jms-topics>
|
||||||
|
<auto-delete-queues>${auto-delete}</auto-delete-queues>
|
||||||
|
<auto-delete-addresses>${auto-delete}</auto-delete-addresses>
|
||||||
</address-setting>
|
</address-setting>
|
||||||
</address-settings>
|
</address-settings>
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ import javax.jms.JMSException;
|
||||||
import javax.jms.Message;
|
import javax.jms.Message;
|
||||||
import javax.jms.MessageConsumer;
|
import javax.jms.MessageConsumer;
|
||||||
import javax.jms.MessageProducer;
|
import javax.jms.MessageProducer;
|
||||||
|
import javax.jms.Queue;
|
||||||
import javax.jms.Session;
|
import javax.jms.Session;
|
||||||
import javax.jms.TextMessage;
|
import javax.jms.TextMessage;
|
||||||
import javax.json.JsonArray;
|
import javax.json.JsonArray;
|
||||||
|
@ -83,6 +84,7 @@ import org.apache.activemq.artemis.nativo.jlibaio.LibaioContext;
|
||||||
import org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec;
|
import org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec;
|
||||||
import org.apache.activemq.artemis.utils.HashProcessor;
|
import org.apache.activemq.artemis.utils.HashProcessor;
|
||||||
import org.apache.activemq.artemis.utils.PasswordMaskingUtil;
|
import org.apache.activemq.artemis.utils.PasswordMaskingUtil;
|
||||||
|
import org.apache.activemq.artemis.utils.RandomUtil;
|
||||||
import org.apache.activemq.artemis.utils.SensitiveDataCodec;
|
import org.apache.activemq.artemis.utils.SensitiveDataCodec;
|
||||||
import org.apache.activemq.artemis.utils.StringUtil;
|
import org.apache.activemq.artemis.utils.StringUtil;
|
||||||
import org.apache.activemq.artemis.utils.Wait;
|
import org.apache.activemq.artemis.utils.Wait;
|
||||||
|
@ -749,7 +751,6 @@ public class ArtemisTest extends CliTestBase {
|
||||||
|
|
||||||
File userFile = new File(instance1.getAbsolutePath() + "/etc/artemis-users.properties");
|
File userFile = new File(instance1.getAbsolutePath() + "/etc/artemis-users.properties");
|
||||||
userFile.delete();
|
userFile.delete();
|
||||||
// File roleFile = new File(instance1.getAbsolutePath() + "/etc/artemis-roles.properties");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
activeMQServerControl.listUser("");
|
activeMQServerControl.listUser("");
|
||||||
|
@ -1326,6 +1327,63 @@ public class ArtemisTest extends CliTestBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAutoDeleteTrue() throws Exception {
|
||||||
|
testAutoDelete(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAutoDeleteFalse() throws Exception {
|
||||||
|
testAutoDelete(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testAutoDelete(boolean autoDelete) throws Exception {
|
||||||
|
|
||||||
|
File instanceFolder = temporaryFolder.newFolder("autocreate" + autoDelete);
|
||||||
|
setupAuth(instanceFolder);
|
||||||
|
|
||||||
|
// This is usually set when run from the command line via artemis.profile
|
||||||
|
Run.setEmbedded(true);
|
||||||
|
if (autoDelete) {
|
||||||
|
Artemis.main("create", instanceFolder.getAbsolutePath(), "--force", "--silent", "--no-web", "--no-autotune", "--require-login", "--autodelete");
|
||||||
|
} else {
|
||||||
|
Artemis.main("create", instanceFolder.getAbsolutePath(), "--force", "--silent", "--no-web", "--require-login", "--no-autotune");
|
||||||
|
}
|
||||||
|
System.setProperty("artemis.instance", instanceFolder.getAbsolutePath());
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Some exceptions may happen on the initialization, but they should be ok on start the basic core protocol
|
||||||
|
Pair<ManagementContext, ActiveMQServer> run = (Pair<ManagementContext, ActiveMQServer>) Artemis.internalExecute("run");
|
||||||
|
|
||||||
|
String queueName = "testAutoDelete" + RandomUtil.randomPositiveInt();
|
||||||
|
|
||||||
|
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
|
||||||
|
try (Connection connection = factory.createConnection("admin", "admin")) {
|
||||||
|
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||||
|
Queue queue = session.createQueue(queueName);
|
||||||
|
MessageProducer producer = session.createProducer(queue);
|
||||||
|
producer.send(session.createTextMessage("hi"));
|
||||||
|
|
||||||
|
Wait.assertTrue(() -> run.getB().locateQueue(queueName) != null);
|
||||||
|
connection.start();
|
||||||
|
MessageConsumer consumer = session.createConsumer(queue);
|
||||||
|
Assert.assertNotNull(consumer.receive(5000));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (autoDelete) {
|
||||||
|
Wait.assertTrue(() -> run.getB().locateQueue(queueName) == null);
|
||||||
|
} else {
|
||||||
|
// Things are async, allowing some time to make sure it would eventually fail
|
||||||
|
Thread.sleep(500);
|
||||||
|
Assert.assertNotNull(run.getB().locateQueue(queueName));
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
stopServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPing() throws Exception {
|
public void testPing() throws Exception {
|
||||||
|
|
Loading…
Reference in New Issue