Skip to content

convert redisscala tests from groovy to java#12553

Closed
shalk wants to merge 8 commits into
open-telemetry:mainfrom
shalk:test-rediscala
Closed

convert redisscala tests from groovy to java#12553
shalk wants to merge 8 commits into
open-telemetry:mainfrom
shalk:test-rediscala

Conversation

@shalk

@shalk shalk commented Nov 1, 2024

Copy link
Copy Markdown
Member

@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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member 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
Copy Markdown
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
Copy Markdown
Member 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
Copy Markdown
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

@shalk shalk Nov 11, 2024

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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