Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Individually run tests succeed while running whole class fails on the second #331

Open
callaertanthony opened this issue Jun 16, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@callaertanthony
Copy link

Describe the bug
I discovered when I run whole class test I have a second independent test failing when I need to create topics.

To Reproduce
This gist : https://gist.github.com/callaertanthony/571eeeca9b406b2cf0770df6394948bc

Expected behavior
The two tests must success as they run exactly the same method without sharing context

Logs

metaPropertiesEnsemble=MetaPropertiesEnsemble(metadataLogDir=Optional.empty, dirs={/var/folders/4g/mxpw3bf903sgt_53jrrx_km40000gp/T/kafka11103251442868018071/broker-0: EMPTY})
io.kroxylicious.testing.kafka.invm.InVMKafkaCluster@4e6f2bb5
org.apache.kafka.clients.admin.KafkaAdminClient@21e20ad5
{virtualClusters:{demo=VirtualCluster[targetCluster=TargetCluster[bootstrapServers='localhost:20273', clientTls=null], clusterNetworkAddressConfigProvider=ClusterNetworkAddressConfigProviderDefinition[type=io.kroxylicious.proxy.internal.clusternetworkaddressconfigprovider.PortPerBrokerClusterNetworkAddressConfigProvider, config=io.kroxylicious.proxy.internal.clusternetworkaddressconfigprovider.PortPerBrokerClusterNetworkAddressConfigProvider$PortPerBrokerClusterNetworkAddressConfigProviderConfig@54657dd2], tls=Optional.empty, logNetwork=false, logFrames=false]},useIoUring:false}
io.kroxylicious.test.tester.DefaultKroxyliciousTester@706eab5d
io.kroxylicious.test.client.KafkaClient@72725ee1
CloseableAdmin[instance=org.apache.kafka.clients.admin.KafkaAdminClient@61f39bb]
metaPropertiesEnsemble=MetaPropertiesEnsemble(metadataLogDir=Optional.empty, dirs={/var/folders/4g/mxpw3bf903sgt_53jrrx_km40000gp/T/kafka14558994476648222760/broker-0: EMPTY})
io.kroxylicious.testing.kafka.invm.InVMKafkaCluster@6724cdec
org.apache.kafka.clients.admin.KafkaAdminClient@6944e53e
{virtualClusters:{demo=VirtualCluster[targetCluster=TargetCluster[bootstrapServers='localhost:16636', clientTls=null], clusterNetworkAddressConfigProvider=ClusterNetworkAddressConfigProviderDefinition[type=io.kroxylicious.proxy.internal.clusternetworkaddressconfigprovider.PortPerBrokerClusterNetworkAddressConfigProvider, config=io.kroxylicious.proxy.internal.clusternetworkaddressconfigprovider.PortPerBrokerClusterNetworkAddressConfigProvider$PortPerBrokerClusterNetworkAddressConfigProviderConfig@52e04737], tls=Optional.empty, logNetwork=false, logFrames=false]},useIoUring:false}
io.kroxylicious.test.tester.DefaultKroxyliciousTester@5bc7e78e
io.kroxylicious.test.client.KafkaClient@1a4d1ab7
CloseableAdmin[instance=org.apache.kafka.clients.admin.KafkaAdminClient@546e61d5]

Additional context
Add any other context about the problem here.

@callaertanthony callaertanthony added the bug Something isn't working label Jun 16, 2024
@callaertanthony
Copy link
Author

If I set the cluster with @ZooKeeperCluster it works. So it seems that it's the KRaft mode who fails

@k-wall
Copy link
Contributor

k-wall commented Jun 17, 2024

I believe you are just seeing the eventually consistent nature of Kafka. Just because you've successfully created a topic does not necessarily mean you'll be able to query it immediately. It may take time to appear. You'd get the same behaviour with just plain old Kafka.

If you add to your test, the problem should go away.

            await().atMost(Duration.ofSeconds(5)).until(() -> admin.listTopics().namesToListings().get(),
                    n -> n.size() == 2);

The @Topic annotation guarantees you that the topic is available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants