Skip to content

Alfresco/alfresco-tas-ftp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

94 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

in progress

🐾 Back to TAS Master Documentation


Table of Contents

Synopsis

TAS( Test Automation System)- FTP is the project that handles the automated tests related only to FTP protocol integrated with Alfresco One Alfresco FTP protocol.

It is based on Apache Maven, compatible with major IDEs and is using also Spring capabilities for dependency injection.

As a high level overview, this project makes use of the following functionality useful in automation testing as:

  • reading/defining test environment settings (e.g. alfresco server details, authentication, etc.)
  • managing resource (i.e. creating files and folders)
  • test data generators (for site, users, content, etc)
  • helpers (i.e. randomizers, test environment information)
  • test logging generated on runtime and test reporting capabilities
  • test management tool integration (at this point we support integration with Test Rail (v5.2.1)
  • health checks (verify if server is reachable, if server is online)
  • generic Internal-DSL (Domain Specific Language)

Using Nexus -Release Repository, everyone will be able to use individual interfaces in their projects by extending the automation core functionalities.

Back to Top ^

Prerequisite

(tested on unix/non-unix distribution)

Back to Top ^

Installation (if you want to contribute)

  • Open your GitLab client and clone the repository of this project.
  • You can do this also from command line (or in your terminal) adding:
$ git clone https://gitlab.alfresco.com/tas/alfresco-tas-ftp-test.git
# this clone will have the latest changes from repository. If you want to checkout a specific version released, take a look at the [Change Log](docs/CHANGELOG.md) page
$ cd alfresco-tas-ftp-test
# this command will checkout the remove v1.0.0 tagged repository and create locally a new branch v1.0.0
$ git checkout tags/v1.0.0 -b v1.0.0 
  • Install and check if all dependencies are downloaded
$
$ mvn clean install -DskipTests
# you should see one [INFO] BUILD SUCCESS message displayed

Back to Top ^

Package Presentation

The project uses a maven layout archetype:

├── pom.xml
├── src
│   ├── main
│   │   └── java
│   │       └── org
│   │           └── alfresco
│   │               └── ftp
│   │                   ├── FTPProperties.java  #handles all properties from default.properties
│   │                   ├── FTPWrapper.java  #wrapper around FTP protocol
│   │                   └── dsl
│   │                       ├── FTPAssertion.java
│   │                       ├── FTPUtil.java
│   │                       └── JmxUtil.java
│   ├── test
│   │   ├── java
│   │   │   └── org
│   │   │       └── alfresco
│   │   │           └── ftp
                     ├── file
                        ├── CreateFileTests.java
                        ├──    (...)
                        └── UploadFileTests.java
                     ├── folder
                        ├── CreateFolderTests.java
                        ├──    (...)
                        └── RenameFolderSanityTests.java
                     ├── FTPConnectionTests.java #tests that verify the ftp connection
│   │   │               ├── FTPDemoTest.java #demo example
                     ├── FTPTest.java #abstract base class that should be inherited by all tests
│   │   │               └── FTPTransferModeTests.java #tests that verify different types of transfer mode
│   │   └── resources
│   │       ├── alfresco-ftp-context.xml  #spring configuration
│   │       ├── default.properties #all settings related to environment, protocol
│   │       └── log4j.properties

Back to Top ^

Sample Usage

Following the standard layout for Maven projects, the application sources locate in src/main/java and test sources locate in src/test/java. Application sources consist in defining the FTP object that simulates the actions for this protocol. The tests are based on an abstract object: FTPTest.java that handles the common behavior: checking the health status of the test server, configuration settings, getting the general properties, etc.

Please take a look at FTPDemoTest.java class for an example.

Common configuration settings required for this project are stored in properties file, see default.properties. Please analyze and update it accordingly with Alfresco test server IP, port, credentials, etc.

Example:

# Alfresco HTTP Server Settings
alfresco.scheme=http
alfresco.server=<add-here-the-ip-of-your-test-server>
alfresco.port=<default-port-for-alfresco-not-share>
ftp.port=<ftp-port-of-alfresco-server>
ftp.timeout=<ftp-timeout>
ftp.passiveMode=false #if your Alfresco instance is installed on Docker machine set passive mode to false
  • optional update the logging level in log4j file (you can increase/decrease the deails of the logging file, setting the log4j.rootLogger=DEBUG if you want.)
  • go to running section for more information on how to run this tests.

Back to Top ^

How to write a test

  • Tests are organized in java classes and located on src/test/java as per maven layout.

  • One test class should contain the tests that cover one functionality as we want to have a clear separation of test scope: tests for sanity/core/full, tests that verify manage of folder/files etc.

  • These are the conventions that need to follow when you write a test:

    • The test has @Test annotation with the group defined: protocols, ftp. You can add more groups like sanity, regression

    • The test has @TestRail annotation in order to assure that the details and results will be submitted on TestRail. The fields for TestRail annotation will be explained on next chapter.

    @Test(groups={"protocols", "ftp", "sanity"}) @TestRail(section = { "protocols", "ftp" }, executionType=ExecutionType.SANITY, description = "Verify admin user creates folder in DocumentLibrary with FTP") public void adminShouldCreateFolderInSite() throws Exception { ftpProtocol.usingSite(testSite).createFolder(testFolder).assertExistsInRepo(); }

    ```
    
    • Use Spring capabilities to initialize the objects(Models, Wrappers) with @Autowired

    • We followed Builder pattern to develop specific DSL for simple and clear usage of protocol client in test:

       ftpProtocol.usingSite(testSite) .createFolder(testFolder) .assertExistsInRepo();
    * To view a simple class that is using this utility, just browse on [FTPDemoTest.java](src/test/java/org.alfresco.ftp.FTPDemoTest.java)
    Notice the class definition and inheritance value:
    
    ```java        
        public class FTPDemoTest extends FTPTest
    
    • the test name are self explanatory:
    @TestRail(section = { "protocols", "ftp" }, executionType=ExecutionType.SANITY, description = "Verify admin user creates folder in DocumentLibrary with FTP")
    public void adminShouldCreateFolderInSite() throws Exception
    {
        ftpProtocol.usingSite(testSite)
            .createFolder(testFolder)
            .assertExistsInRepo();
    }

Back to Top ^

How to run tests

from IDE

  • The project can be imported into a development environment tool (Eclipse or IntelliJ). You have the possibility to execute tests or suite of tests using TestNG plugin previously installed in IDE. From Eclipse, just right click on the testNG class (something similar to FTPDemoTest.java), select Run As - TestNG Test You should see your test passed.

  • In case you are using the default settings that points to localhost (127.0.0.1) and you don't have Alfresco installed on your machine, you will see one exception thrown (as expected):

    org.alfresco.utility.exception.ServerUnreachableException: Server {127.0.0.1} is unreachable.

from command line

  • In terminal or CMD, navigate (with CD) to root folder of your project (you can use the sample project):

    The tests can be executed on command line/terminal using Maven command

    mvn test

    This command with trigger the tests specified in the default testNG suite from POM file: src/main/shared-resources/ftp-suites.xml

    You can use -Dtest parameter to run the test/suites through command line (http://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html).

    You can also specify a different suiteXMLFile like:

    mvn test -DsuiteXmlFile=src/resources/your-custom-suite.xml

    Or even a single test:

    mvn test -Dtest=org.alfresco.ftp.FTPDemoTest

    But pay attention that you will not have enabled all the listeners in this case (the Reporting listener or TestRail integration one)

Back to Top ^

Listeners

With the help of Listeners we can modify the behaviour of TestNG framework. There are a lot of testNG listener interfaces that we can override in order to provide new functionality. The tas framework provides out of the box a couple of listeners that you could use. These could be enabled and added at the class level or suite level.

a) org.alfresco.utility.report.ReportListenerAdapter

  • if added at the class level:

    @Listeners(value=ReportListenerAdapter.class)
    public class MyTestClass extends FTPTest
    {
     (...)
    }
  • or suite xml level

    <suite name="Your Suite test" parallel="classes">
    <listeners>
    	<listener class-name="org.alfresco.utility.report.ReportListenerAdapter"></listener>
    </listeners>
    (...)
    </suite>

    It will automatically generate one html named "report.html" in ./target/report folder. Please also take a look at Test Results section.

b) org.alfresco.utility.testrail.TestRailExecutorListener

It will automatically update Test Rail application with the test cases that you've automated. Please take a look at Test Rail Integration section for more details.

c) org.alfresco.utility.report.log.LogsListener

This is a new listener that will generate further details in one XML format of the automated test steps that you will write.

Example:

public void myDSLMethod1()
{
    STEP("Lorem ipsum dolor sit amet");
    //code for first step
    
    STEP("consectetur adipiscing elit");
    //code for the next description
}

public void myDSLMethod2() 
{
    STEP("sed do eiusmod tempor incididunt ut labore");
    //code for first step
    
    STEP("et dolore magna aliqua");
    //code for the next description
}

If these methods will be executed insite a test method, all those steps will be automatically logged in the XML report generated. Example:

@Test
public void adminShouldCreateFileInSite()
{
    myDSLMethod1();
    myDSLMethod2()
}

So if "testingSomething" will be executed this is what you will see on the XML file generated. (please take a look at Test Results section for defining the defaul location)

Here is one example of XML file generated with these steps:

Back to Top ^

Test Results

We already executed a couple of tests using command line as indicated above. Sweet! Please take a look at ftp-suites.xml one more time. You will see there that we have one listener added:

<listener class-name="org.alfresco.utility.report.ReportListenerAdapter"></listener>

This will tell our framework, after we run all tests, to generate one HTML report file with graphs and metrics.

Take a look at the target/reports folder (created after running the tests) and open the report.html file.

Playing with this report, you will notice that you will be able to: * search tests cases by name * filter test cases by errors, labels, groups, test types, date when it was executed, protocol used, etc. * view overall pass/fail metrics of current test suite, history of tests execution, etc.

The report path can be configured in default.properties):

```
    # The location of the reports path
    reports.path=your-new-location-of-reports
```    

Back to Top ^

Test Rail Integration

Alfresco is using now https://alfresco.testrail.net (v5.3.0.3601).

We aim to accelerate the delivery of automated test by minimizing the interaction with the test management tool - TestRail. In this scope we developed the following capabilities:

  • creating automatically the manual tests in TestRail
  • submitting the test results (with stack trace) after each execution into TestRail Test Runs
  • adding the test steps for each test.

Configuration

In order to use Test Rail Integration you will need to add a couple of information in default.properties file: (the document is pretty self explanatory)

# Example of configuration:
# ------------------------------------------------------
# testManagement.endPoint=https://alfresco.testrail.com/
# testManagement.username=<yourusername-that-you-connect-to-testrail>
# testManagement.apiKey=<api-key>
# testManagement.project=<id-of-your-project
# testManagement.testRun=<test-run-name>

!This settings are already defined in default.properties for you.

For generating a new API Key take a look at the official documentation, TestRail APIv2

  • testManagement.project= <id-of-your-project this is the ID of the project where you want to store your test cases. If you want to use Alfresco ONE project in TestRail, open that project and notice the URL, after "/overview/1" link you will see the ID of the project (1 in this case) If you want to use TAS Project you will notice the ID 7, so "testManagement.project=7"
  • "testManagement.testRun=" this represents the name of the Test Run from your project.
  • In Test Rail, navigating to Test Runs & Results, create a new Test Run and include all/particular test cases. If this test run name is "Automation", update testManagement.testRun= Automation. All test results will be updated only on this test run at runtime as each test is executed by TAS framework.

How to enable Test Rail Integration?

We wanted to simplify the Test Rail integration, so we used listeners in order to enable/disable the integration of Test Rail.

  • first configure your default.properties as indicated above

  • now on your TestNG test, add the @TestRail annotation, so let's say you will have this test:

     @Test(groups="sample-tests")
     public void thisAutomatedTestWillBePublishedInTestRail()
     {
     }

    add now @TestRail integration with mandatory field section. This means that this tests annotated, will be uploaded in TestRail:

    @Test(groups="sample-tests")
    @TestRail(section = { "protocols", "TBD" })
    public void thisAutomatedTestWillBePublishedInTestRail()
    {
    }

    The section field, represents an array of strings, the hierarchy of sections that SHOULD be found on TestRail under the project you've selected in default.properties. Follow the TestRail user-guide for more information regarding sections. In our example we created in Test Rail one root section "protocols" with a child section: "TBD" (you can go further and add multiple section as you wish)

  • now, lets add the listener, the TestRailExecutorListener that will handle this TC Management interaction. This listener can be added at the class level or suite level (approach that we embrace) Take a look at ftp-suites.xml for further example.

    <listeners>
    	<listener class-name="org.alfresco.utility.testrail.TestRailExecutorListener"></listener>
     (...)
    </listeners>

    Right click on ftp-suites.xml file and run it, or just "mvn test" from root if this sample project. After everything passes, go in Test Rail, open your project and navigate to "Test Cases" section. Notice that under protocols/TBD section, you will see your test case published.

    If you defined also the "testManagement.testRun" correctly, you will see under Test Runs, the status of this case marked as passed.

    The @TestRail annotation offers also other options like:

    • "description" this is the description that will be updated in Test Rail for your test case
    • "testType", the default value is set to Functional test
    • "executionType", default value is set to ExecutionType.REGRESSION, but you can also use ExecutionType.SMOKE, ExecutionType.SANITY, etc

    Take a look at the demo scenarios in this project for further examples.

Back to Top ^

Reference

Contributors

As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other... more

License

TBD

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages