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

Please add support for SmtpSampler #191

Closed
IamKoN opened this issue Jun 15, 2023 · 14 comments
Closed

Please add support for SmtpSampler #191

IamKoN opened this issue Jun 15, 2023 · 14 comments

Comments

@IamKoN
Copy link

IamKoN commented Jun 15, 2023

Feature request for SmtpSampler support

Caused by: com.thoughtworks.xstream.converters.ConversionException:
---- Debugging information ----
cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message       : org.apache.jmeter.protocol.smtp.sampler.SmtpSampler
class               : org.apache.jorphan.collections.ListedHashTree
required-type       : org.apache.jorphan.collections.ListedHashTree
converter-type      : org.apache.jmeter.save.converters.HashTreeConverter

Thank you!

@rabelenda
Copy link
Contributor

Thank you for reporting this. I guess you are getting this while using jmx2dsl, right?

@rabelenda
Copy link
Contributor

Hello, since we haven't yet implemented specific logic for smtpsampler (requested here), and in consequence haven't added associated dependencies, the jmx2dsl command fails with the error you get.

Until we don't implement support for smtp sampler you might use as a workaround something like this:

java -cp jmdsl.jar:ApacheJMeter_mail-5.5.jar:mail-1.5.0-b01.jar us.abstracta.jmeter.javadsl.cli.Cli jmx2dsl smtp.jmx

Downloading the additional jars from here and here, or copying them (or even pointing in the command line to them) from JMeter lib folder.

With that you would get a functional, but not yet "optimized", conversion using existing support for wrappers.

I hope this helps.

Regards

@rabelenda
Copy link
Contributor

Closing this as SMTP sampelr has already been requested here.

@Shashy1508
Copy link

Thanks let me try thsi out.

@Brijendra9322
Copy link

Brijendra9322 commented Oct 18, 2023

GoogleTest.zip
Regarding above issue I have created Sample jmx file to launch as browser on Chrome using WebDriver Sampler.
And tried to convert with the command below which was suggested above but still get same error which @Shashy1508 is getting.

java -jar jmdsl.jar jmx2dsl GoogleTest.jmx

Uploaded the image test plan
GoogleTest_Jmeter

Error I am getting is :

Cause:
CannotResolveClassException: com.googlecode.jmeter.plugins.webdriver.config.ChromeDriverConfig

Detail:com.thoughtworks.xstream.converters.ConversionException:
---- Debugging information ----
cause-exception : com.thoughtworks.xstream.converters.ConversionException
cause-message :
first-jmeter-class : org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:66)
class : org.apache.jmeter.save.ScriptWrapper
required-type : org.apache.jmeter.save.ScriptWrapper
converter-type : org.apache.jmeter.save.ScriptWrapperConverter
path : /jmeterTestPlan/hashTree/hashTree/hashTree[3]/com.googlecode.jmeter.plugins.webdriver.config.ChromeDriverConfig
line number : 98
version : 1.21

And after tried with command suggested by you .

java -cp jmdsl.jar:ApacheJMeter_core-5.6.2.jar
:jorphan-5.6.2.jar us.abstracta.jmeter.javadsl.cli.Cli:jmeter-java-dsl-jmx2dsl-0.52.1.jar GoogleTest.jmx

Picked up JAVA_TOOL_OPTIONS: -Djava.net.preferIPv4Stack=true
Error: Could not find or load main class us.abstracta.jmeter.javadsl.cli.Cli:jmeter-java-dsl-jmx2dsl-0.52.1.jar
Caused by: java.lang.ClassNotFoundException: us.abstracta.jmeter.javadsl.cli.Cli:jmeter-java-dsl-jmx2dsl-0.52.1.jar
PS C:\Users\bps29\OneDrive - ACS\nnnxx-desktop.contentops.cloud.cas.org-08122022-20.01\Phoenix\JMeterDSL>

Uploaded the zipped jmx file.
Please have a look.

@rabelenda
Copy link
Contributor

Hello, thank you for sharing the JMX!

Downloading the selenium webdriver plugin zip from here, unzipping it, and running jmx2dsl like this:

java -cp "jmdsl.jar:lib/ext/*:lib/*" us.abstracta.jmeter.javadsl.cli.Cli jmx2dsl GoogleTest.jmx

I was able to get the following DSL:

///usr/bin/env jbang "$0" "$@" ; exit $?
/*
These commented lines make the class executable if you have jbang installed by making the file
executable (eg: chmod +x ./PerformanceTest.java) and just executing it with ./PerformanceTest.java
*/
//DEPS org.assertj:assertj-core:3.23.1
//DEPS org.junit.jupiter:junit-jupiter-engine:5.9.1
//DEPS org.junit.platform:junit-platform-launcher:1.9.1
//DEPS us.abstracta.jmeter:jmeter-java-dsl-wrapper:1.22
//DEPS us.abstracta.jmeter:jmeter-java-dsl:1.22

import static org.assertj.core.api.Assertions.assertThat;
import static us.abstracta.jmeter.javadsl.JmeterDsl.*;
import static us.abstracta.jmeter.javadsl.wrapper.WrapperJmeterDsl.*;

import com.googlecode.jmeter.plugins.webdriver.config.gui.ChromeDriverConfigGui;
import com.googlecode.jmeter.plugins.webdriver.sampler.gui.WebDriverSamplerGui;
import java.io.IOException;
import java.io.PrintWriter;
import org.apache.jmeter.visualizers.SummaryReport;
import org.junit.jupiter.api.Test;
import org.junit.platform.engine.discovery.DiscoverySelectors;
import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder;
import org.junit.platform.launcher.core.LauncherFactory;
import org.junit.platform.launcher.listeners.SummaryGeneratingListener;
import org.junit.platform.launcher.listeners.TestExecutionSummary;
import us.abstracta.jmeter.javadsl.core.TestPlanStats;

public class PerformanceTest {

  @Test
  public void test() throws IOException {
    TestPlanStats stats = testPlan()
        .tearDownOnlyAfterMainThreadsDone()
        .children(
          vars()
            .set("email", "\"//input[@type='email']\"")
            .set("password", "\"//input[@type='password']\"")
            .set("url", "'https://contenttech-platform-load.cas.org/'")
            .set("loginButton", "\"//span[text()=' Login ']\"")
            .set("userRoleLabel", "\"//*[@ng-reflect-place-holder='User Role']\"")
            .set("userRole", "\"//*[@title='ProjectManager']/div[text()='ProjectManager']\"")
            .set("exceptionQueue", "\"//*[text()=' Exception ']/span\"")
            .set("exceptionCount", "\"//span[text()='Exception']/following::div//a/div\"")
            .set("sampledCount", "\"//span[text()='Sampled']/following::div//a/div\"")
            .set("noMarkush", "\"//span[text()='No Markush']/following::div//a/div\"")
            .set("wc", "\"//span[text()='WC']/following::div//a/div\"")
            .set("RF", "\"//span[text()='WC']/following::div//a/div\"")
            .set("pendingApproval", "\"//span[text()='Pending Approval']/following::div//a/div\"")
            .set("profile", "\"//div[@class='profile-img ff-rb blue-background']\"")
            .set("reports", "\"//app-platform-menu/div/div[1]/app-platform-side-bar/div/ul/li[3]/div/div/img\"")
            .set("productionReport", "\"//li[text()='Production Report']\""),
          threadGroup(1, 1,
            testElement(new ChromeDriverConfigGui())
              .prop("ChromeDriverConfig.chromedriver_path", "chromedriver.exe")
              .prop("ChromeDriverConfig.android_enabled", false)
              .prop("ChromeDriverConfig.headless_enabled", false)
              .prop("ChromeDriverConfig.insecurecerts_enabled", false)
              .prop("ChromeDriverConfig.incognito_enabled", false)
              .prop("ChromeDriverConfig.no_sandbox_enabled", false)
              .prop("ChromeDriverConfig.disable_dev_shm_usage", false)
              .prop("WebDriverConfig.driver_path", "C:\\Users\\bps29\\Downloads\\chromedriver-win64\\chromedriver-win64\\chromedriver.exe"),
            testElement(new SummaryReport()),
            testElement("PT_01_GoogleSearch", new WebDriverSamplerGui())
              .prop("WebDriverSampler.script", "var pkg = JavaImporter(org.openqa.selenium);\n"
                + "WDS.sampleResult.sampleStart();\n"
                + "WDS.browser.get(\"https://google.com\");\n"
                + "var searchField = WDS.browser.findElement(pkg.By.xpath(\"//textarea[@title='Search']\"));\n"
                + "searchField.sendKeys(\"Selenium\");\n"
                + "java.lang.Thread.sleep(5000)")
              .prop("WebDriverSampler.language", "javascript"),
            resultsTreeVisualizer()
          )
        ).run();
    assertThat(stats.overall().errorsCount()).isEqualTo(0);
  }

  /*
   This method is only included to make the test class self-executable. You can remove it when
   executing tests with maven, gradle, or some other tool.
   */
  public static void main(String[] args) {
    SummaryGeneratingListener summaryListener = new SummaryGeneratingListener();
    LauncherFactory.create()
        .execute(LauncherDiscoveryRequestBuilder.request()
                .selectors(DiscoverySelectors.selectClass(PerformanceTest.class))
                .build(),
            summaryListener);
    TestExecutionSummary summary = summaryListener.getSummary();
    summary.printFailuresTo(new PrintWriter(System.err));
    System.exit(summary.getTotalFailureCount() > 0 ? 1 : 0);
  }

}

If you plan to run this in a project, make sure that the jmeter plugin is added as dependency to it. Eg:

<dependency>
    <groupId>kg.apc</groupId>
    <artifactId>jmeter-plugins-webdriver</artifactId>
    <version>4.10.0.0</version>
</dependency>

And also the jmeter dsl wrapper module:

<dependency>
    <groupId>us.abstracta.jmeter</groupId>
    <artifactId>jmeter-java-dsl-wrapper</artifactId>
    <version>1.22</version>
</dependency>

On top of the usual junit & jmeter dsl dependencies.

@Brijendra9322
Copy link

Brijendra9322 commented Oct 18, 2023

Thanks for the quick reply. but i am facing error while importing dependency.

kg.apc jmeter-plugins-webdriver 4.10.0.0

image

Also i have downloaded the selenium webdriver plugin zip and placed entire folder under project and ran the command which you shared .

java -cp "jmdsl.jar:lib/ext/:lib/" us.abstracta.jmeter.javadsl.cli.Cli jmx2dsl GoogleTest.jmx

After hitting this command i am getting error.
Picked up JAVA_TOOL_OPTIONS: -Djava.net.preferIPv4Stack=true
Error: Could not find or load main class us.abstracta.jmeter.javadsl.cli.Cli
Caused by: java.lang.ClassNotFoundException: us.abstracta.jmeter.javadsl.cli.Cli

i am sharing the project folder structure here so that you can tell if i am doing any mistake.
image

here lib folder is selenium webDriver plugin which i have placed.

@rabelenda
Copy link
Contributor

Hello,

The first issue might be related to maven respositories configuration, or you may need to tell intellij to update maven index (check the intellij tip you get when hovering the plugin version, or try to do a mvn clean compile and verify in the logs that the jars are properly downloaded). The dependency does exist in maven central repository: https://central.sonatype.com/artifact/kg.apc/jmeter-plugins-webdriver/overview

Regarding your second issue, that class is part of jmdsl.jar. Do you have jmdsl.jar, lib folder (extracted from plugin zip file), and jmx all in same folder? And are you running the command from that folder? The issue looks like it didn't load jmdsl.jar, so probably you are running the command from a folder which doesn't contain it. Are you using windows or linux/mac? If you are using windows then you need to replace colons (:) with semi colons (;) in classpath.

@Brijendra9322
Copy link

Thanks for your help. It worked :)
i am using windows machine. Thanks for guiding me in this.
java -cp "jmdsl.jar;lib/ext/;lib/" us.abstracta.jmeter.javadsl.cli.Cli jmx2dsl GoogleTest.jmx

@Brijendra9322
Copy link

Hello , while running converted DSL code into IntelliJ i am getting below error for SummaryReport.java.
Is there any exception needs to catch under the class. Below is the error and screenshot attached.

java.lang.ExceptionInInitializerError
at org.apache.jmeter.reporters.ResultCollector.(ResultCollector.java:167)
at org.apache.jmeter.reporters.ResultCollector.(ResultCollector.java:157)
at org.apache.jmeter.visualizers.gui.AbstractVisualizer.(AbstractVisualizer.java:119)
at org.apache.jmeter.visualizers.SummaryReport.(SummaryReport.java:172)
at org.example.UIPerformance.test(UIPerformance.java:70)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:728)
at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:156)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:147)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:86)
at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(InterceptingExecutableInvoker.java:103)
at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.lambda$invoke$0(InterceptingExecutableInvoker.java:93)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:92)
at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:86)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:218)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:214)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:139)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:69)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:170)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:154)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:90)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: java.lang.NullPointerException
at org.apache.jmeter.samplers.SampleSaveConfiguration.(SampleSaveConfiguration.java:287)

image

@rabelenda
Copy link
Contributor

Can you try adding this (with proper import) before test plan creation? new JmeterEnvironment();

@Brijendra9322
Copy link

Thanks it resolved the error . Now getting another error i am getting is. Any modification require ?
Error:
ERROR com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverSampler - You must be using an underlying instance of WebDriver that supports executing javascript

image

image

@rabelenda
Copy link
Contributor

That is a problem from the webdriver plugin. Was the JMX working fine and only de resulting DSL not working? Maybe you have to fix the path pointing to the chrome driver? or update the chrome driver? or maybe you are missing some dependency in pom.xml?

@Brijendra9322
Copy link

again started facing issue while conversion. getting same error as above. i have put all jmx, API under src folder. and i am running command from src folder itself. Please look attached image.
command : java -cp "jmdsl.jar;lib/ext/;lib/" us.abstracta.jmeter.javadsl.cli.Cli jmx2dsl SDPUIPerformanceSuite.jmx
Java version : 11

image

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

No branches or pull requests

4 participants