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

Removed cartridge-java from dependencies #71

Merged
merged 1 commit into from
Jun 16, 2023
Merged

Removed cartridge-java from dependencies #71

merged 1 commit into from
Jun 16, 2023

Conversation

iDneprov
Copy link
Contributor

@iDneprov iDneprov commented May 5, 2023

  • Update executeScript and executeCommand methods to execute code viva execInContainer.
  • Add executeScriptDecoded and executeCommandDecoded methods to return parsed yaml not String.
  • Remove cartridge-java client from TarantoolContainerClientHelper and tests.
  • Rewrite tests and add new cases to support new API.
  • Remove io.tarantool.cartridge-driver dependency.
  • Update org.yaml.snakeyaml to 2.0 version.

I haven't forgotten about:

  • Tests
  • Changelog
  • Documentation
  • Commit messages comply with the guideline
  • Cleanup the code for review. See checklist

Related issues:

Closes #69

@iDneprov iDneprov changed the title Gh 69 Removed cartridge-java from dependencies May 17, 2023
@iDneprov iDneprov closed this May 17, 2023
@iDneprov iDneprov reopened this May 17, 2023
@iDneprov iDneprov requested a review from ArtDu May 17, 2023 17:11
@dkasimovskiy dkasimovskiy requested a review from akudiyar May 18, 2023 09:21
@iDneprov
Copy link
Contributor Author

I also need to think about a container builder for SSL | mTLS tests.

Copy link
Contributor

@ArtDu ArtDu left a comment

Choose a reason for hiding this comment

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

Just two small comments

CHANGELOG.md Outdated
@@ -1,5 +1,15 @@
# Changelog

## [0.6.0] - 2023-05-17
BREAKING CHANGES
Copy link
Contributor

Choose a reason for hiding this comment

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

Not all of them are breaking changes. Look how we did it cartridge-java
image

pom.xml Outdated
@@ -49,7 +49,7 @@
<connection>scm:git:[email protected]:tarantool/cartridge-java-testcontainers.git</connection>
<developerConnection>scm:git:[email protected]:tarantool/cartridge-java-testcontainers.git</developerConnection>
<url>http://github.com/tarantool/cartridge-java-testcontainers/tree/master</url>
<tag>v0.5.4</tag>
<tag>v0.6.0</tag>
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't change it. Maven will change in release phase

@iDneprov iDneprov force-pushed the gh-69 branch 4 times, most recently from 71ec0bc to cbdf777 Compare May 29, 2023 15:42
Copy link
Collaborator

@akudiyar akudiyar left a comment

Choose a reason for hiding this comment

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

LGTM overall, I have few nitpicks though

@@ -1,12 +1,15 @@
package org.testcontainers.containers;

import java.util.Arrays;
import org.jetbrains.annotations.NotNull;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please do not use unnecessary imports for such third-party types

Container.ExecResult result = executeScript(scriptResourcePath, sslIsActive, keyFile, certFile);

if (result.getExitCode() != 0) {
throw new IllegalStateException(String.format("Executed script %s with exit code %d," +
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest making these command string templates constant variables


List<?> result = container.executeCommand("return profile_get(...)", 1).get();
ArrayList result = container.executeCommandDecoded("return profile_get(1)");
Copy link
Collaborator

Choose a reason for hiding this comment

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

The linter and compiler most likely show warnings for this place. ArrayList<?> or ArrayList<Object> are more approriate. ArrayList is an old form from Java 4 that is long prohibited but exists for compatibility

@iDneprov
Copy link
Contributor Author

Now TarantoolCartridgeBootstrapFromLuaWithFixedPortsTestdoes not start testcontainer

@iDneprov iDneprov force-pushed the gh-69 branch 6 times, most recently from f7ebd35 to a4b81d9 Compare May 30, 2023 17:04
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.*;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please do not use star imports (set up your IDE to not change this for, say, 100 import lines)

TarantoolClientBuilder clientBuilder) {
super(TarantoolContainerImageHelper.getImage(tarantoolImageParams));
clientHelper = new TarantoolContainerClientHelper(this, clientBuilder);
clientHelper = new TarantoolContainerClientHelper(this, "/sdk/tarantoolctl");
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be a constant at least, but better that should be either an env variable or the executable should be in the classpath so no explicit path is specified. DO not leave such hardcode, that will not work for all environments

@@ -39,6 +37,9 @@ public class TarantoolContainer extends GenericContainer<TarantoolContainer>
private String password = API_PASSWORD;
private String host = DEFAULT_HOST;
private Integer port = DEFAULT_PORT;
private Boolean sslIsActive = false;
private String keyFile = "";
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this should be a default path or name, shouldn't it?

.withRetryingByNumberOfAttempts(15,
TarantoolRequestRetryPolicies.retryNetworkErrors(),
b -> b.withDelay(100));
this.tarantoolctlPath = "tarantoolctl";
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest using an environment variable with default value here


String bashCommand;
if (keyFile != "" && certFile != "") {
bashCommand = String.format("echo \"print(require('yaml').encode(require('net.box').connect({ uri='%s:%d', " +
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be a constant., not an inline string. Also, we may use more proper script formatting for easier reading with backslashes or plus signs.

The same for the subsequent lines


List<?> result = container.executeCommand("return profile_get(...)", 1).get();
ArrayList<?> result = container.executeCommandDecoded("return profile_get(1)");
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't get why we need a more specific type here. Do we use any ArrayList methods or properties? Is ArrayList always guaranteed as a result (as I see it is a generic parameter so it seems not)?

@iDneprov iDneprov force-pushed the gh-69 branch 2 times, most recently from 6e052f8 to 67b4481 Compare June 2, 2023 15:48
@iDneprov iDneprov requested review from akudiyar and ArtDu June 2, 2023 15:49
@iDneprov
Copy link
Contributor Author

iDneprov commented Jun 2, 2023

SSL and mTLS support will be added in #75

@iDneprov iDneprov force-pushed the gh-69 branch 2 times, most recently from 63b2277 to 13f838b Compare June 5, 2023 11:27
@iDneprov
Copy link
Contributor Author

iDneprov commented Jun 5, 2023

@ArtDu, @akudiyar, guys, this RP is ready for review.

@iDneprov
Copy link
Contributor Author

iDneprov commented Jun 7, 2023

@akudiyar, hi! We are planning to merge this PR this week. Will you have time to watch it again?

Copy link
Collaborator

@akudiyar akudiyar left a comment

Choose a reason for hiding this comment

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

It seems that we are putting too many details to the changelog. These details can be read from the git history. Leaving internal changes that do not affect customers does not make sense, and it's better for readability to shorten several small changes related to the same feature to one line that describes the meaning of the changes.

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
pom.xml Outdated
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.28</version>
<scope>provided</scope>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please limit this import to the test scope

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use it in SslContext class, not in the test scope.
Why you do not recommend using lombok in other scopes?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Using it for a single class with 2 fields and in a library code needs additional justification. We've just removed the driver dependency (which is a good move), why are we adding to the library level a new dependency that is normally used on application level?

@@ -189,6 +191,22 @@ public TarantoolCartridgeContainer(String dockerFile, String buildImageName, Str
this(buildImage(dockerFile, buildImageName, buildArgs), instancesFile, topologyConfigurationFile, buildArgs);
}

// todo add SSL and mTLS cartridge test
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's not leave any commented code in the repo. We have git and branches for not-ready changes.

@@ -251,6 +269,20 @@ private static ImageFromDockerfile buildImage(String dockerFile, String buildIma
"cartridge" : buildArgs.get("CARTRIDGE_SRC_DIR"));
}

// todo add SSL and mTLS cartridge test
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's not leave any commented code in the repo. We have git and branches for not-ready changes.

@akudiyar
Copy link
Collaborator

akudiyar commented Jun 9, 2023

A side note: commits named like "Fix someone's comments" or "Update filename" are not useful for the git history. They need either to be squashed or re-formulated in a way that the message describes what exact changes are made to the code (examples: "rename variable", "pull code literals to constants", "remove/add dependency XXX" etc.)

Copy link
Contributor

@dkasimovskiy dkasimovskiy left a comment

Choose a reason for hiding this comment

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

Fix changelog, please.

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@iDneprov iDneprov requested a review from dkasimovskiy June 9, 2023 15:03
dkasimovskiy
dkasimovskiy previously approved these changes Jun 9, 2023
@iDneprov
Copy link
Contributor Author

A side note: commits named like "Fix someone's comments" or "Update filename" are not useful for the git history.

All commits will be squashed into one before the changes are merged into master. I try not to merge them during reviews to make it easier to keep track of requested changes.

If everything looks good for you, just approve changes, and I'll use "Squash and merge" button.

@@ -0,0 +1,62 @@
package org.testcontainers.containers.Enterprise;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
package org.testcontainers.containers.Enterprise;
package org.testcontainers.containers.enterprise;

Comment on lines 103 to 104
// No SSL
if (sslContext == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this type of comment code style is more appropriate in this case

Suggested change
// No SSL
if (sslContext == null) {
if (sslContext == null) { // No SSL

Comment on lines 110 to 111
// mTLS
} else if (sslContext.getKeyFile() != null && sslContext.getCertFile() != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// mTLS
} else if (sslContext.getKeyFile() != null && sslContext.getCertFile() != null) {
} else if (sslContext.getKeyFile() != null && sslContext.getCertFile() != null) { // mTLS

Comment on lines 118 to 119
// SSL
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// SSL
} else {
} else { // SSL

ArtDu
ArtDu previously approved these changes Jun 14, 2023
Copy link
Contributor

@dkasimovskiy dkasimovskiy left a comment

Choose a reason for hiding this comment

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

Есть небольшие замечания.
В остальном, можно мержить.

@@ -213,6 +167,20 @@ public TarantoolContainer withPassword(String password) {
return this;
}


/**
* Specify SSL as connection transport. And path to key and cert files inside your container for mTLS connection
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Specify SSL as connection transport. And path to key and cert files inside your container for mTLS connection
* Specify SSL as connection transport. Add path to key and cert files inside your container for mTLS connection

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I meant, specify transport and path.

);
final Map<String, String> buildArgs = new HashMap<>();
buildArgs.put("DOWNLOAD_SDK_URI", System.getenv("DOWNLOAD_SDK_URI"));
buildArgs.put("SDK_VERSION", "tarantool-enterprise-sdk-nogc64-2.10.6-0-r557.linux.x86_64");
Copy link
Contributor

Choose a reason for hiding this comment

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

Я бы вынес версию SDK в константу или settings.

@iDneprov iDneprov force-pushed the gh-69 branch 5 times, most recently from 0947346 to 7e6d389 Compare June 16, 2023 10:21
- [breaking change] Remove io.tarantool.cartridge-driver dependency
- [breaking change] Update executeScript and executeCommand methods to execute code viva execInContainer
  (now it returns yaml string in Container.ExecResult not CompletableFuture)
- Add executeScriptDecoded and executeCommandDecoded methods to return parsed yaml not string.
- Add SslContext class
- Add withSslContext method to TarantoolContainer and TarantoolCartridgeContainer.
- Update org.yaml.snakeyaml to 2.0 version.

Closes #69
@ArtDu ArtDu merged commit 211db68 into master Jun 16, 2023
@ArtDu ArtDu deleted the gh-69 branch June 16, 2023 10:37
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.

Remove cartridge-java from dependencies
4 participants