-
Notifications
You must be signed in to change notification settings - Fork 30
ECR-4041] Update artefact representation #1349
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
Conversation
re-created from #1341 |
There was a problem hiding this 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); |
There was a problem hiding this comment.
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
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.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
exonum-java-binding/CHANGELOG.md
Outdated
`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.
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 { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
- Produce a more detailed error message,
- Possibly, check that rid is 'Java'?
exonum-java-binding/core/src/main/java/com/exonum/binding/core/runtime/ServiceArtifactId.java
Show resolved
Hide resolved
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.
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) { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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 ^
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* 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.
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() { |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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.
return Runtime.ArtifactId.newBuilder() | ||
.setRuntimeId(artifactId.getRuntimeId()) | ||
.setName(artifactId.getName()) | ||
.setVersion(artifactId.getVersion()) | ||
.build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RE-ident.
"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.
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) |
There was a problem hiding this comment.
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.
Overview
See: https://jira.bf.local/browse/ECR-4041
Definition of Done