ECR-4041] Update artefact representation - #1349
Conversation
|
re-created from #1341 |
dmitry-timofeev
left a comment
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
The task description explicitly requests that pluginId is made equal to Exonum artifact id. https://jira.bf.local/browse/ECR-4041
893884d to
a0a7acc
Compare
9ce8e94 to
14e6ed9
Compare
| 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); |
There was a problem hiding this comment.
do we need to check here that artifact.runtimeId is java runtime?
There was a problem hiding this comment.
I believe it is surely Core's responsibility
There was a problem hiding this comment.
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.
| `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) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Shan't we keep it to
- Produce a more detailed error message,
- 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", |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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)
| @@ -194,7 +195,7 @@ | |||
| <archive> | |||
| <manifestEntries> | |||
| <Plugin-Id>${artifactName}</Plugin-Id> | |||
There was a problem hiding this comment.
(here and elsewhere in services) PluginId is not correct (must be rid:name:version) — see the task desc.
| @@ -224,6 +225,7 @@ | |||
| <systemPropertyVariables> | |||
| <it.artifactFilename>${artifactFilename}.jar</it.artifactFilename> | |||
| <it.artifactId>${artifactName}</it.artifactId> | |||
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
Why is version added? It does not seem to be needed — you must be able to take it from ^
|
I noticed in several places ArtifactId-proto is converted to ServiceArtifactId (SRA & SRA tests). Would it make sense to add |
| * 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. |
There was a problem hiding this comment.
| * deployed and the service artifact name and the service artifact version. | |
| * deployed, the service artifact name and its version. |
| ServiceArtifactId javaArtifactId = ServiceArtifactId | ||
| .newJavaId(artifact.getName(), artifact.getVersion()); |
There was a problem hiding this comment.
ServiceArtifactId javaArtifactId = ServiceArtifactId.fromProto(artifact);| () -> ServiceArtifactId.parseFrom(artifactId)); | ||
| } | ||
|
|
||
| private ArtifactId createArtifactIdMessage() { |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
Probably, exonum.artifactId and same with version.
| return Runtime.ArtifactId.newBuilder() | ||
| .setRuntimeId(artifactId.getRuntimeId()) | ||
| .setName(artifactId.getName()) | ||
| .setVersion(artifactId.getVersion()) | ||
| .build(); |
| "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 ", |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
This method no longer needs a version — it can pull it from SAId.
Overview
See: https://jira.bf.local/browse/ECR-4041
Definition of Done