Skip to content

Commit

Permalink
wait conditions refactored, readme updated, directories organized (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
Baraujo25 authored Jan 15, 2020
1 parent e82e035 commit 3456181
Show file tree
Hide file tree
Showing 47 changed files with 335 additions and 236 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ People who usually work with these IBM servers interact with them, basically, by
The plugin adds four different elements to JMeter:

#### A Recording Controller (RTE-Recorder)
![alt text](docs/RecorderPanel.png "RTE Recorder")
![alt text](docs/recorder/recorder-panel.png "RTE Recorder")

##### Configuring the RTE Recorder
First all is necessary to add a template which is going to contain all the elements required to begin with recording.
Expand All @@ -25,19 +25,19 @@ Go to Files -> Templates -> and select _Recording RTE_

##### Usage of RTE Recorder

To start recording, the user should specify the _Server_, _Port_, _Protocol_, _Terminal Type_, _SSL Type_, _Timeout_ and _Timeout Threshold_. These configurations are the same ones detailed in [RTE-Config](#a-config-element-rte-config). Details about Timeout Threshold field and how the wait conditions works can be found [here](docs/wait-conditions-recording.md).
![alt_text](docs/RecordingFilledUp.png)
To start recording, the user should specify the _Server_, _Port_, _Protocol_, _Terminal Type_, _SSL Type_, _Timeout_ and _Timeout Threshold_. These configurations are the same ones detailed in [RTE-Config](#a-config-element-rte-config). Details about Timeout Threshold field and how the wait conditions works can be found [here](docs/recorder/terminal-emulator/wait-conditions/wait-conditions-recording.md).
![alt_text](docs/recorder/recording-filled-up.png)
> RTE recorder buttons purpose:
> - *Start*: This button allows the user to begin with the recording and to connect to the mainframe application through a terminal emulator. Additionally, after button is pressed, an RTE-Config and Connect Sampler will be added to the test plan.
> - *Stop*: This button allows the user to stop current recording. Once this button is pressed, the recording will be stopped and Disconnect Sampler will be added to the test plan followed by the closure of the terminal emulator.
> - *Restart*: This button is the equivalent to pressing stop and start buttons.
> - *Timeout Threshold*: This field will set the timeout which later on the [waits conditions ](docs/wait-conditions-recording.md)will use to set the proper time out for the conditions.
> - *Timeout Threshold*: This field will set the timeout which later on the [waits conditions ](docs/recorder/terminal-emulator/wait-conditions/wait-conditions-recording.md)will use to set the proper time out for the conditions.
Once everything is configured, the user proceeds to start the recording session, pressing START button. After the connection to the mainframe application is established (supposing configurations are right), the **[Terminal Emulator](/docs/terminal-emulator.md)** will show up.
Once everything is configured, the user proceeds to start the recording session, pressing START button. After the connection to the mainframe application is established (supposing configurations are right), the **[Terminal Emulator](/docs/recorder/terminal-emulator/terminal-emulator.md)** will show up.

![alt_text](docs/emulator-login.png)
![alt_text](docs/recorder/terminal-emulator/emulator-login.png)

>Click [here](/docs/terminal-emulator.md) to see all the information you must know about terminal emulator.
>Click [here](/docs/recorder/terminal-emulator/terminal-emulator.md) to see all the information you must know about terminal emulator.
Now we are able to interact with our client through RTE-Emulator. Every interaction will be automatically saved in samplers (_[check out everything about samplers ](#sampler-rte-sampler)_).
Once we have ended the flow that we want to record, we can easily close the terminal emulator or press STOP button to stop our recording.
Expand All @@ -49,7 +49,7 @@ Once we have ended the flow that we want to record, we can easily close the term

When a View Results Tree JMeter test element is included as a child of the RTE recorder, then all interactions between the Terminal Emulator and the mainframe application will be showed on the View Results Tree and allow for proper analysis and validation of all information sent and received from the mainframe application.

![alter_text](docs/View-Result-Tree.png)
![alter_text](docs/recorder/view-result-tree.png)

#### A Config Element (RTE Config)

Expand Down Expand Up @@ -96,10 +96,10 @@ All the "waiters" use a stable timeout value (in milliseconds) which specifies t
> Warning: both Stable Timeout and Silent Interval should be shorter than Timeout value, otherwise the sampler will always return a timeout error.
#### RTE-Extractor
![alt_text](docs/rte-extractor.png)
![alt_text](docs/extractor/rte-extractor.png)

RTE-Extractor is a post-processor which its main purpose is to extract positions from response headers to be used later as a JMeter variable.
> Check [here](/docs/rte-extractor.md) for more information.
> Check [here](/docs/extractor/rte-extractor.md) for more information.

### Example
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
31 changes: 31 additions & 0 deletions docs/recorder/terminal-emulator/terminal-emulator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Terminal Emulator
![alt_text](rte-recorder-emulator.png)

- Pressing ![alt_text](/src/main/resources/dark-theme/copy.png) you are able to copy from the emulator, also using the standard keyboard shortcuts.
- Pressing ![alt_text](/src/main/resources/dark-theme/paste.png) you are able to paste in cursor position on the emulator, also using standard shortcuts.
- You can select a screen area to be used as input field label, press ![alt_text](/src/main/resources/dark-theme/inputByLabel.png) and then set the input field text, to record a test plan that uses the provided label to locate the input field on the screen and fill the field with provided text.
> Input by label allows to find the field on the screen regardless of changes of field positioning, which makes recorded test plans more robust (than using default input by coord).
>[Here](#input-by-label-usage) is a small example of input by label usage.
- You can select a screen area to be used as wait for text, then press ![alt_text](/src/main/resources/dark-theme/waitForText.png) and a new *Text Wait Condition* will be added to your sampler.

>[Here](wait-conditions/wait-conditions-recording.md#text-wait-condition) is more information about wait for text, how it works and a little usage example.
- You can press assertion button ![alt_text](/src/main/resources/dark-theme/assertion.png) when you want to make sure that a part of the screen has appeared in the screen. This assertion has the same behaviour as JMeter Assertions. To assert for a part of the screen you just have to select a part of the screen and press the button. An assertion will be added to corresponding sampler.
>[Here](#recorder-screen-assertion-usage) is an example of usage.
- Clicking on ![alter_text](/src/main/resources/dark-theme/not-visible-credentials.png) / ![alter_text](/src/main/resources/dark-theme/visible-credentials.png) you will be able to show/hide credentials.

- If you click on the ![alter_text](/src/main/resources/dark-theme/help.png) icon in the emulator, a pop up window will be displayed with general help information on the emulator: shortcuts, explanation about indicators on the screen, etc.

- **Sample name:** As the label says, you can specify the name of the sample in current screen.

### Input By Label Usage

![alt_text](input-by-label-usage.gif)



### Recorder Screen Assertion Usage

![alt_text](assertion-usage.gif)
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ To begin with the explication of how Wait Conditions works in RTE-Recorder, lets

*Text wait*: It will wait until the text appears on the screen.

[Here](../README.md#waiters-usage) there is more information about Wait Conditions in general.
[Here](/README.md#waiters-usage) there is more information about Wait Conditions in general.


## Wait conditions recording resolution
Expand All @@ -18,7 +18,7 @@ Wait conditions recording resolution is currently determined by the following 4

**Case 2**: Consider now that you have received multiple keyboards status changes, so the keyboard has been unlocked and locked few/many times but the difference between those locks and unlocks is greater than **Stable Period**, then the plugin will add a Silent Wait Condition alongside a warning stating this behavior and a possible workaround in case the recorded behavior is not the expected one.

> [Here](../README.md#stable-period) for a description of stable period
> [Here](/README.md#stable-period) for a description of stable period
**Case 3**: In this case your keyboard state has been changed once or several times but now the difference between those status changes is lower than stable period and also the difference between last keyboard unlock and last event occurred (like attention keys, inputs, etc) is lower than Stable Period. Then a Sync Wait Condition will be added to that sampler.

Expand Down
File renamed without changes
File renamed without changes
31 changes: 0 additions & 31 deletions docs/terminal-emulator.md

This file was deleted.

14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
<groupId>com.blazemeter.jmeter</groupId>
<artifactId>jmeter-bzm-rte</artifactId>
<packaging>jar</packaging>
<version>2.2</version>
<version>2.2.1</version>
<name>RTEPlugin Sampler as JMeter plugin</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<jmeter.version>3.1</jmeter.version>
<jmeter.version>3.2</jmeter.version>
</properties>

<repositories>
Expand All @@ -24,23 +24,23 @@
</repositories>

<scm>
<connection>scm:git:git@github.com:Blazemeter/RTEPlugin.git</connection>
<developerConnection>scm:git:git@github.com:Blazemeter/RTEPlugin.git
<connection>scm:git:git@gitlab.abstracta.us:BZ-plugins/jmeter-rte-plugin.git</connection>
<developerConnection>scm:git:git@gitlab.abstracta.us:BZ-plugins/jmeter-rte-plugin.git
</developerConnection>
<url>https://github.com/Blazemeter/RTEPlugin</url>
<url>http://gitlab.abstracta.us/BZ-plugins/jmeter-rte-plugin</url>
</scm>

<dependencies>

<dependency>
<groupId>com.github.blazemeter</groupId>
<artifactId>xtn5250</artifactId>
<version>3.1</version>
<version>3.2</version>
</dependency>
<dependency>
<groupId>com.github.blazemeter</groupId>
<artifactId>dm3270</artifactId>
<version>0.11.1-lib</version>
<version>0.12.1-lib</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public abstract class ConditionWaiter<T extends WaitCondition> implements ExceptionListener {

private static final Logger LOG = LoggerFactory.getLogger(ConditionWaiter.class);

protected final T condition;
private ExceptionHandler exceptionHandler;
protected boolean lastConditionState;
private final CountDownLatch lock = new CountDownLatch(1);
private final ScheduledExecutorService stableTimeoutExecutor;
private ExceptionHandler exceptionHandler;
private ScheduledFuture stableTimeoutTask;
private boolean ended;

Expand All @@ -26,7 +31,7 @@ public ConditionWaiter(T condition, ScheduledExecutorService stableTimeoutExecut
exceptionHandler.addListener(this);
}

protected synchronized void startStablePeriod() {
private synchronized void startStablePeriod() {
if (ended) {
return;
}
Expand All @@ -35,7 +40,7 @@ protected synchronized void startStablePeriod() {
.schedule(lock::countDown, condition.getStableTimeoutMillis(), TimeUnit.MILLISECONDS);
}

protected synchronized void endStablePeriod() {
private synchronized void endStablePeriod() {
if (stableTimeoutTask != null) {
stableTimeoutTask.cancel(false);
}
Expand Down Expand Up @@ -72,4 +77,27 @@ public void stop() {
exceptionHandler.removeListener(this);
}

protected void updateConditionState(String event) {
boolean currentConditionState = getCurrentConditionState();
if (lastConditionState != currentConditionState) {
lastConditionState = currentConditionState;
if (currentConditionState) {
LOG.debug("Stable period restarted because event {} arrived", event);
startStablePeriod();
} else {
LOG.debug("Stable period cancelled. Since {} arrived condition does not meet", event);
endStablePeriod();
}
}
}

protected abstract boolean getCurrentConditionState();

protected void initialVerificationOfCondition() {
if (getCurrentConditionState()) {
LOG.debug("Start stable period since condition was already met");
startStablePeriod();
lastConditionState = true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* {@link WaitCondition} to wait for the cursor to be visible on the desired position.
*/
public class CursorWaitCondition extends WaitCondition {

private final Position position;

public CursorWaitCondition(Position position, long timeoutMillis, long stableTimeoutMillis) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
* {@link WaitCondition} to wait for certain text to be in terminal screen.
*/
public class TextWaitCondition extends WaitCondition {

private static final Logger LOG = LoggerFactory.getLogger(TextWaitCondition.class);

private final Pattern regex;
private final PatternMatcher matcher;
private final Area searchArea;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public class RTEExtractor extends AbstractScopedTestElement implements PostProce
private static final String VARIABLE_PREFIX_PROPERTY = "RTEExtractor.variablePrefix";
private static final String POSITION_TYPE_PROPERTY = "RTEExtractor.positionType";
private static final PositionType DEFAULT_POSITION_TYPE = PositionType.CURSOR_POSITION;

private static final int UNSPECIFIED_COORDS = 1;
private static final int UNSPECIFIED_OFFSET = 0;
private JMeterContext context;

public RTEExtractor() {
Expand Down Expand Up @@ -101,7 +102,7 @@ private Position extractFieldPosition(String responseHeaders, String requestHead
}

private int getOffsetAsInt() {
return Integer.parseInt(getOffset());
return getOffset().isEmpty() ? UNSPECIFIED_OFFSET : Integer.parseInt(getOffset());
}

private boolean isGivenFieldPositionValid(String requestHeaders) {
Expand Down Expand Up @@ -149,35 +150,35 @@ private String extractTerminalType(String requestHeaders) {
}

private int getRowAsInt() {
return Integer.parseInt(getRow());
return getRow().isEmpty() ? UNSPECIFIED_COORDS : Integer.parseInt(getRow());
}

private int getColumnAsInt() {
return Integer.parseInt(getColumn());
return getColumn().isEmpty() ? UNSPECIFIED_COORDS : Integer.parseInt(getColumn());
}

public String getRow() {
return getPropertyAsString(ROW_PROPERTY);
}

public void setRow(String row) {
setProperty(ROW_PROPERTY, row);
setProperty(ROW_PROPERTY, row, "1");
}

public String getColumn() {
return getPropertyAsString(COLUMN_PROPERTY);
}

public void setColumn(String column) {
setProperty(COLUMN_PROPERTY, column);
setProperty(COLUMN_PROPERTY, column, "1");
}

public String getOffset() {
return getPropertyAsString(OFFSET_PROPERTY);
}

public void setOffset(String offset) {
setProperty(OFFSET_PROPERTY, offset);
setProperty(OFFSET_PROPERTY, offset, "0");
}

public String getVariablePrefix() {
Expand Down
Loading

0 comments on commit 3456181

Please sign in to comment.