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

run SB tests from cli #708

Merged
merged 9 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/data/nav.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
items:
- title: Installing the Galasa CLI
path: /docs/cli-command-reference/installing-cli-tool
- title: Galasa CLI commands
path: /docs/cli-command-reference/cli-command-reference-about
- title: Initialising your local environment
path: /docs/initialising-home-folder
- title: Creating a project using the CLI
Expand All @@ -47,6 +49,10 @@
path: /docs/cli-command-reference/cli-runs-local-debug
- title: Exploring Galasa SimBank using the CLI
path: /docs/cli-command-reference/simbank-cli
- title: Running the SimBank tests using the CLI
path: /docs/running-simbank-tests-cli
- title: Viewing test results locally
path: /docs/cli-command-reference/viewing-test-results-cli
- title: Getting started using Eclipse
path: /docs/getting-started/
items:
Expand All @@ -58,8 +64,12 @@
path: /docs/getting-started/simbank
- title: Creating a project using Eclipse
path: /docs/running-simbank-tests/setting-up-galasa-project-eclipse
- title: Running the supplied SimBank tests
path: /docs/running-simbank-tests
- title: Running the SimBank tests using Eclipse
path: /docs/running-simbank-tests-eclipse
- title: Viewing test results locally
path: /docs/running-simbank-tests/viewing-test-results
- title: Exploring the supplied SimBank tests
path: /docs/exploring-simbank-tests
items:
- title: The SimBank IVT
path: /docs/running-simbank-tests/simbank-IVT
Expand All @@ -73,8 +83,6 @@
path: /docs/running-simbank-tests/web-app-integration-test
- title: Writing your own SimBank test
path: /docs/running-simbank-tests/writing-a-simbank-test
- title: Viewing test results
path: /docs/running-simbank-tests/viewing-test-results
- title: Writing your own independent Galasa tests
path: /docs/writing-own-tests
items:
Expand All @@ -84,8 +92,6 @@
path: /docs/writing-own-tests/running-test-modes
- title: Testing across environments
path: /docs/writing-own-tests/binding-tests
- title: Test streams
path: /docs/writing-own-tests/test-streams
- title: Key principles for writing tests
path: /docs/writing-own-tests/key-principles
- title: The Galasa Ecosystem
Expand All @@ -95,6 +101,8 @@
path: /docs/ecosystem/architecture
- title: Installing the Ecosystem on Kubernetes
path: /docs/ecosystem/installing/k8s
- title: Test streams
path: /docs/writing-own-tests/test-streams
- title: Managing integrated test runs
path: /docs/ecosystem/cps
- title: Selecting tests to run in the Ecosystem
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
path: "/docs/cli-command-reference/cli-command-reference-about"
title: "Galasa CLI commands"
---

Galasa CLI commands start with `galasactl`. Example commands are provided for running on Mac or Unix, and Windows Powershell. The Windows Powershell uses the backtick (`) for line continuation characters. If you are using Windows command-shell, the line continuation character is the caret (^).

You can view the Galasa CLI command syntax, including parameter descriptions, in the <a href=https://github.com/galasa-dev/cli/blob/main/docs/generated/galasactl.md target="_blank"> cli repository</a> in GitHub.


## Getting help

Once you have installed the Galasa CLI, you can use the following command to get more information about the command and command options, including default values.

```
galasactl --help
```

Use the `--log` option to send logging information to a file. Any folder that is referenced must exist. Existing files are overwritten. Specify `-` to log to `stderr`. The default is no logging.

```
galasactl --log <logFilePath>
```

## Errors

You can view a list of error messages that can be generated by the galasactl tool in the <a href="https://github.com/galasa-dev/cli/blob/main/docs/generated/errors-list.md" target="_blank"> Galasa cli repository</a> in GitHub.


## Known limitations

Go programs can sometimes struggle to resolve DNS names, especially when a working over a virtual private network (VPN). In such situations, you might notice that a bootstrap file cannot be found with galasactl, but can be found by a desktop browser, or curl command. In such situations you can manually add the host detail to the `/etc/hosts` file, to avoid DNS being involved in the resolution mechanism.



## Next steps

To install Galasa for using in the command line, follow the instructions in the [Installing the Galasa CLI](/docs/cli-command-reference/installing-cli-tool) documentation.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Read on to understand more about the prerequisites that you need to install so t




## Next steps

To install Galasa for using in the command line, follow the instructions in the [Installing the Galasa CLI](/docs/cli-command-reference/installing-cli-tool) documentation.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
path: "/docs/exploring-simbank-tests"
title: "Exploring the supplied SimBank tests"
---

Galasa SimBank comes with a selection of prepared Galasa tests. Explore the SimBank IVT test and the other SimBank tests in the following sections. Follow the flow of logic in these classes and understand more about the Java that is used to create them, including how to use Galasa annotations and review documented test methods.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,86 @@ On Windows (Powershell)

You can now run the Galasa CLI too from any directory in your file system without having to specify the absolute path.

## Installing Java

Install a Java version 11 JDK or later. We do not currently support Java 17 or later. The following example uses Homebrew to install Java version 11 on a MacOS.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a link to Homebrew could be helpful


1. Install Java version 11 JDK using HomeBrew by running the following command in your terminal:
```
brew install openjdk@11
```
2. Set the JAVA_HOME environment variable to reference the JVM in which you want the test to run. To avoid setting this on every terminal, add the following information to your shell’s initialization file:
```
export JAVA_HOME=/path/to/your/jdk/Contents/Home
```
where `/path/to/your/jdk` is you JDK path.
You can find your JDK path by running the `which java` command in your terminal.



## Installing Maven

Install Maven 3.8 or later. The following example uses Homebrew:

1. Run the following command to install Maven:
```
brew update
brew install maven
```
2. Add the follwing information to your `~/.m2/settings.xml` file:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"follwing" typo.

Also, is this manual step required? It seems to have been added automatically to my settings file.

```
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<pluginGroups>
<pluginGroup>dev.galasa</pluginGroup>
</pluginGroups>

<profiles>
<profile>
<id>galasa</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>maven.central</id>
<url>https://repo.maven.apache.org/maven2/</url>
</repository>
<!-- To use the bleeding edge version of galasa, use the development obr
<repository>
<id>galasa.repo</id>
<url>https://development.galasa.dev/main/maven-repo/obr</url>
</repository>
-->
</repositories>
<pluginRepositories>
<pluginRepository>
<id>maven.central</id>
<url>https://repo.maven.apache.org/maven2/</url>
</pluginRepository>
<!-- To use the bleeding edge version of galasa, use the development obr
<pluginRepository>
<id>galasa.repo</id>
<url>https://development.galasa.dev/main/maven-repo/obr</url>
</pluginRepository>
-->
</pluginRepositories>
</profile>
</profiles>
</settings>
```
This information tells Maven where to find some custom Maven plug-in tools that are used by the build.


## Installing Gradle

1. Install <a href="https://gradle.org/install/" target="_blank"> Gradle</a> version 6.x. *Note:* Gradle version 7.x is not currently supported.
2. Put Gradle on your PATH by adding the following information to your shell’s initialization file:
```
export PATH="/opt/homebrew/opt/gradle@6/bin:$PATH"
gradle --version | grep "Gradle" | cut -f2 -d' '
```

## About Galasa CLI commands

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
---
path: "/docs/running-simbank-tests-cli"
title: "Running the SimBank tests using the CLI"
---

You can explore Galasa further with Galasa Simbank. Galasa Simbank is a simulated bank application that showcases Galasa's functionality within an application. Galasa SimBank comes with a selection of prepared Galasa tests:

- A basic Installation Verification Test (IVT) which logs on to SimBank - `SimBankIVT.java`.
- A test that updates an account using web services and examines the changes with 3270 screens - `BasicAccountCreditTest.java`.
- A test that uses a provisioned account object to perform the same test as `BasicAccountCreditTest.java` in an improved test design - `ProvisionedAccountCreditTests.java`.
- A test that exercises the z/OS Batch Manager by simulating the submission of a JCL job to add a number of accounts to the SimBank system - `BatchAccountsOpenTest.java`.

The following sections explain how to run the `SimBankIVT` test class by using the CLI. Make sure that you have installed the Galasa CLI tool and Java version 11 JDK, and set the JAVA_HOME environment variable, as described in the _Installing the Galasa CLI_ documentation.

## Updating the overrides and credentials property files
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this was the information I needed to get the tests running!



In order to run the Galasa SimBanks tests you need to add some configuration information in the `overrides.properties` and `credentials.properties` files that were created when you initialised your Galasa home folder by running the ```galasactl local init``` command. Complete the following steps to edit the files:


1. Edit a file called `overrides.properties` in your `.galasa` folder so that it contains the following configuration properties. Configuration properties held in this file is used by Galasa tests at runtime. You can change the value of the properties that are set in this file to enable you to run tests against different configurations without changing the test code. The following example configuration properties enable the provided Galasa SimBank tests to run on your machine:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"are used"?


```properties
zos.dse.tag.SIMBANK.imageid=SIMBANK
zos.dse.tag.SIMBANK.clusterid=SIMBANK

simbank.dse.instance.name=SIMBANK
simbank.instance.SIMBANK.zos.image=SIMBANK

zos.image.SIMBANK.ipv4.hostname=127.0.0.1
zos.image.SIMBANK.telnet.port=2023
zos.image.SIMBANK.webnet.port=2080
zos.image.SIMBANK.telnet.tls=false
zos.image.SIMBANK.credentials=SIMBANK

zosmf.image.SIMBANK.servers=SIMBANK
zosmf.server.SIMBANK.image=SIMBANK
zosmf.server.SIMBANK.port=2040
zosmf.server.SIMBANK.https=false
```
1. Edit a file called `credentials.properties` in your `.galasa` folder. Credentials that are held in this file are used by Galasa tests, for example to pass credentials to the application being tested. Storing values in this file avoids the need to hard-code credentials inside a test class, enabling the test to run in different environments without changing any test code. The following example properties enable the provided Galasa SimBank tests to run on your machine:

```properties
secure.credentials.SIMBANK.username=IBMUSER
secure.credentials.SIMBANK.password=SYS1
```

## Running the SimBank IVT test class by using the CLI

The SimBank tests are held in the <a href="https://github.com/galasa-dev/simplatform" target="_blank"> Galasa simplatform repository</a> in GitHub. To start running the tests you need to clone the repository, if you have not already done so. To find out how to clone the cli repository, follow the instruction in the `Launching SimBank` section in the [Exploring Galasa SimBank using the CLI]() documentation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing link for "Exploring Galasa SimBank using the CLI"


After cloning the repository, complete the following steps to run the SimBankIVT test that is provided with Galasa. The following example uses SimBank OBR version `0.25.0` and Galasa uber OBR version `0.30.0`.

You can find the version of the `dev.galasa.simbank.obr` that you are using by looking in the `pom.xml` file in the `dev.galasa.simbank.obr` folder. The `dev.galasa.uber.obr` is the OBR that contains all the bundles that are needed for Galasa to work (including the Managers, any required dependencies, the framework, etc). The version of the `dev.galasa.uber.obr` depends on which version of Galasa you have installed.


1. Open a terminal, navigate to your `simplatform` directory and run the `./build-locally.sh` script to build the code in both the simbank-tests and the simplaform-application directories.
2. In another terminal run the `./run-locally.sh --server` script to start the simbank server inside a inside a local JVM. In a few seconds, the Eclipse Console window responds with a series of initialization messages, which on Windows looks like:
```
2019-10-21 14:24:35 INFO dev.galasa.simplatform.main.Simplatform main Starting Simplatform ...
2019-10-21 14:24:35 INFO dev.galasa.simplatform.db.Database setDerbyHome Setting Derby home to C:\Users\<username>\AppData\Local\Temp\galasaSimplatform1440125512154994774
2019-10-21 14:24:36 INFO dev.galasa.simplatform.saf.SecurityAuthorizationFacility <init> Creating SAF service
2019-10-21 14:24:36 INFO dev.galasa.simplatform.application.Bank accountExists Checking if account: 123456789 exists
2019-10-21 14:24:36 INFO dev.galasa.simplatform.application.Bank accountExists Account doesn't exist
2019-10-21 14:24:36 INFO dev.galasa.simplatform.application.Bank openAccount Creating account: 123456789
2019-10-21 14:24:36 INFO dev.galasa.simplatform.application.Bank accountExists Checking if account: 987654321 exists
2019-10-21 14:24:36 INFO dev.galasa.simplatform.application.Bank accountExists Account doesn't exist
2019-10-21 14:24:36 INFO dev.galasa.simplatform.application.Bank openAccount Creating account: 987654321
2019-10-21 14:24:36 INFO dev.galasa.simplatform.saf.SecurityAuthorizationFacility addUser Added user: IBMUSER
2019-10-21 14:24:36 INFO dev.galasa.simplatform.main.Simplatform main Loading services...
2019-10-21 14:24:36 INFO dev.galasa.simplatform.listener.Listener <init> Loading service: dev.galasa.simplatform.listener.WebServiceListener listening on port: 2080
2019-10-21 14:24:36 INFO dev.galasa.simplatform.listener.Listener <init> Loading service: dev.galasa.simplatform.listener.TelnetServiceListener listening on port: 2023
2019-10-21 14:24:36 INFO dev.galasa.simplatform.main.Simplatform main ... services loaded
2019-10-21 14:24:36 INFO dev.galasa.simplatform.main.Simplatform main Starting Derby Network server....
2019-10-21 14:24:37 INFO dev.galasa.simplatform.main.Simplatform main ... Derby Network server started on port 2027
2019-10-21 14:24:37 INFO dev.galasa.simplatform.main.Simplatform main ... Simplatform started
```
If you are a Mac or Linux user, the messages will be almost identical.

3. In the terminal in which you ran the `./build-locally.sh` script, run the following command to run the SimBankIVT test:
On Mac or Unix:
```
galasactl runs submit local --log - \
--obr mvn:dev.galasa/dev.galasa.simbank.obr/0.25.0/obr \
--obr mvn:dev.galasa/dev.galasa.uber.obr/0.30.0/obr \
--class dev.galasa.simbank.tests/dev.galasa.simbank.tests.SimBankIVT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't get this to work. I tried a few different directories to see if that helped but no luck. It might be useful to include a reminder to run galasactl local init (really weirdly the command fails to run if the bootstrap.properties file is missing but then tries to create it when it does exist!)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now works with the "Updating the overrides and credentials property files" information! I did trip over running init again, and it might be useful to include an extract of the console output of a successful run just in case things don't go smoothly, e.g. like the run-locally.sh above.

```
On Windows (Powershell):
```
galasactl runs submit local --log - `
--obr mvn:dev.galasa/dev.galasa.simbank.obr/0.25.0/obr `
--obr mvn:dev.galasa/dev.galasa.uber.obr/0.30.0/obr `
--class dev.galasa.simbank.tests/dev.galasa.simbank.tests.SimBankIVT
```
where:

- `--log` specifies that debugging information is directed somewhere, and the `-` means that it is sent to the console (stderr).
- `--obr` The `--obr` parameter specifies the Maven co-ordinates of the OBR jar file, in the format `mvn:groupId/artifactId/version/classifier`. The first instance specifies the OBR where the CLI tool can find an OBR which refers to the bundle where the tests are stored. When running locally, all tests must exist in the OBR (or OBRs) that are passed to the tool. The second instance specifies the OBR containing the bundles that are needed for Galasa to work (for example, Galasa Managers, required dependencies, and the Galasa framework).
- `--class` specifies which test class to run. The string is in the format of `<osgi-bundle-id>/<fully-qualified-java-class>`.
4. The `SimBankIVT` test class runs, and the terminal displays its progress through to completion, with an Exit code of `0`.
5. View the results of the test runs in your terminal. You can also view results in the `run.log` file in the result archive store (RAS). 3270 terminal interactions can be viewed in the `artifacts` directory in the RAS. Find out more in the [Viewing test results locally](/docs/cli-command-reference/viewing-test-results-cli) documentation.

To run other SimBank tests, for example `BasicAccountCreditTest`, replace the test class name in the `--class` parameter. For example:

On Mac or Unix:

```
galasactl runs submit local --log - \
--obr mvn:dev.galasa/dev.galasa.simbank.obr/0.25.0/obr \
--obr mvn:dev.galasa/dev.galasa.uber.obr/0.30.0/obr \
--class dev.galasa.simbank.tests/dev.galasa.simbank.tests.BasicAccountCreditTest
```

On Windows (Powershell):

```
galasactl runs submit local --log - `
--obr mvn:dev.galasa/dev.galasa.simbank.obr/0.25.0/obr `
--obr mvn:dev.galasa/dev.galasa.uber.obr/0.30.0/obr `
--class dev.galasa.simbank.tests/dev.galasa.simbank.tests.BasicAccountCreditTest
```



## Next steps

Explore the SimBankIVT test and the other SimBank tests in the [Exploring the supplied SimBank tests](exploring-simbank-tests) sections. Follow the flow of logic in these classes and understand more about the Java that is used to create them, including how to use Galasa annotations and review documented test methods.
4 changes: 3 additions & 1 deletion src/markdown-pages/docs/cli-command-reference/simbank-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,6 @@ Press PF3 and once again browse the 123456789 account as described previously to

Note that SimBank also offers a web services interface on port 2080, and although it is not exercised in this topic, it *is* used by two of the provided tests - `BasicAccountCreditTest.java` and `ProvisionedAccountCreditTests.java`.

Having explored SimBank manually, it's a good time to run some or all of a small collection of automated tests that are provided with SimBank itself - to start, choose [Running the supplied SimBank tests](../running-simbank-tests) in the side-menu.

Having explored SimBank manually, it's a good time to run some or all of a small collection of automated tests that are provided with SimBank itself - to start, choose `Running the supplied SimBank tests`.

Loading
Loading