Skip to content

Conversation

bullet-tooth
Copy link
Contributor

Overview


See: https://jira.bf.local/browse/ECR-4041

Definition of Done

  • There are no TODOs left in the code
  • Change is covered by automated tests
  • The coding guidelines are followed
  • Public API has Javadoc
  • Method preconditions are checked and documented in the Javadoc of the method
  • Changelog is updated if needed (in case of notable or breaking changes)
  • The continuous integration build passes

@bullet-tooth
Copy link
Contributor Author

re-created from #1341

@bullet-tooth bullet-tooth added work-in-progress 👷‍♂️ Do not expect reviewers to provide any feedback on WIP PRs — please ask for it explicitly! and removed work-in-progress 👷‍♂️ Do not expect reviewers to provide any feedback on WIP PRs — please ask for it explicitly! labels Jan 8, 2020
Copy link
Contributor

@dmitry-timofeev dmitry-timofeev left a comment

Choose a reason for hiding this comment

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

It must be WIP — some code isn't even included (e.g., JavaArtifactNames.checkPluginArtifact).

try {
JavaArtifactNames.checkArtifactName(pluginId);
return ServiceArtifactId.newJavaId(pluginId);
String[] result = JavaArtifactNames.checkPluginArtifact(pluginId);
Copy link
Contributor

Choose a reason for hiding this comment

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

The task description explicitly requests that pluginId is made equal to Exonum artifact id. https://jira.bf.local/browse/ECR-4041

@bullet-tooth bullet-tooth added the work-in-progress 👷‍♂️ Do not expect reviewers to provide any feedback on WIP PRs — please ask for it explicitly! label Jan 9, 2020
void deployArtifact(String name, byte[] deploySpec) throws ServiceLoadingException {
DeployArguments deployArguments = parseDeployArgs(name, deploySpec);
void deployArtifact(byte[] artifactId, byte[] deploySpec) throws ServiceLoadingException {
ArtifactId artifact = parseArtifact(artifactId);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

do we need to check here that artifact.runtimeId is java runtime?

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe it is surely Core's responsibility

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say the core responsibility is to pass Java artifact ids only 🙃 But the check is redundant — Java Runtime loads only Java artifacts; if you pass non-Java artifact id later, it just won't be found.

@bullet-tooth bullet-tooth removed the work-in-progress 👷‍♂️ Do not expect reviewers to provide any feedback on WIP PRs — please ask for it explicitly! label Jan 9, 2020
`IllegalArgumentException`.
- Transaction index in block type changed from `long` to `int`. (#1348)
- Extracted artifact version to the separate field from the artifact name.
Artifact name format is `groupId/artifactId` now. (#1349)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd also specify the new full pluginId format, as it has also changed.

import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

class JavaArtifactNamesTest {
Copy link
Contributor

Choose a reason for hiding this comment

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

These tests no longer seem to have anything to do with artifact names, hence I suggest to rename the class and methods.

return serviceDefinition;
}

private static ServiceArtifactId extractServiceId(String pluginId)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shan't we keep it to

  1. Produce a more detailed error message,
  2. Possibly, check that rid is 'Java'?

JavaArtifactNames.checkNoForbiddenChars(serviceArtifactId);
String[] coordinates = serviceArtifactId.split(DELIMITER, KEEP_EMPTY);
checkArgument(coordinates.length == 3,
"Invalid artifact id (%s), must have 'runtimeId:groupId/artifactId:version' format",
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say just 'runtimeId:serviceName:version' as we don't enforce groupId/artifactId

return serviceRuntime.isArtifactDeployed(serviceArtifact);
}

private static DeployArguments parseDeployArgs(String name, byte[] deploySpec) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Pass full ArtifactId to keep all components in the log?

String name = "com.acme/foo";
String version = "1.2.3";
ArtifactId artifact = ArtifactId.newBuilder()
.setName(name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Here and elsewhere: it does not set runtime id, which is unusual for core. I'd also consider extracting in a method (e.g., createArtifactIdMessage)

<attach>false</attach>
<archive>
<manifestEntries>
<Plugin-Id>${artifactName}</Plugin-Id>
Copy link
Contributor

Choose a reason for hiding this comment

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

(here and elsewhere in services) PluginId is not correct (must be rid:name:version) — see the task desc.

</argLine>
<systemPropertyVariables>
<it.artifactFilename>${artifactFilename}.jar</it.artifactFilename>
<it.artifactId>${artifactName}</it.artifactId>
Copy link
Contributor

Choose a reason for hiding this comment

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

It clashes with the standard project.artifactId, I suggest some other name (it.exonumArtifactId?)

<systemPropertyVariables>
<it.artifactFilename>${artifactFilename}.jar</it.artifactFilename>
<it.artifactId>${artifactName}</it.artifactId>
<it.artifactVersion>${artifactVersion}</it.artifactVersion>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is version added? It does not seem to be needed — you must be able to take it from ^

@dmitry-timofeev
Copy link
Contributor

I noticed in several places ArtifactId-proto is converted to ServiceArtifactId (SRA & SRA tests). Would it make sense to add ServiceArtifactId#from(ArtifactId)?

* A service artifact identifier. It consists of the runtime id in which the service shall be
* deployed and the service artifact name. The name of Java artifacts usually contains the three
* coordinates identifying any Java artifact: groupId, artifactId and version.
* deployed and the service artifact name and the service artifact version.
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
* deployed and the service artifact name and the service artifact version.
* deployed, the service artifact name and its version.

Comment on lines 88 to 89
ServiceArtifactId javaArtifactId = ServiceArtifactId
.newJavaId(artifact.getName(), artifact.getVersion());
Copy link
Contributor

Choose a reason for hiding this comment

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

    ServiceArtifactId javaArtifactId = ServiceArtifactId.fromProto(artifact);

() -> ServiceArtifactId.parseFrom(artifactId));
}

private ArtifactId createArtifactIdMessage() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Make it a constant?

Protobufs are immutable, this method is not parameterized.

<Plugin-Id>${artifactName}</Plugin-Id>
<Plugin-Version>${project.version}</Plugin-Version>
<Plugin-Id>${artifactId}</Plugin-Id>
<Plugin-Version>${artifactVersion}</Plugin-Version>
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably, exonum.artifactId and same with version.

Comment on lines 580 to 584
return Runtime.ArtifactId.newBuilder()
.setRuntimeId(artifactId.getRuntimeId())
.setName(artifactId.getName())
.setVersion(artifactId.getVersion())
.build();
Copy link
Contributor

Choose a reason for hiding this comment

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

RE-ident.

Comment on lines 85 to 93
"1:too-few:components:1.0",
"1:com.acme:foo-service:0.1.0:extra-component",
" : : ",
"1:com acme:foo:1.0",
"1 :com.acme:foo:1.0",
"1:com.acme:foo service:1.0",
"1:com.acme:foo-service:1 0",
"1:com.acme:foo-service: 1.0",
"1:com.acme:foo-service:1.0 ",
Copy link
Contributor

Choose a reason for hiding this comment

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

The sources need to be updated to reflect the new string representation.
E.g., "too-few:components:1.0" — is fine in terms of components; the problem here is non-integral runtime id.
Or, several "com.acme:foo service:1.0" with spaces do not necessarily trigger that as they, again,
have an invalid runtime id.

It still doesn't make sense — each element in the test data must have a single problem, and otherwise be valid. FTFY:

      "",
      /* Too few components */
      "too-few-components",
      "1:too-few-components",
      /* Extra component */
      "1:foo-service:0.1.0:extra-component",
      /* All blanks */
      " : : ",
      /* Non-integral runtime id */
      "a:com.acme/foo:1.0",
      /* Spaces in runtime id */
      "1 :com.acme/foo:1.0",
      /* Spaces in name */
      "1:com.acme foo:1.0",
      "1:com.acme/fo o:1.0",
      /* Spaces in version */
      "1:com.acme:foo: 1.0",
      "1:com.acme/foo:1.0 ",
      "1:com.acme:foo:1 0",

new ServiceArtifactBuilder()
.setPluginId(serviceArtifactId.getName())
.setPluginId(serviceArtifactId.toString())
.setPluginVersion(serviceArtifactVersion)
Copy link
Contributor

Choose a reason for hiding this comment

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

This method no longer needs a version — it can pull it from SAId.

@dmitry-timofeev dmitry-timofeev merged commit 7b55c6e into new-protos-base Jan 13, 2020
@dmitry-timofeev dmitry-timofeev deleted the ecr-4041-new branch January 13, 2020 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants