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

convert redisscala tests from groovy to java #12553

Closed
wants to merge 8 commits into from

Conversation

shalk
Copy link
Contributor

@shalk shalk commented Nov 1, 2024

@shalk shalk marked this pull request as ready for review November 8, 2024 12:41
@shalk shalk requested a review from a team as a code owner November 8, 2024 12:41
static void setUp() throws Exception {
redisServer = new GenericContainer<>("redis:6.2.3-alpine").withExposedPorts(6379);
redisServer.start();
// cleanup.deferCleanup(redisServer::stop);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this line

Comment on lines 56 to 57
host = redisServer.getHost();
port = redisServer.getMappedPort(6379);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be local variables?


@AfterAll
static void tearDown() throws Exception {
if (system != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

groovy version also calls redisServer.stop()

import scala.Option;
import scala.concurrent.Future;

public class RediscalaClientTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usually we make test classes package private

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.shaded.org.apache.commons.lang3.tuple.Pair;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we avoid using classes shaded into other libraries

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

.hasKind(CLIENT)
.hasParent(trace.getSpan(0))
.hasAttributesSatisfyingExactly(
equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add a static import for DB_SYSTEM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also could use DbIncubatingAttributes .DbIncubatingAttributes.REDIS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return Pair.of(writeFuture, valueFuture);
});

await().atMost(java.time.Duration.ofSeconds(3)).until(() -> result.getLeft().isCompleted());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could import java.time.Duration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

false,
false,
serializer));
await().atMost(java.time.Duration.ofSeconds(3)).until(value::isCompleted);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just wondering whether it would be better to use scala await class like the groovy test does or maybe even consider converting the whole test to scala

Copy link
Contributor Author

@shalk shalk Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think java class is enough to cover the instrument case

Comment on lines +105 to +106
SettableFuture<Future<Object>> writeFutureRef = SettableFuture.create();
;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SettableFuture<Future<Object>> writeFutureRef = SettableFuture.create();
;
SettableFuture<Future<Object>> writeFutureRef = SettableFuture.create();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants