You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by Antonio Gomes Rodrigues <ra...@gmail.com> on 2023/06/06 16:24:21 UTC

Need help to a PR

Hi all,

I have some time to work again in JMeter, unfortunately I haven't made code
for a long time. It's why I need help

I would like to add feature to import HAR file to gain productivity in
scripting step.

I have checked and it will not be too difficult by using lib like
https://github.com/sdstoehr/har-reader and refactor/share line code of
"curl import" feature.

1.
My first question is how to add a new library into JMeter?
I have added
api("com.github.sdstoehr:har-reader:2.2.1")
in src/bom-thirdparty/build.gradle.kts but it's not working (
import de.sstoehr.harreader.model.Har; don't work and I can't use the
library)

Anybody can help me?
Do you have a better choice library?

2.
Another question
Some feature in menu implements MenuCreator
Whereas another are in org/apache/jmeter/gui/util/JMeterMenuBar.java
What is the recommendation?

Thanks,
Antonio

Re: Need help to a PR

Posted by Antonio Gomes Rodrigues <ra...@gmail.com>.
Hi Vladimir,

I have take the same structure as your PR and now it works fine
I am working on it

Thanks to your help

Le ven. 9 juin 2023 à 23:20, Antonio Gomes Rodrigues <ra...@gmail.com> a
écrit :

> Hi Vladimir
>
> Thanks to your example, but I am still no familiar with gradle
>
> I think I don(t put the library (build.gradle.kts) in the right file
>
> I have put my java class in
> src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/gui/action/ParseHARAction.java
> and modify src/protocol/http/build.gradle.kts
>
> For code I have commit it in
> https://github.com/ra0077/jmeter/tree/Add_HAR_convertor
>
> Le jeu. 8 juin 2023 à 22:28, Vladimir Sitnikov <
> sitnikov.vladimir@gmail.com> a écrit :
>
>> >Any idea to solve this problem?
>>
>> It is hard to understand the reason for the failure without looking into
>> the code.
>> It would be great if you could file a draft pull request with your
>> changes.
>>
>> Here's how you could add har-reader module into JMeter:
>> https://github.com/apache/jmeter/pull/5976
>>
>> "import de.sstoehr.harreader.HarReader" works for me
>>
>> Vladimir
>>
>

Re: Need help to a PR

Posted by Antonio Gomes Rodrigues <ra...@gmail.com>.
Hi Vladimir

Thanks to your example, but I am still no familiar with gradle

I think I don(t put the library (build.gradle.kts) in the right file

I have put my java class in
src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/gui/action/ParseHARAction.java
and modify src/protocol/http/build.gradle.kts

For code I have commit it in
https://github.com/ra0077/jmeter/tree/Add_HAR_convertor

Le jeu. 8 juin 2023 à 22:28, Vladimir Sitnikov <si...@gmail.com>
a écrit :

> >Any idea to solve this problem?
>
> It is hard to understand the reason for the failure without looking into
> the code.
> It would be great if you could file a draft pull request with your changes.
>
> Here's how you could add har-reader module into JMeter:
> https://github.com/apache/jmeter/pull/5976
>
> "import de.sstoehr.harreader.HarReader" works for me
>
> Vladimir
>

Re: Need help to a PR

Posted by Vladimir Sitnikov <si...@gmail.com>.
>Any idea to solve this problem?

It is hard to understand the reason for the failure without looking into
the code.
It would be great if you could file a draft pull request with your changes.

Here's how you could add har-reader module into JMeter:
https://github.com/apache/jmeter/pull/5976

"import de.sstoehr.harreader.HarReader" works for me

Vladimir

Re: Need help to a PR

Posted by Antonio Gomes Rodrigues <ra...@gmail.com>.
Hi Vladimir,

Thanks a lot to your help and patience?
It help me a lot, but I have still a problem

I have add
implementation("de.sstoehr:har-reader")
in src/core/build.gradle.kts

Add
api("de.sstoehr:har-reader:2.2.1")
in src/bom-thirdparty/build.gradle.kts

Execute PchecksumUpdateAll

Add in org/apache/jmeter/protocol/http/gui/action/ParseHARAction.java a
Java class
I have made a gui
public class ParseHARAction extends AbstractAction implements MenuCreator,
ActionListener

It works fine
But I failed in step to use har-reader library

When I try to import lib
import de.sstoehr.harreader.HarReader;
import de.sstoehr.harreader.HarReaderException;
import de.sstoehr.harreader.model.Har;
import de.sstoehr.harreader.model.HarEntry;

It doesn't find

To be sure it's the right import I have checked it in
https://github.com/sdstoehr/har-reader/blob/main/src/test/java/de/sstoehr/harreader/HarReaderTest.java
and with chatGPT

Any idea to solve this problem?

Thanks
Antonio



Le mar. 6 juin 2023 à 21:28, Vladimir Sitnikov <si...@gmail.com>
a écrit :

> > DO I need to add a checksum?
>
> That is right, we require dependency verification.
>
> Here's a sample when I recently added a new dependency:
>
> https://github.com/apache/jmeter/commit/a2690e8a6d22420869eb89643c116901cc5c5bce
>
> Note that there were changes to checksum.xml, and the new pgp keys have
> been added as well to
> /cached-pgp-keys/ folder. Don't forget to add the added keys to your commit
> as well.
>
> ---
>
> In this case it would be reasonably safe to launch the build with
> -PchecksumUpdateAll.
> Then the checksum file will be updated automatically.
>
> Of course, it makes sense to doublecheck if
> ffcd6605daa43db4290eca4898e2d057e0d58dc6 matches
> the official signing key for the dependency.
> It should typically be printed on the official website of the dependency or
> at least in the github repository.
>
> See samples in
> https://github.com/junit-team/junit5/issues/2020#issuecomment-534117511
>
> Vladimir
>

Re: Need help to a PR

Posted by Vladimir Sitnikov <si...@gmail.com>.
> DO I need to add a checksum?

That is right, we require dependency verification.

Here's a sample when I recently added a new dependency:
https://github.com/apache/jmeter/commit/a2690e8a6d22420869eb89643c116901cc5c5bce

Note that there were changes to checksum.xml, and the new pgp keys have
been added as well to
/cached-pgp-keys/ folder. Don't forget to add the added keys to your commit
as well.

---

In this case it would be reasonably safe to launch the build with
-PchecksumUpdateAll.
Then the checksum file will be updated automatically.

Of course, it makes sense to doublecheck if
ffcd6605daa43db4290eca4898e2d057e0d58dc6 matches
the official signing key for the dependency.
It should typically be printed on the official website of the dependency or
at least in the github repository.

See samples in
https://github.com/junit-team/junit5/issues/2020#issuecomment-534117511

Vladimir

Re: Need help to a PR

Posted by Antonio Gomes Rodrigues <ra...@gmail.com>.
Hi Vladimir,

Thanks to you quick response

What do you mean by " it might be better to add src/har-importer module
rather than put it into src/core"

I have try your first solution without success

I have this error
FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':src:dist:populateLibs'.
> Could not resolve all task dependencies for configuration
':src:dist:runtimeClasspath'.
   > Could not find com.github.sdstoehr:har-reader:2.2.1.
     Searched in the following locations:
       -
https://repo.maven.apache.org/maven2/com/github/sdstoehr/har-reader/2.2.1/har-reader-2.2.1.pom
     If the artifact you are trying to retrieve can be found in the
repository but without metadata in 'Maven POM' format, you need to adjust
the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project :src:dist > project :src:bom-thirdparty
   > Could not find com.github.sdstoehr:har-reader:2.2.1.
     Searched in the following locations:
       -
https://repo.maven.apache.org/maven2/com/github/sdstoehr/har-reader/2.2.1/har-reader-2.2.1.pom
     If the artifact you are trying to retrieve can be found in the
repository but without metadata in 'Maven POM' format, you need to adjust
the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project :src:dist > project :src:core


I hev modified
implementation("com.github.sdstoehr:har-reader")
by
implementation("de.sstoehr:har-reader")

and
api("de.sstoehr:har-reader:2.2.1")

because in https://github.com/sdstoehr/har-reader he write

<dependency>
  <groupId>de.sstoehr</groupId>
  <artifactId>har-reader</artifactId>
  <version>2.2.1</version>
</dependency>

Now I have
FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':src:dist:populateLibs'.
> Checksum/PGP violations detected on resolving configuration
:src:dist:runtimeClasspath
    No trusted PGP keys are configured for group de.sstoehr:
      de.sstoehr:har-reader:2.2.1
(pgp=[ffcd6605daa43db4290eca4898e2d057e0d58dc6], sha512=[computation
skipped])

  There might be more checksum violations, however, current configuration
specifies the build to fail on the first violation.
  You might use the following properties:
    * -PchecksumIgnore temporary disables checksum-dependency-plugin (e.g.
to try new dependencies)
    * -PchecksumUpdate updates checksum.xml and it will fail after the
first violation so you can review the diff
    * -PchecksumUpdateAll (insecure) updates checksum.xml with all the new
discovered checksums
    * -PchecksumFailOn=build_finish (insecure) It will postpone the failure
till the build finish
  It will collect all the violations, however untrusted code might be
executed (e.g. from a plugin)
  You can find updated checksum.xml file at
D:\src\build\checksum\checksum.xml.
  You might add -PchecksumUpdate to update root checksum.xml file.

DO I need to add a checksum?

Regards
Antonio


Le mar. 6 juin 2023 à 18:50, Vladimir Sitnikov <si...@gmail.com>
a écrit :

> > I have added
> api("com.github.sdstoehr:har-reader:2.2.1")
> in src/bom-thirdparty/build.gradle.kts
>
> That’s right.
> You declare version in bom-thirdparty, and then you add a dependency
> without version.
> For instance, add implementation(“
> com.github.sdstoehr:har-reader”) to src/core/build.gradle.kts.
>
> However, you might need to depend on other modules (e.g. protocols:http),
> so it might be better to add src/har-importer module rather than put it
> into src/core
>
> I would suggest going with MenuCreator.
>
> Vladimir
> --
> Vladimir
>

Re: Need help to a PR

Posted by Vladimir Sitnikov <si...@gmail.com>.
> I have added
api("com.github.sdstoehr:har-reader:2.2.1")
in src/bom-thirdparty/build.gradle.kts

That’s right.
You declare version in bom-thirdparty, and then you add a dependency
without version.
For instance, add implementation(“
com.github.sdstoehr:har-reader”) to src/core/build.gradle.kts.

However, you might need to depend on other modules (e.g. protocols:http),
so it might be better to add src/har-importer module rather than put it
into src/core

I would suggest going with MenuCreator.

Vladimir
-- 
Vladimir