Giter VIP home page Giter VIP logo

hivemq-testcontainer's Introduction

hivemq-testcontainer's People

Contributors

rhinobetatron avatar sgtsilvio avatar yannickweber avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hivemq-testcontainer's Issues

Extensions added with .withFile did not have the permissions to write Files.

Problem or use case

The extensions added by the hivemq-testcontainer cannot create files.

@Rule
public final @NotNull HiveMQTestContainerRule rule =
        new HiveMQTestContainerRule()
                .withExtension(HiveMQExtension.builder()
                        .id("extension-1")
                        .name("my-extension")
                        .version("1.0")
                        .mainClass(FileCreatorExtension.class).build());

This code inside the Extension will throw an IOException with message 'permission denied':

final File extensionHomeFolder = extensionStartInput.getExtensionInformation().getExtensionHomeFolder();
final File file = new File(extensionHomeFolder, "myfile.txt");
file.createNewFile()

Preferred solution or suggestions

Set permissions correctly

Method to disable the hivemq-allow-all-extension

Problem or use case

For some tests I need to disable the hivemq-allow-all-extension.

Preferred solution or suggestions

container.withAllowAllExtensionDisabled()

container.enableAllowAllExtension()

container.disableAllowAllExtension()

Classes in method arguments are not put into extension jar

Expected behavior

A class that is used in as a method parameter should also be put into the extension jar.
The causes the extension to throw a ClassNotFoundException.

Actual behavior

The class is missing.

Reproducer code

public class MyExtension implements ExtensionMain {

    @Override
    public void extensionStart(
           final @NotNull ExtensionStartInput extensionStartInput, 
           final @NotNull ExtensionStartOutput extensionStartOutput) {
                   doNothing(new B());
    }

    private void doNothing(final @NotNull A a) {

    }
}

public class B extends A {
}

public class A {
}

throws:

Caused by: java.lang.ClassNotFoundException: A
	at java.base/java.net.URLClassLoader.findClass(Unknown Source)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
	at com.hivemq.extensions.classloader.IsolatedPluginClassloader.loadClass(IsolatedPluginClassloader.java:123)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)

Details

  • Affected HiveMQ Testcontainer version(s): 1.0.0

Add extensions at runtime

Currently it is only possible to add an extension when creating the rule/extension:

public class ContainerWithExtensionFromDirectoryIT {

    @Rule
    public final @NotNull HiveMQTestContainerRule hivemqRule =
            new HiveMQTestContainerRule()
                    .withExtension(new File("src/test/resources/modifier-extension"))
                    .withLogLevel(Level.DEBUG);

    @Test(timeout = 500_000)
    public void test_extension_from_file() throws Exception {
        TestPublishModifiedUtil.testPublishModified(extension.getMqttPort());
    }
}

It should also be possible to add an extension at runtime:

class ContainerWithExtensionAtRuntimeFromDirectoryIT {

    @Rule
    public final @NotNull HiveMQTestContainerRule hivemqRule =
            new HiveMQTestContainerRule()
                    .withLogLevel(Level.DEBUG);

    @Test(timeout = 500_000)
    public void test_adding_extension_at_runtime_from_file() throws Exception {
        hivemqRule.addExtension(new File("src/test/resources/modifier-extension"));

        TestPublishModifiedUtil.testPublishModified(extension.getMqttPort());
    }
}

Silencing of container output.

The user should be able to silence the output of HiveMQ, so it is not printed to the hosts stdout.

@RegisterExtension
final @NotNull HiveMQTestContainerExtension extension = 
    new HiveMQTestContainerExtension()
    .silenceContainer(true);

Wait strategy does not work when restarting

Expected behavior

The wait strategy should always work, also when restarting a container

Actual behavior

When restarting a container, the wait strategy does not work, returns too early, almost instant

Problem is the use of MultiLogMessageWaitStrategy, which holds the result of the first start.

To Reproduce

Steps

  1. start => wait strategy works
  2. stop
  3. start => wait strategy does not work, returns too early, almost instant

Details

  • Affected HiveMQ Testcontainer version(s): 1.3.0
  • Used JVM version:

Cannot create extension with generated sources

It appears that ShrinkWrap fails to create an extension jar that includes generated sources, e.g. when using Dagger dependency injection in an extension (the failing class DaggerKafkaExtensionInjector is in a generated-sources source set):

2020-04-07 12:50:19,785 ERROR - Extension with id "hivemq-kafka-extension" cannot be started because of an uncaught exception thrown by the extension. Extension will be disabled.
java.lang.NoClassDefFoundError: com/hivemq/extensions/kafka/ioc/DaggerKafkaExtensionInjector
	at com.hivemq.extensions.kafka.ioc.DaggerBootstrap.bootstrapKafkaExtension(DaggerBootstrap.java:22)
	at com.hivemq.extensions.kafka.KafkaExtensionMain.extensionStart(KafkaExtensionMain.java:35)
	at cr.b.a(Unknown Source)
        at cr.c.d(Unknown Source)
	at cZ.h.c(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source)
	at com.codahale.metrics.InstrumentedExecutorService$InstrumentedRunnable.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.hivemq.extensions.kafka.ioc.DaggerKafkaExtensionInjector
	at java.base/java.net.URLClassLoader.findClass(Unknown Source)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
	at cu.a.loadClass(Unknown Source)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
	... 10 common frames omitted

Steps to reproduce

Try to use the testcontainer with e.g. kafka extension

Maven clean flags

Problem or use case

Restarting tests is problematic without executing mvn clean between execution attempts.

Preferred solution or suggestions

Include a .cleanBefore and .cleanAfter Method for the MavenHiveMQExtensionSupplier.

Method to change the MQTT Port.

Problem or use case

When the configuration of the containerised HiveMQ is changed and sets another MQTT port the .getMQTTPort() Method still returns the mapped port for the 1883 port. This causes the MqttWaitStrategy to fail.

Preferred solution or suggestions

Include a method withMqttPort(int)to change the Mqtt Port.

mounting of extensions

The user should be able to mount extensions.

Mount complete extension folder
The user should be able to mount a folder that is already containing an extension .jar and .xml

.withMountedExtension(File extensionDir)

Create extension from code and mount the containing folder

.withMountedExtension(HiveMQExtension extension, File extensionDir)

Expose generic container.

The user should be able to extend and modify the behaviour of the test container. Therefore the underlaying generic container should be exposed.

This would also enable the user to extend the HiveMQTestcontainerRule and add custom behaviour.

API Idea 1:

final @NotNull GenericContainer<HiveMQTestContanier> 
 container = rule.getGenericContainer();

API Idea 2:
The HiveMQTestContainer Interface should extend the Container Interface from TestContainers. The would yield the most elegant API but would lead to a lot of adpater boilerplate code, since every method of the HiveMQTestContainerImpl must be bridget.
Also a bit of refactoring must be done.

Enabling of extensions

The user should be able to enable extensions.

rule.disableExtension("extension-1", "my-extension");
rule.enableExtension("extension-1", "my-extension");

Static control center binding.

The user should be able to bind the control center port statically.

@RegisterExtension
final @NotNull HiveMQTestContainerExtension extension = 
    new HiveMQTestContainerExtension()
    .withControlCenterPort(8000);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.