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

Integration tests Refactoring & Reworking #1104

Open
helkv opened this issue Jan 24, 2019 · 2 comments
Open

Integration tests Refactoring & Reworking #1104

helkv opened this issue Jan 24, 2019 · 2 comments
Assignees

Comments

@helkv
Copy link
Contributor

@helkv helkv commented Jan 24, 2019

Ticket for the revision of the existing integration test and the development of new integration tests.

Reasons for the refactoring and reworking of the Imeji integration tests:

  • The existing integration tests were not executed for a long time
    • some of them were not up to date and did not run any more
  • Embedded Elasticsearch, which some tests rely on, is not supported in the new Elasticsearch version any more
  • After major changes in Imeji a new testing approach and test setup is needed

Steps for the revision of the integration tests setup:

  1. Analysation of the existing integration tests and their structure
  2. Handling of the existing integration tests
    1. Deletion of existing tests which are out dated and in a bad condition
    2. Refactoring of existing tests which are in good condition and fit in the new test setup
    3. Continue to use (parts of) existing tests which are in good condition and still run successfully
  3. Reimplementation of the Elasticsearch access within the tests
  4. Implementation of the new integration tests, on basis of the new Imeji architecture and the new testing approach
@helkv helkv self-assigned this Jan 24, 2019
helkv added a commit that referenced this issue Jan 24, 2019
- The test classes are compiled again
- Running the tests is still skipped (until tests are fixed or new are
added)
- Removed the access to ElasticInitializer from the test super class
(alternative to Embedded Elastic has to be implemented/configured
instead)
helkv pushed a commit that referenced this issue Mar 15, 2019
-> Use Testcontainers (Elasticsearch Module) to start Elasticsearch in a
Docker Container for the integration tests
- Add ElasticsearchTestUtil class to start and stop the
ElasticsearchContainer
helkv pushed a commit that referenced this issue Mar 15, 2019
-> Use ElasticsearchTestUtil to start/stop Elasticsearch in a Docker
Container before/after the integration tests
- Remove SuperTestSuite
- Update jersey (REST) dependencies to solve dependency conflict
(referring to javax.servlet-api) occurring in the integration tests
helkv pushed a commit that referenced this issue Mar 15, 2019
-> Eclipse wrongly shows 'The import ... cannot be resolved' error
messages for multiple dependencies (i.a. javax.ws.rs...), when
javaee-api dependency is present
-> javaee-api not required (covered by other dependencies)
helkv added a commit that referenced this issue Mar 22, 2019
-> Run the integration tests (using docker for elasticsearch) when
building Imeji with Maven
- set skipTests false
helkv added a commit that referenced this issue Apr 23, 2019
- On jenkins an IOException occurs in the PdfHandlingTest (locally the
test runs successfully)
- Skip the PdfHandlingTest, until Test/IOException is fixed
helkv added a commit that referenced this issue Apr 26, 2019
- Edit the PropertyReader
1) Load the imeji.properties from the server conf directory if a server
is detected
2) Throw a FileNotFoundException if a server is detected but the
imeji.properties is not found in the server conf directory
3) Load the imeji.properties from classpath if no server is detected
4) Throw a FileNotFoundException if no server is detected and the
imeji.properties is not found in the classpath

- Renamed solution.properties to version.properties
- Removed appname property from the version.properties
- Removed setting the catalina.base system property in the pom.xml
helkv added a commit that referenced this issue Jun 19, 2019
- Set the Elasticsearch docker image name to Elasticsearch version 7.0.1
(after merging with the latest imeji version which uses Elasticsearch
7.0.1)
helkv added a commit that referenced this issue Jun 28, 2019
-> The local test User objects have to be retrieved after creating a
collection (because the side effect that the user objects (with
user-grants) passed to the method get updated is removed!)
-> The stored test User objects have to be updated
(UserService.update()) after changing the grants of the local test user
(because the user now gets retrieved within the
ShareService.shareToUser()/shareToGroup() methods!)

- Updated test classes: ContentServiceTest, FileAuthorizationTest,
ShareServiceTest, StatementServiceTest, SuperServiceTest,
UserServiceTest
helkv added a commit that referenced this issue Jun 28, 2019
- Add new test classes (to be extended by more test methods):
CollectionServiceCreateTest, StatementServiceUpdateTest
helkv added a commit that referenced this issue Jul 5, 2019
-> So that new test classes are being executed they have to be added to
the corresponding suite classes for now.
- Add CollectionServiceCreateTest and StatementServiceUpdateTest to
ServiceTestSuite
helkv added a commit that referenced this issue Jul 5, 2019
-> Delete the test files 'tmp' directory before and after each test
class
- Add deleteTempDirectory() method to JenaUtil class
@haarli haarli added this to To do in imeji 4.6 Jul 8, 2019
helkv added a commit that referenced this issue Jul 8, 2019
-> The local test User objects have to be retrieved after creating a
collection (because the side effect that the user objects (with
user-grants) passed to the method get updated is removed!)
-> So that new test classes are being executed they have to be added to
the corresponding suite classes for now.

- Updated & Fixed test classes: CollectionServiceTest, ItemServiceTest
- Re-add CollectionServiceTest and ItemServiceTest to ServiceTestSuite
@helkv helkv moved this from To do to In progress in imeji 4.6 Jul 9, 2019
helkv added a commit that referenced this issue Jul 11, 2019
- Delete the test files directories (before and) after each test class
in JenaUtil.closeJena()
- Log the deletion of the different test files directories
helkv added a commit that referenced this issue Jul 12, 2019
- Changed the order of the deletion methods in JenaUtil: delete tmp
directory before files directory
helkv added a commit that referenced this issue Jul 12, 2019
-> Skip integration tests execution until:
-> all tests that fail from time to time are fixed
-> the integration tests execution is configured correctly (all
necessary tests are being executed + integration tests will be executed
e.g. only on jenkins)

- set skipTests true
helkv added a commit that referenced this issue Jul 31, 2019
- Refactor maven profiles in pom.xml
- Add new maven profile env-testing (used to run the tests on jenkins)
- Edit Jenkinsfile: Activate the env-testing profile for the imeji maven
build on Jenkins
helkv added a commit that referenced this issue Aug 1, 2019
- Add ControllerTestSuite so that the controller tests get executed
- Skip currently not running tests in: InvitationBusinessControllerTest,
RegistrationBusinessControllerTest and StatisticsControllerTestClass
helkv added a commit that referenced this issue Aug 8, 2019
=> From now on the war file is not builded if (integration) tests fail
- Remove testFailureIgnore = true
@helkv
Copy link
Contributor Author

@helkv helkv commented Aug 19, 2019

Updated integration tests get executed on Jenkins with every imeji commit/build.

@helkv helkv moved this from In progress to Done in imeji 4.6 Aug 19, 2019
helkv added a commit that referenced this issue Aug 26, 2019
- Use JUnit Plugin to capture test reports used for reporting and
visualization of the test results in Jenkins
helkv added a commit that referenced this issue Aug 29, 2019
- Use path ./data/imeji_test to save data created during tests
(-> The content of the ./data folder is deleted at the end of the tests)
@helkv helkv closed this as completed Sep 16, 2019
imeji 4.6 automation moved this from Done to Closed Sep 16, 2019
@helkv
Copy link
Contributor Author

@helkv helkv commented Oct 25, 2019

Further refactoring & reworking of the integration test.

@helkv helkv reopened this Oct 25, 2019
@helkv helkv added this to To do in imeji 4.8 Oct 25, 2019
@helkv helkv moved this from To do to In progress in imeji 4.8 Oct 25, 2019
helkv added a commit that referenced this issue Oct 25, 2019
-> Add new class ConcurrencyUtil, with methods to wait for thread
(pools) to finish/complete
-> Add new Dependency Awaitility to wait for asynchronous tasks. Used in
ConcurrencyUtil
-> Enhanced class Imeji.java: Add wrapper methods for
Executors.newCachedThreadPool()/.newSingleThreadExecutor() to add the
thread-pools to a global list of ThreadPoolExecutors (the list is used
for the waiting mechanism)

- Use of the new thread pool wrapper methods in: ItemBean, JenaWriter,
SearchServiceAbstract, ThreadedTransaction, WriterFacade
- Removed ExecutorService from CRUDTransation, because it's not used
- Wait for all threads to finish at the end of each test, before
Elasticsearch and Jena is closed

=> Fixes the problem, that Jena & Elasticsearch threads being
interrupted before they are finished. This issue occurs in tests, when
the test is finished and Jena & Elasticsearch are closed, but some Jena
& Elasticsearch threads are still working.
helkv added a commit that referenced this issue Nov 8, 2019
-> Fix for ConcurrentModificationException in
ConcurrencyUtil.waitForThreadsToComplete()
-> ConcurrentModificationException is thrown if another
threadPoolExecutor is added to the list, while
waitForThreadsToComplete() is already iterating over it.

- Reworked ConcurrencyUtil.waitForThreadsToComplete(): Catch the
ConcurrentModificationException and run waitForThreadsToComplete() again
to also check the new added threadPool
helkv added a commit that referenced this issue Nov 8, 2019
- Remove creating/initializing the temp directory with a static constant
- Add getOrCreateTempDirectory() method for getting the temp directory
or creating the temp directory if it does not exist.

-> Now the temp directory can be created before and deleted after each
test (class)
helkv added a commit that referenced this issue Nov 8, 2019
- Remove the deletion of the Temp + Files directories from initJena()
method (Now Temp + Files directories do not get deleted before, only
after the tests)
- Keep the deletion of the TDB directory in initJena() method (TDB
directory gets deleted before and after the tests)

-> Deleting the TDB directory after the tests does not work correctly on
Windows: IOException "Unable to delete file:
...\tdb\imeji_HTreeMap_invitationStore.t"
-> Probable Reason: Problem in mapDB -> The already closed DB
(invitationStore) is still locked by Windows (no issue on Linux)
=> No fix for this problem up to now
helkv added a commit that referenced this issue Nov 8, 2019
- Remove the deletion/withdrawing of items at the end of some tests in
ItemServiceTest

-> The deletion/withdrawing of items which have no content (=file)
results in a NotFoundException, because the ItemService.delete method
tries to delete the content as well
-> Fix for NotFoundException "content ... not found" in ItemServiceTest
helkv added a commit that referenced this issue Nov 8, 2019
- Use ItemService.createWithFile() instead of create() method, before
deleting the collection the created item belongs to.

-> The deletion/withdrawing of collections which have items which have
no content (=file) results in a NotFoundException, because the
ItemService.delete method tries to delete the content as well
-> Fix for NotFoundException "content ... not found" in
CollectionServiceTest
helkv added a commit that referenced this issue Nov 8, 2019
-> Add a TestWatcher (as Rule) to SuperServiceTest to log the current
executed test. Only for inheriting test classes of SuperServiceTest.
helkv added a commit that referenced this issue Nov 12, 2019
-> Grant Strings get parsed by ElasticUserGroup, when a UserGroup is
created/updated
-> A single Grant String must be of the form "ShareRoles_type" + "," +
"collection_uri"
-> If a Grant String has no comma an ArrayIndexOutOfBoundsException is
thrown in ElasticUserGroup

- Reworked the Grants in UsergroupServiceTest: Now the Grants have the
right form to be parsed
helkv added a commit that referenced this issue Nov 12, 2019
-> Fix for several Exceptions by ContentService().create():
TikaException, FileNotFoundException, CommandException: ... unable to
open image ... No such file or directory, NullPointerException: Source
must not be null
-> Exceptions caused by:
ContentService().delete() results in errors if ContentService().create()
and its threads have not finished working (writing the files)

- Wait for all threads to finish after calling ContentService().create()
fixes the issue.
@helkv helkv changed the title New integration tests Integration tests Refactoring & Reworking Nov 12, 2019
helkv added a commit that referenced this issue Nov 13, 2019
-> Test method loginWithWrongAPIKey() results in an error message
getting logged is correct and expected

- Add comment to loginWithWrongAPIKey() that the error message getting
logged is correct
helkv added a commit that referenced this issue Nov 13, 2019
- Update the Testcontainers (elasticsearch) mvn dependency from version
1.10.7 to 1.12.3
helkv added a commit that referenced this issue Nov 19, 2019
-> Waiting mechanism (added in commit #b1a62ad2) does not work
correctly: The new List (in the Imeji class) which collects all
ThreadPoolExecutors does not get cleared
=> This would lead to more and more memory being used by the
list-object!
=> Do not use a collecting list for the solution

-> Instead use the accessible (public static) ThreadPoolExecutors to get
access to all the running threads in the tests!

- Revoke changes made for the first solution (commit #b1a62ad2)
- Add new methods to ConcurrencyUtil, to wait for all accessible
ThreadPools
- Use the new methods in several test classes, to wait for all running
threads of the ThreadPools
helkv added a commit that referenced this issue Nov 21, 2019
-> Reworked creation of the temp directory (added in commit #93390f52)
does not work correctly: If the temp directory already exists the
tempDir variable is not initialized with the existing temp directory
=> The tempDir variable would be null, if the temp directory already
exists

- Initialize tempDir as (non final) static variable
- In the initialization: Create a temp directory if none exists, if one
exists initialize tempDir variable with the appropriate path
- Reworked the getOrCreateTempDirectory() method
- Remove the use of the getOrCreateTempDirectory() method in
createTempFile() method
- getOrCreateTempDirectory() method used only for tests
@helkv helkv moved this from In progress to Done in imeji 4.8 Nov 22, 2019
helkv added a commit that referenced this issue Dec 4, 2019
-> Before: Some temporal test files created by the integration were
stored in the system tmp directory and were not cleaned after the tests
-> Now: All temporal test files created by the integration are stored in
the imeji tmp directory, which gets deleted after the tests
helkv added a commit that referenced this issue Dec 5, 2019
-> Creating the temp test files in the imeji tmp directory leads to an
error on Jenkins (Linux): "Runtime Error copying file"
-> Errors do not occur locally (Windows)

- Use method getOrCreateTempDirectory() instead of getTempDirectory() to
create the temp test files to be sure the imeji tmp directory exists
when creating the files
helkv added a commit that referenced this issue Dec 5, 2019
- Get the original error message, if an error occurs when
creating/copying a file in copyFile() method
helkv added a commit that referenced this issue Dec 6, 2019
-> Accessing the temp directory seems to be a problem on Jenkins
(Linux), because the absolute path has the 'files' directory in it,
which is not guaranteed to exists when accessing the temp directory
=> This leads to an exception "No such file or directory" when temp test
files get created

- Use the canonical path (which dosen't contain the not existing 'files'
directory) to access the temp directory, when creating the temp test
files
@helkv helkv moved this from Done to Closed in imeji 4.8 Feb 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
imeji 4.6
  
Closed
imeji 4.8
  
Closed
Development

No branches or pull requests

1 participant