From 69689ead3b7855b01adee71d5be97f41041d1c6d Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Tue, 26 Feb 2019 14:17:19 +0100 Subject: [PATCH 01/63] Add base embedded mongo test --- core/cleaner/pom.xml | 6 +++ .../StartMetadataCleanupProcessorTest.java | 54 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java diff --git a/core/cleaner/pom.xml b/core/cleaner/pom.xml index 474ad7972..afadeb90a 100644 --- a/core/cleaner/pom.xml +++ b/core/cleaner/pom.xml @@ -118,6 +118,12 @@ com.google.code.findbugs jsr305 + + de.flapdoodle.embed + de.flapdoodle.embed.mongo + 2.2.0 + test + diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java new file mode 100644 index 000000000..ebe5421e6 --- /dev/null +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java @@ -0,0 +1,54 @@ +package com.cognifide.aet.cleaner.processors; + +import com.mongodb.BasicDBObject; +import com.mongodb.DB; +import com.mongodb.DBCollection; +import com.mongodb.MongoClient; +import de.flapdoodle.embed.mongo.MongodExecutable; +import de.flapdoodle.embed.mongo.MongodStarter; +import de.flapdoodle.embed.mongo.config.IMongodConfig; +import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; +import de.flapdoodle.embed.mongo.config.Net; +import de.flapdoodle.embed.mongo.distribution.Version; +import de.flapdoodle.embed.process.runtime.Network; +import java.util.Date; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class StartMetadataCleanupProcessorTest { + + private MongodExecutable mongodExecutable; + + @Before + public void setUp() throws Exception { + MongodStarter starter = MongodStarter.getDefaultInstance(); + String bindIp = "localhost"; + int port = 12345; + IMongodConfig mongodConfig = new MongodConfigBuilder() + .version(Version.Main.PRODUCTION) + .net(new Net(bindIp, port, Network.localhostIsIPv6())) + .build(); + + mongodExecutable = starter.prepare(mongodConfig); + mongodExecutable.start(); + + MongoClient mongo = new MongoClient(bindIp, port); + DB db = mongo.getDB("test"); + DBCollection col = db.createCollection("testCol", new BasicDBObject()); + col.save(new BasicDBObject("testDoc", new Date())); + + } + + @Test + public void test() { + + } + + @After + public void tearDown() { + if (mongodExecutable != null) { + mongodExecutable.stop(); + } + } +} \ No newline at end of file From a6901f11e5b9e78f88992c431e6a426b46e68a6f Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Wed, 27 Feb 2019 07:54:12 +0100 Subject: [PATCH 02/63] Change fake server to "mongo-java-server" --- core/cleaner/pom.xml | 12 +++-- .../StartMetadataCleanupProcessorTest.java | 52 ++++++++----------- 2 files changed, 30 insertions(+), 34 deletions(-) diff --git a/core/cleaner/pom.xml b/core/cleaner/pom.xml index afadeb90a..0af79848d 100644 --- a/core/cleaner/pom.xml +++ b/core/cleaner/pom.xml @@ -119,9 +119,15 @@ jsr305 - de.flapdoodle.embed - de.flapdoodle.embed.mongo - 2.2.0 + de.bwaldvogel + mongo-java-server + 1.12.0 + test + + + org.mongodb + mongo-java-driver + 3.8.0 test diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java index ebe5421e6..a15802dda 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java @@ -1,54 +1,44 @@ package com.cognifide.aet.cleaner.processors; -import com.mongodb.BasicDBObject; -import com.mongodb.DB; -import com.mongodb.DBCollection; +import static org.junit.Assert.assertEquals; + import com.mongodb.MongoClient; -import de.flapdoodle.embed.mongo.MongodExecutable; -import de.flapdoodle.embed.mongo.MongodStarter; -import de.flapdoodle.embed.mongo.config.IMongodConfig; -import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; -import de.flapdoodle.embed.mongo.config.Net; -import de.flapdoodle.embed.mongo.distribution.Version; -import de.flapdoodle.embed.process.runtime.Network; -import java.util.Date; +import com.mongodb.ServerAddress; +import com.mongodb.client.MongoCollection; +import de.bwaldvogel.mongo.MongoServer; +import de.bwaldvogel.mongo.backend.memory.MemoryBackend; +import java.net.InetSocketAddress; +import org.bson.Document; import org.junit.After; import org.junit.Before; import org.junit.Test; public class StartMetadataCleanupProcessorTest { - private MongodExecutable mongodExecutable; + private MongoCollection collection; + private MongoClient client; + private MongoServer server; @Before public void setUp() throws Exception { - MongodStarter starter = MongodStarter.getDefaultInstance(); - String bindIp = "localhost"; - int port = 12345; - IMongodConfig mongodConfig = new MongodConfigBuilder() - .version(Version.Main.PRODUCTION) - .net(new Net(bindIp, port, Network.localhostIsIPv6())) - .build(); - - mongodExecutable = starter.prepare(mongodConfig); - mongodExecutable.start(); - - MongoClient mongo = new MongoClient(bindIp, port); - DB db = mongo.getDB("test"); - DBCollection col = db.createCollection("testCol", new BasicDBObject()); - col.save(new BasicDBObject("testDoc", new Date())); + server = new MongoServer(new MemoryBackend()); + // bind on a random local port + InetSocketAddress serverAddress = server.bind(); + client = new MongoClient(new ServerAddress(serverAddress)); + collection = client.getDatabase("testdb").getCollection("testcollection"); } @Test public void test() { - + assertEquals(0, collection.countDocuments()); + collection.insertOne(new Document()); + assertEquals(1, collection.countDocuments()); } @After public void tearDown() { - if (mongodExecutable != null) { - mongodExecutable.stop(); - } + client.close(); + server.shutdown(); } } \ No newline at end of file From 99621e73b883ada6962339610236ce2fadc8bdf3 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Wed, 27 Feb 2019 07:57:35 +0100 Subject: [PATCH 03/63] Remove comment --- .../cleaner/processors/StartMetadataCleanupProcessorTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java index a15802dda..19d2dba30 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java @@ -22,10 +22,9 @@ public class StartMetadataCleanupProcessorTest { @Before public void setUp() throws Exception { server = new MongoServer(new MemoryBackend()); - - // bind on a random local port InetSocketAddress serverAddress = server.bind(); client = new MongoClient(new ServerAddress(serverAddress)); + collection = client.getDatabase("testdb").getCollection("testcollection"); } From de814c719e1125c03b1e2a56a8106469b9eb56b7 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Wed, 27 Feb 2019 09:35:24 +0100 Subject: [PATCH 04/63] Code cleanup --- .../StartMetadataCleanupProcessorTest.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java index 19d2dba30..01db3a969 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java @@ -3,7 +3,7 @@ import static org.junit.Assert.assertEquals; import com.mongodb.MongoClient; -import com.mongodb.ServerAddress; +import com.mongodb.MongoClientURI; import com.mongodb.client.MongoCollection; import de.bwaldvogel.mongo.MongoServer; import de.bwaldvogel.mongo.backend.memory.MemoryBackend; @@ -18,21 +18,28 @@ public class StartMetadataCleanupProcessorTest { private MongoCollection collection; private MongoClient client; private MongoServer server; + private String mongoURI; @Before public void setUp() throws Exception { server = new MongoServer(new MemoryBackend()); InetSocketAddress serverAddress = server.bind(); - client = new MongoClient(new ServerAddress(serverAddress)); + mongoURI = String.format("mongodb://localhost:%d", serverAddress.getPort()); + client = new MongoClient(new MongoClientURI(mongoURI)); collection = client.getDatabase("testdb").getCollection("testcollection"); } @Test public void test() { - assertEquals(0, collection.countDocuments()); - collection.insertOne(new Document()); - assertEquals(1, collection.countDocuments()); + assertEquals(0, collection.count()); + + // creates the database and collection in memory and insert the object + Document obj = new Document("_id", 1).append("key", "value"); + collection.insertOne(obj); + + assertEquals(1, collection.count()); + assertEquals(obj, collection.find().first()); } @After From f2e85b44f12019be46846c379172fbafdc1d6a92 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Wed, 27 Feb 2019 10:42:03 +0100 Subject: [PATCH 05/63] Add mock dependency --- core/cleaner/pom.xml | 8 +++++++- .../processors/StartMetadataCleanupProcessorTest.java | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/core/cleaner/pom.xml b/core/cleaner/pom.xml index 0af79848d..06216be17 100644 --- a/core/cleaner/pom.xml +++ b/core/cleaner/pom.xml @@ -118,6 +118,7 @@ com.google.code.findbugs jsr305 + de.bwaldvogel mongo-java-server @@ -127,7 +128,12 @@ org.mongodb mongo-java-driver - 3.8.0 + test + + + org.apache.sling + org.apache.sling.testing.osgi-mock.junit4 + 2.4.6 test diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java index 01db3a969..575c62009 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java @@ -8,13 +8,18 @@ import de.bwaldvogel.mongo.MongoServer; import de.bwaldvogel.mongo.backend.memory.MemoryBackend; import java.net.InetSocketAddress; +import org.apache.sling.testing.mock.osgi.junit.OsgiContext; import org.bson.Document; import org.junit.After; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; public class StartMetadataCleanupProcessorTest { + @Rule + public final OsgiContext context = new OsgiContext(); + private MongoCollection collection; private MongoClient client; private MongoServer server; From 2c01a096ec9a672e6f6ad648bcb6c1bbbd7de6a8 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Wed, 27 Feb 2019 11:19:50 +0100 Subject: [PATCH 06/63] Cleanup pom --- core/cleaner/pom.xml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/core/cleaner/pom.xml b/core/cleaner/pom.xml index 06216be17..1a575476f 100644 --- a/core/cleaner/pom.xml +++ b/core/cleaner/pom.xml @@ -33,6 +33,22 @@ AET :: Core :: Cleaner Cleaner responsible for removing outdated AET artifacts from datastorage + + + + de.bwaldvogel + mongo-java-server + 1.12.0 + + + org.apache.sling + org.apache.sling.testing.osgi-mock.junit4 + 2.4.6 + + + + + com.cognifide.aet @@ -122,7 +138,6 @@ de.bwaldvogel mongo-java-server - 1.12.0 test @@ -133,7 +148,6 @@ org.apache.sling org.apache.sling.testing.osgi-mock.junit4 - 2.4.6 test From e1fc3f238e76d7be096d0e30eba7579b0d498666 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Wed, 27 Feb 2019 12:16:17 +0100 Subject: [PATCH 07/63] Add needed dependencies for mocking OSGI --- core/cleaner/pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/cleaner/pom.xml b/core/cleaner/pom.xml index 1a575476f..fde77727f 100644 --- a/core/cleaner/pom.xml +++ b/core/cleaner/pom.xml @@ -71,6 +71,14 @@ validation + + org.osgi + org.osgi.core + + + org.osgi + org.osgi.compendium + org.osgi org.osgi.service.component.annotations From 47cb57af0e7d93414dc5c5b8ecc6709f24acc1c7 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Wed, 27 Feb 2019 14:16:25 +0100 Subject: [PATCH 08/63] Add registering services with mocked mongoUri --- core/cleaner/pom.xml | 17 +++++++++++ .../StartMetadataCleanupProcessorTest.java | 29 ++++++++++++++++--- core/datastorage/pom.xml | 17 +++++++++++ 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/core/cleaner/pom.xml b/core/cleaner/pom.xml index fde77727f..44de2abed 100644 --- a/core/cleaner/pom.xml +++ b/core/cleaner/pom.xml @@ -165,7 +165,24 @@ org.apache.felix maven-bundle-plugin + true + + scr-metadata + + manifest + + + true + true + + + <_dsannotations>* + + <_metatypeannotations>* + + + default-bundle diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java index 575c62009..34494f2a3 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java @@ -1,7 +1,23 @@ +/** + * AET + * + * Copyright (C) 2013 Cognifide Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ package com.cognifide.aet.cleaner.processors; import static org.junit.Assert.assertEquals; +import com.cognifide.aet.vs.mongodb.MongoDBClient; import com.mongodb.MongoClient; import com.mongodb.MongoClientURI; import com.mongodb.client.MongoCollection; @@ -14,7 +30,10 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.runners.MockitoJUnitRunner; +@RunWith(MockitoJUnitRunner.class) public class StartMetadataCleanupProcessorTest { @Rule @@ -26,24 +45,26 @@ public class StartMetadataCleanupProcessorTest { private String mongoURI; @Before - public void setUp() throws Exception { + public void setUp() { server = new MongoServer(new MemoryBackend()); InetSocketAddress serverAddress = server.bind(); mongoURI = String.format("mongodb://localhost:%d", serverAddress.getPort()); client = new MongoClient(new MongoClientURI(mongoURI)); collection = client.getDatabase("testdb").getCollection("testcollection"); + + context.registerInjectActivateService(new MongoDBClient(), "mongoURI", mongoURI); + context.registerInjectActivateService(new StartMetadataCleanupProcessor()); } @Test public void test() { - assertEquals(0, collection.count()); + assertEquals(0, collection.countDocuments()); - // creates the database and collection in memory and insert the object Document obj = new Document("_id", 1).append("key", "value"); collection.insertOne(obj); - assertEquals(1, collection.count()); + assertEquals(1, collection.countDocuments()); assertEquals(obj, collection.find().first()); } diff --git a/core/datastorage/pom.xml b/core/datastorage/pom.xml index 238f7d194..2a29e3f71 100644 --- a/core/datastorage/pom.xml +++ b/core/datastorage/pom.xml @@ -119,7 +119,24 @@ org.apache.felix maven-bundle-plugin + true + + scr-metadata + + manifest + + + true + true + + + <_dsannotations>* + + <_metatypeannotations>* + + + default-bundle From 33c230579076ca43d8682a7b54eb680c2f5f9ca8 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Wed, 27 Feb 2019 14:18:34 +0100 Subject: [PATCH 09/63] Clean code --- .../cleaner/processors/StartMetadataCleanupProcessorTest.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java index 34494f2a3..47a070e8c 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java @@ -23,7 +23,6 @@ import com.mongodb.client.MongoCollection; import de.bwaldvogel.mongo.MongoServer; import de.bwaldvogel.mongo.backend.memory.MemoryBackend; -import java.net.InetSocketAddress; import org.apache.sling.testing.mock.osgi.junit.OsgiContext; import org.bson.Document; import org.junit.After; @@ -47,8 +46,7 @@ public class StartMetadataCleanupProcessorTest { @Before public void setUp() { server = new MongoServer(new MemoryBackend()); - InetSocketAddress serverAddress = server.bind(); - mongoURI = String.format("mongodb://localhost:%d", serverAddress.getPort()); + mongoURI = String.format("mongodb://localhost:%d", server.bind().getPort()); client = new MongoClient(new MongoClientURI(mongoURI)); collection = client.getDatabase("testdb").getCollection("testcollection"); From 3fbf38287f6085446b311173cd6a7feea2feb509 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Thu, 28 Feb 2019 07:32:26 +0100 Subject: [PATCH 10/63] Rename + move test class --- ...CleanupProcessorTest.java => CleanerIntegrationTest.java} | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) rename core/cleaner/src/test/java/com/cognifide/aet/cleaner/{processors/StartMetadataCleanupProcessorTest.java => CleanerIntegrationTest.java} (93%) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java similarity index 93% rename from core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java rename to core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 47a070e8c..68666c349 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/StartMetadataCleanupProcessorTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -13,10 +13,11 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ -package com.cognifide.aet.cleaner.processors; +package com.cognifide.aet.cleaner; import static org.junit.Assert.assertEquals; +import com.cognifide.aet.cleaner.processors.StartMetadataCleanupProcessor; import com.cognifide.aet.vs.mongodb.MongoDBClient; import com.mongodb.MongoClient; import com.mongodb.MongoClientURI; @@ -33,7 +34,7 @@ import org.mockito.runners.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) -public class StartMetadataCleanupProcessorTest { +public class CleanerIntegrationTest { @Rule public final OsgiContext context = new OsgiContext(); From 02f1c9acc56b2fd4037cdb129f330830ed980983 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Thu, 28 Feb 2019 07:39:10 +0100 Subject: [PATCH 11/63] Add registering all processors --- .../aet/cleaner/CleanerIntegrationTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 68666c349..2377ac6af 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -17,7 +17,15 @@ import static org.junit.Assert.assertEquals; +import com.cognifide.aet.cleaner.processors.FetchAllProjectSuitesProcessor; +import com.cognifide.aet.cleaner.processors.GetMetadataArtifactsProcessor; +import com.cognifide.aet.cleaner.processors.RemoveArtifactsProcessor; +import com.cognifide.aet.cleaner.processors.RemoveMetadataProcessor; import com.cognifide.aet.cleaner.processors.StartMetadataCleanupProcessor; +import com.cognifide.aet.cleaner.processors.SuitesRemovePredicateProcessor; +import com.cognifide.aet.cleaner.route.MetadataCleanerRouteBuilder; +import com.cognifide.aet.vs.artifacts.ArtifactsDAOMongoDBImpl; +import com.cognifide.aet.vs.metadata.MetadataDAOMongoDBImpl; import com.cognifide.aet.vs.mongodb.MongoDBClient; import com.mongodb.MongoClient; import com.mongodb.MongoClientURI; @@ -53,7 +61,16 @@ public void setUp() { collection = client.getDatabase("testdb").getCollection("testcollection"); context.registerInjectActivateService(new MongoDBClient(), "mongoURI", mongoURI); + context.registerInjectActivateService(new MetadataDAOMongoDBImpl()); + context.registerInjectActivateService(new ArtifactsDAOMongoDBImpl()); + context.registerInjectActivateService(new StartMetadataCleanupProcessor()); + context.registerInjectActivateService(new FetchAllProjectSuitesProcessor()); + context.registerInjectActivateService(new SuitesRemovePredicateProcessor()); + context.registerInjectActivateService(new RemoveMetadataProcessor()); + context.registerInjectActivateService(new GetMetadataArtifactsProcessor()); + context.registerInjectActivateService(new RemoveArtifactsProcessor()); + context.registerInjectActivateService(new MetadataCleanerRouteBuilder()); } @Test From bdcb9ac232a8b934b80dcb36ee1c75387201540d Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Thu, 28 Feb 2019 08:08:10 +0100 Subject: [PATCH 12/63] Add starting clener job in test --- .../aet/cleaner/CleanerIntegrationTest.java | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 2377ac6af..8d53d6100 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -16,6 +16,7 @@ package com.cognifide.aet.cleaner; import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; import com.cognifide.aet.cleaner.processors.FetchAllProjectSuitesProcessor; import com.cognifide.aet.cleaner.processors.GetMetadataArtifactsProcessor; @@ -27,6 +28,7 @@ import com.cognifide.aet.vs.artifacts.ArtifactsDAOMongoDBImpl; import com.cognifide.aet.vs.metadata.MetadataDAOMongoDBImpl; import com.cognifide.aet.vs.mongodb.MongoDBClient; +import com.google.common.collect.ImmutableMap; import com.mongodb.MongoClient; import com.mongodb.MongoClientURI; import com.mongodb.client.MongoCollection; @@ -39,7 +41,11 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; +import org.quartz.JobDataMap; +import org.quartz.JobDetail; +import org.quartz.JobExecutionContext; @RunWith(MockitoJUnitRunner.class) public class CleanerIntegrationTest { @@ -47,10 +53,16 @@ public class CleanerIntegrationTest { @Rule public final OsgiContext context = new OsgiContext(); + @Mock + JobExecutionContext jobExecutionContext; + @Mock + JobDetail jobDetail; + private MongoCollection collection; private MongoClient client; private MongoServer server; private String mongoURI; + private MetadataCleanerRouteBuilder metadataCleanerRouteBuilder; @Before public void setUp() { @@ -70,11 +82,27 @@ public void setUp() { context.registerInjectActivateService(new RemoveMetadataProcessor()); context.registerInjectActivateService(new GetMetadataArtifactsProcessor()); context.registerInjectActivateService(new RemoveArtifactsProcessor()); - context.registerInjectActivateService(new MetadataCleanerRouteBuilder()); + metadataCleanerRouteBuilder = context.registerInjectActivateService(new MetadataCleanerRouteBuilder()); } @Test - public void test() { + public void test() throws Exception{ + final JobDataMap jobData = new JobDataMap(ImmutableMap.builder() + .put(CleanerJob.KEY_ROUTE_BUILDER, metadataCleanerRouteBuilder) + .put(CleanerJob.KEY_KEEP_N_VERSIONS, 1L) + .put(CleanerJob.KEY_REMOVE_OLDER_THAN, 1L) + .put(CleanerJob.KEY_COMPANY_FILTER, "company") + .put(CleanerJob.KEY_PROJECT_FILTER, "project") + .put(CleanerJob.KEY_DRY_RUN, false) + .build()); + + when(jobDetail.getJobDataMap()).thenReturn(jobData); + when(jobExecutionContext.getJobDetail()).thenReturn(jobDetail); + + + CleanerJob cleanerJob = new CleanerJob(); + cleanerJob.execute(jobExecutionContext); + assertEquals(0, collection.countDocuments()); Document obj = new Document("_id", 1).append("key", "value"); From e612a40c98afec9919e53cf8ec804dba402fbb94 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Thu, 28 Feb 2019 08:15:37 +0100 Subject: [PATCH 13/63] Remove junk code --- .../aet/cleaner/CleanerIntegrationTest.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 8d53d6100..a50fecdc8 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -58,7 +58,6 @@ public class CleanerIntegrationTest { @Mock JobDetail jobDetail; - private MongoCollection collection; private MongoClient client; private MongoServer server; private String mongoURI; @@ -70,8 +69,6 @@ public void setUp() { mongoURI = String.format("mongodb://localhost:%d", server.bind().getPort()); client = new MongoClient(new MongoClientURI(mongoURI)); - collection = client.getDatabase("testdb").getCollection("testcollection"); - context.registerInjectActivateService(new MongoDBClient(), "mongoURI", mongoURI); context.registerInjectActivateService(new MetadataDAOMongoDBImpl()); context.registerInjectActivateService(new ArtifactsDAOMongoDBImpl()); @@ -99,17 +96,8 @@ public void test() throws Exception{ when(jobDetail.getJobDataMap()).thenReturn(jobData); when(jobExecutionContext.getJobDetail()).thenReturn(jobDetail); - CleanerJob cleanerJob = new CleanerJob(); cleanerJob.execute(jobExecutionContext); - - assertEquals(0, collection.countDocuments()); - - Document obj = new Document("_id", 1).append("key", "value"); - collection.insertOne(obj); - - assertEquals(1, collection.countDocuments()); - assertEquals(obj, collection.find().first()); } @After From 70bdd057beaa09b1a533e4b01252e7b86569bba7 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Thu, 28 Feb 2019 08:21:10 +0100 Subject: [PATCH 14/63] Extract jobDetails setup function --- .../aet/cleaner/CleanerIntegrationTest.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index a50fecdc8..d15758c54 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -84,18 +84,7 @@ public void setUp() { @Test public void test() throws Exception{ - final JobDataMap jobData = new JobDataMap(ImmutableMap.builder() - .put(CleanerJob.KEY_ROUTE_BUILDER, metadataCleanerRouteBuilder) - .put(CleanerJob.KEY_KEEP_N_VERSIONS, 1L) - .put(CleanerJob.KEY_REMOVE_OLDER_THAN, 1L) - .put(CleanerJob.KEY_COMPANY_FILTER, "company") - .put(CleanerJob.KEY_PROJECT_FILTER, "project") - .put(CleanerJob.KEY_DRY_RUN, false) - .build()); - - when(jobDetail.getJobDataMap()).thenReturn(jobData); - when(jobExecutionContext.getJobDetail()).thenReturn(jobDetail); - + setUpJobData(1L, 1L, "company" , "project"); CleanerJob cleanerJob = new CleanerJob(); cleanerJob.execute(jobExecutionContext); } @@ -105,4 +94,17 @@ public void tearDown() { client.close(); server.shutdown(); } + + private void setUpJobData(Long versionsToKeep, Long maxAge, String companyName, String projectName){ + final JobDataMap jobData = new JobDataMap(ImmutableMap.builder() + .put(CleanerJob.KEY_ROUTE_BUILDER, metadataCleanerRouteBuilder) + .put(CleanerJob.KEY_KEEP_N_VERSIONS, versionsToKeep) + .put(CleanerJob.KEY_REMOVE_OLDER_THAN, maxAge) + .put(CleanerJob.KEY_COMPANY_FILTER, companyName) + .put(CleanerJob.KEY_PROJECT_FILTER, projectName) + .put(CleanerJob.KEY_DRY_RUN, false) + .build()); + when(jobDetail.getJobDataMap()).thenReturn(jobData); + when(jobExecutionContext.getJobDetail()).thenReturn(jobDetail); + } } \ No newline at end of file From a4d5ec6bc27ed59ce4be0ab5e1c768d8122f5bdb Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Thu, 28 Feb 2019 08:22:11 +0100 Subject: [PATCH 15/63] Cleanup code --- .../com/cognifide/aet/cleaner/CleanerIntegrationTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index d15758c54..376a24fd2 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -46,6 +46,7 @@ import org.quartz.JobDataMap; import org.quartz.JobDetail; import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; @RunWith(MockitoJUnitRunner.class) public class CleanerIntegrationTest { @@ -83,10 +84,9 @@ public void setUp() { } @Test - public void test() throws Exception{ + public void test() throws JobExecutionException { setUpJobData(1L, 1L, "company" , "project"); - CleanerJob cleanerJob = new CleanerJob(); - cleanerJob.execute(jobExecutionContext); + new CleanerJob().execute(jobExecutionContext); } @After From 85c8e44db0916084a96b32b1bc958b931746df6f Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Thu, 28 Feb 2019 08:23:25 +0100 Subject: [PATCH 16/63] Remove unused imports --- .../cognifide/aet/cleaner/CleanerIntegrationTest.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 376a24fd2..851a1a55b 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -15,7 +15,6 @@ */ package com.cognifide.aet.cleaner; -import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.when; import com.cognifide.aet.cleaner.processors.FetchAllProjectSuitesProcessor; @@ -31,11 +30,9 @@ import com.google.common.collect.ImmutableMap; import com.mongodb.MongoClient; import com.mongodb.MongoClientURI; -import com.mongodb.client.MongoCollection; import de.bwaldvogel.mongo.MongoServer; import de.bwaldvogel.mongo.backend.memory.MemoryBackend; import org.apache.sling.testing.mock.osgi.junit.OsgiContext; -import org.bson.Document; import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -80,12 +77,13 @@ public void setUp() { context.registerInjectActivateService(new RemoveMetadataProcessor()); context.registerInjectActivateService(new GetMetadataArtifactsProcessor()); context.registerInjectActivateService(new RemoveArtifactsProcessor()); - metadataCleanerRouteBuilder = context.registerInjectActivateService(new MetadataCleanerRouteBuilder()); + metadataCleanerRouteBuilder = context + .registerInjectActivateService(new MetadataCleanerRouteBuilder()); } @Test public void test() throws JobExecutionException { - setUpJobData(1L, 1L, "company" , "project"); + setUpJobData(1L, 1L, "company", "project"); new CleanerJob().execute(jobExecutionContext); } @@ -95,7 +93,8 @@ public void tearDown() { server.shutdown(); } - private void setUpJobData(Long versionsToKeep, Long maxAge, String companyName, String projectName){ + private void setUpJobData(Long versionsToKeep, Long maxAge, String companyName, + String projectName) { final JobDataMap jobData = new JobDataMap(ImmutableMap.builder() .put(CleanerJob.KEY_ROUTE_BUILDER, metadataCleanerRouteBuilder) .put(CleanerJob.KEY_KEEP_N_VERSIONS, versionsToKeep) From 79d463c5e354989d85c588da7360e51224a92710 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Thu, 28 Feb 2019 08:43:25 +0100 Subject: [PATCH 17/63] Separate server socket binding from creating mongoUri --- .../com/cognifide/aet/cleaner/CleanerIntegrationTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 851a1a55b..9a4605c3d 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -32,6 +32,7 @@ import com.mongodb.MongoClientURI; import de.bwaldvogel.mongo.MongoServer; import de.bwaldvogel.mongo.backend.memory.MemoryBackend; +import java.net.InetSocketAddress; import org.apache.sling.testing.mock.osgi.junit.OsgiContext; import org.junit.After; import org.junit.Before; @@ -64,7 +65,8 @@ public class CleanerIntegrationTest { @Before public void setUp() { server = new MongoServer(new MemoryBackend()); - mongoURI = String.format("mongodb://localhost:%d", server.bind().getPort()); + InetSocketAddress address = server.bind(); + mongoURI = String.format("mongodb://localhost:%d", address.getPort()); client = new MongoClient(new MongoClientURI(mongoURI)); context.registerInjectActivateService(new MongoDBClient(), "mongoURI", mongoURI); From 68a7070e946a769883234a5d1639200ba0f5048f Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Thu, 28 Feb 2019 09:05:06 +0100 Subject: [PATCH 18/63] Add test in json file --- .../aet/cleaner/CleanerIntegrationTest.java | 14 +- .../integrationTest/metadata/test1.json | 207 ++++++++++++++++++ 2 files changed, 219 insertions(+), 2 deletions(-) create mode 100644 core/cleaner/src/test/resources/integrationTest/metadata/test1.json diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 9a4605c3d..59f80c7cd 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -32,8 +32,11 @@ import com.mongodb.MongoClientURI; import de.bwaldvogel.mongo.MongoServer; import de.bwaldvogel.mongo.backend.memory.MemoryBackend; +import java.io.IOException; import java.net.InetSocketAddress; +import org.apache.commons.io.IOUtils; import org.apache.sling.testing.mock.osgi.junit.OsgiContext; +import org.bson.Document; import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -84,8 +87,9 @@ public void setUp() { } @Test - public void test() throws JobExecutionException { - setUpJobData(1L, 1L, "company", "project"); + public void test() throws JobExecutionException, IOException { + setUpJobData(1L, 1L, "testCompany", "testProject"); + insertDataToDb("testCompany","testProject"); new CleanerJob().execute(jobExecutionContext); } @@ -108,4 +112,10 @@ private void setUpJobData(Long versionsToKeep, Long maxAge, String companyName, when(jobDetail.getJobDataMap()).thenReturn(jobData); when(jobExecutionContext.getJobDetail()).thenReturn(jobDetail); } + + private void insertDataToDb(String companyName, String projectName) throws IOException { + String dbName = String.format("%s_%s", companyName, projectName); + String json = IOUtils.toString(this.getClass().getResource("/integrationTest/metadata/test1.json"), "UTF-8"); + client.getDatabase(dbName).getCollection("metadata").insertOne(Document.parse(json)); + } } \ No newline at end of file diff --git a/core/cleaner/src/test/resources/integrationTest/metadata/test1.json b/core/cleaner/src/test/resources/integrationTest/metadata/test1.json new file mode 100644 index 000000000..7082ebeb3 --- /dev/null +++ b/core/cleaner/src/test/resources/integrationTest/metadata/test1.json @@ -0,0 +1,207 @@ +{ + "_id" : ObjectId("5c7524ed495d5008b3e6824e"), + "correlationId" : "company-project-test-suite-1551181031545", + "company" : "company", + "project" : "project", + "name" : "test-suite", + "version" : 2, + "runTimestamp" : NumberLong(1551181031545), + "finishedTimestamp" : NumberLong(1551181037358), + "statistics" : { + "duration" : 5813 + }, + "tests" : [ + { + "name" : "first-test", + "proxy" : "rest", + "urls" : [ + { + "name" : "https://en.wikipedia.org/wiki/Main_Page?a=b&c=d", + "url" : "https://en.wikipedia.org/wiki/Main_Page?a=b&c=d", + "collectionStats" : { + "duration" : 1925 + }, + "steps" : [ + { + "index" : 0, + "name" : "open", + "stepResult" : { + "status" : "PAGE_OPENED" + }, + "statistics" : { + "duration" : 1209 + }, + "type" : "open" + }, + { + "index" : 1, + "name" : "resolution", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 120 + }, + "type" : "resolution", + "parameters" : { + "height" : "600", + "width" : "800" + } + }, + { + "index" : 2, + "name" : "sleep", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 150 + }, + "type" : "sleep", + "parameters" : { + "duration" : "150" + } + }, + { + "index" : 3, + "name" : "screen", + "pattern" : "5c7524c5495d5008b3e68247", + "stepResult" : { + "status" : "COLLECTED", + "artifactId" : "5c7524ec495d5008b3e6824a", + "payload" : { + "layoutExclude" : { + "notFoundElements" : [ + "#hplogo" + ] + } + } + }, + "statistics" : { + "duration" : 314 + }, + "comparators" : [ + { + "stepResult" : { + "status" : "FAILED", + "rebaseable" : true, + "acceptable" : true, + "artifactId" : "5c7524ed495d5008b3e6824c", + "data" : { + "heightDifference" : "0", + "widthDifference" : "0", + "collectTimestamp" : "1551181037347", + "percentagePixelDifference" : "31.496875", + "pixelDifference" : "151185", + "patternTimestamp" : "1551180997482", + "excludeMessage" : "The following elements to be excluded have not been found on page: ", + "notFoundCssElements" : "#hplogo" + } + }, + "statistics" : { + "duration" : 412 + }, + "type" : "screen", + "parameters" : { + "comparator" : "layout" + } + } + ], + "type" : "screen", + "parameters" : { + "exclude-elements" : "#hplogo" + } + } + ], + "isReran" : false + }, + { + "name" : "https://google.com", + "url" : "https://google.com", + "collectionStats" : { + "duration" : 2021 + }, + "steps" : [ + { + "index" : 0, + "name" : "open", + "stepResult" : { + "status" : "PAGE_OPENED" + }, + "statistics" : { + "duration" : 1446 + }, + "type" : "open" + }, + { + "index" : 1, + "name" : "resolution", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 114 + }, + "type" : "resolution", + "parameters" : { + "height" : "600", + "width" : "800" + } + }, + { + "index" : 2, + "name" : "sleep", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 150 + }, + "type" : "sleep", + "parameters" : { + "duration" : "150" + } + }, + { + "index" : 3, + "name" : "screen", + "pattern" : "5c7524c1495d5008b3e68245", + "stepResult" : { + "status" : "DUPLICATES_PATTERN", + "artifactId" : "5c7524c1495d5008b3e68245" + }, + "statistics" : { + "duration" : 234 + }, + "comparators" : [ + { + "stepResult" : { + "status" : "PASSED", + "rebaseable" : false, + "acceptable" : false, + "data" : { + "collectTimestamp" : "1551181037047", + "patternTimestamp" : "1551180993118" + } + }, + "statistics" : { + "duration" : 6 + }, + "type" : "screen", + "parameters" : { + "comparator" : "layout" + } + } + ], + "type" : "screen", + "parameters" : { + "exclude-elements" : "#hplogo" + } + } + ], + "isReran" : false + } + ] + } + ] +} \ No newline at end of file From f0fa2e66a2f565d95c081df15297d6aa6993edfd Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Thu, 28 Feb 2019 09:23:25 +0100 Subject: [PATCH 19/63] Change structure --- .../cognifide/aet/cleaner/CleanerIntegrationTest.java | 6 +++--- .../projectA/artifacts.chunks/chunk1.json | 6 ++++++ .../projectA/artifacts.files/file1.json | 10 ++++++++++ .../integrationTest/{ => projectA}/metadata/test1.json | 0 4 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 core/cleaner/src/test/resources/integrationTest/projectA/artifacts.chunks/chunk1.json create mode 100644 core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/file1.json rename core/cleaner/src/test/resources/integrationTest/{ => projectA}/metadata/test1.json (100%) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 59f80c7cd..dfe0b19c1 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -88,8 +88,8 @@ public void setUp() { @Test public void test() throws JobExecutionException, IOException { - setUpJobData(1L, 1L, "testCompany", "testProject"); - insertDataToDb("testCompany","testProject"); + setUpJobData(1L, 1L, "companyTest", "projectTest"); + insertDataToDb("companyTest","projectTest"); new CleanerJob().execute(jobExecutionContext); } @@ -115,7 +115,7 @@ private void setUpJobData(Long versionsToKeep, Long maxAge, String companyName, private void insertDataToDb(String companyName, String projectName) throws IOException { String dbName = String.format("%s_%s", companyName, projectName); - String json = IOUtils.toString(this.getClass().getResource("/integrationTest/metadata/test1.json"), "UTF-8"); + String json = IOUtils.toString(this.getClass().getResource("/integrationTest/projectA/metadata/test1.json"), "UTF-8"); client.getDatabase(dbName).getCollection("metadata").insertOne(Document.parse(json)); } } \ No newline at end of file diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.chunks/chunk1.json b/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.chunks/chunk1.json new file mode 100644 index 000000000..ad4ae2e29 --- /dev/null +++ b/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.chunks/chunk1.json @@ -0,0 +1,6 @@ +{ + "_id" : ObjectId("5c7524c1495d5008b3e68246"), + "files_id" : ObjectId("5c7524c1495d5008b3e68245"), + "n" : 0, + "data" : { "$binary" :"mockedChunk", "$type" : "00"} +} \ No newline at end of file diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/file1.json b/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/file1.json new file mode 100644 index 000000000..f82892d1d --- /dev/null +++ b/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/file1.json @@ -0,0 +1,10 @@ +{ + "_id" : ObjectId("5c7524c1495d5008b3e68245"), + "filename" : null, + "aliases" : null, + "chunkSize" : NumberLong(261120), + "uploadDate" : ISODate("2019-02-26T11:36:33.118Z"), + "length" : NumberLong(25254), + "contentType" : "image/png", + "md5" : "fde31b5c87109abc68b0e3a456e5015a" +} \ No newline at end of file diff --git a/core/cleaner/src/test/resources/integrationTest/metadata/test1.json b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test1.json similarity index 100% rename from core/cleaner/src/test/resources/integrationTest/metadata/test1.json rename to core/cleaner/src/test/resources/integrationTest/projectA/metadata/test1.json From 95ff93a6a3f5c93d035abf7f6d2993f6b8964c1c Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Thu, 28 Feb 2019 09:49:11 +0100 Subject: [PATCH 20/63] Add inserting all collections to db --- .../aet/cleaner/CleanerIntegrationTest.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index dfe0b19c1..01bde4592 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -32,9 +32,10 @@ import com.mongodb.MongoClientURI; import de.bwaldvogel.mongo.MongoServer; import de.bwaldvogel.mongo.backend.memory.MemoryBackend; +import java.io.File; import java.io.IOException; import java.net.InetSocketAddress; -import org.apache.commons.io.IOUtils; +import org.apache.commons.io.FileUtils; import org.apache.sling.testing.mock.osgi.junit.OsgiContext; import org.bson.Document; import org.junit.After; @@ -89,7 +90,7 @@ public void setUp() { @Test public void test() throws JobExecutionException, IOException { setUpJobData(1L, 1L, "companyTest", "projectTest"); - insertDataToDb("companyTest","projectTest"); + insertDataToDb("companyTest", "projectTest"); new CleanerJob().execute(jobExecutionContext); } @@ -115,7 +116,16 @@ private void setUpJobData(Long versionsToKeep, Long maxAge, String companyName, private void insertDataToDb(String companyName, String projectName) throws IOException { String dbName = String.format("%s_%s", companyName, projectName); - String json = IOUtils.toString(this.getClass().getResource("/integrationTest/projectA/metadata/test1.json"), "UTF-8"); - client.getDatabase(dbName).getCollection("metadata").insertOne(Document.parse(json)); + String[] collections = new String[]{"artifacts.chunks", "artifacts.files", "metadata"}; + for (String collection : collections) { + File[] collectionDirs = new File( + getClass().getResource("/integrationTest/projectA/" + collection).getFile()).listFiles(); + if (collectionDirs != null) { + for (File file : collectionDirs) { + String json = FileUtils.readFileToString(file, "UTF-8"); + client.getDatabase(dbName).getCollection(collection).insertOne(Document.parse(json)); + } + } + } } } \ No newline at end of file From 65d5da9717fae2cce7a5a4223a02db36b2a35bb3 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Thu, 28 Feb 2019 09:59:16 +0100 Subject: [PATCH 21/63] Separate db names and filesystem paths --- .../aet/cleaner/CleanerIntegrationTest.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 01bde4592..ffbed8ce9 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -90,7 +90,7 @@ public void setUp() { @Test public void test() throws JobExecutionException, IOException { setUpJobData(1L, 1L, "companyTest", "projectTest"); - insertDataToDb("companyTest", "projectTest"); + insertDataToDb("companyTest", "projectTest", "projectA"); new CleanerJob().execute(jobExecutionContext); } @@ -114,16 +114,16 @@ private void setUpJobData(Long versionsToKeep, Long maxAge, String companyName, when(jobExecutionContext.getJobDetail()).thenReturn(jobDetail); } - private void insertDataToDb(String companyName, String projectName) throws IOException { + private void insertDataToDb(String companyName, String projectName, String projectDataDir) throws IOException { String dbName = String.format("%s_%s", companyName, projectName); - String[] collections = new String[]{"artifacts.chunks", "artifacts.files", "metadata"}; - for (String collection : collections) { - File[] collectionDirs = new File( - getClass().getResource("/integrationTest/projectA/" + collection).getFile()).listFiles(); - if (collectionDirs != null) { - for (File file : collectionDirs) { + String[] collectionNames = new String[]{"artifacts.chunks", "artifacts.files", "metadata"}; + for (String collectionName : collectionNames) { + String collectionDir = String.format("/integrationTest/%s/%s", projectDataDir, collectionName); + File[] collectionFiles = new File(getClass().getResource(collectionDir).getFile()).listFiles(); + if (collectionFiles != null) { + for (File file : collectionFiles) { String json = FileUtils.readFileToString(file, "UTF-8"); - client.getDatabase(dbName).getCollection(collection).insertOne(Document.parse(json)); + client.getDatabase(dbName).getCollection(collectionName).insertOne(Document.parse(json)); } } } From 80490bc843662598443ad2bd1d9f5a40f9d8eea5 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Thu, 28 Feb 2019 12:47:25 +0100 Subject: [PATCH 22/63] Add first test --- .../aet/cleaner/CleanerIntegrationTest.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index ffbed8ce9..4e60379b6 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -15,6 +15,7 @@ */ package com.cognifide.aet.cleaner; +import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.when; import com.cognifide.aet.cleaner.processors.FetchAllProjectSuitesProcessor; @@ -89,9 +90,11 @@ public void setUp() { @Test public void test() throws JobExecutionException, IOException { - setUpJobData(1L, 1L, "companyTest", "projectTest"); - insertDataToDb("companyTest", "projectTest", "projectA"); + setUpJobData(1L, 1L, "company", "project"); + insertDataToDb("company", "project", "projectA"); new CleanerJob().execute(jobExecutionContext); + assertEquals(1, + client.getDatabase("company_project").getCollection("metadata").countDocuments()); } @After @@ -114,12 +117,15 @@ private void setUpJobData(Long versionsToKeep, Long maxAge, String companyName, when(jobExecutionContext.getJobDetail()).thenReturn(jobDetail); } - private void insertDataToDb(String companyName, String projectName, String projectDataDir) throws IOException { + private void insertDataToDb(String companyName, String projectName, String projectDataDir) + throws IOException { String dbName = String.format("%s_%s", companyName, projectName); String[] collectionNames = new String[]{"artifacts.chunks", "artifacts.files", "metadata"}; for (String collectionName : collectionNames) { - String collectionDir = String.format("/integrationTest/%s/%s", projectDataDir, collectionName); - File[] collectionFiles = new File(getClass().getResource(collectionDir).getFile()).listFiles(); + String collectionDir = String + .format("/integrationTest/%s/%s", projectDataDir, collectionName); + File[] collectionFiles = new File(getClass().getResource(collectionDir).getFile()) + .listFiles(); if (collectionFiles != null) { for (File file : collectionFiles) { String json = FileUtils.readFileToString(file, "UTF-8"); From e91f13bdafa7719f6f88085a59b8370b79e162f2 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Thu, 28 Feb 2019 12:47:56 +0100 Subject: [PATCH 23/63] Change suite version --- .../test/resources/integrationTest/projectA/metadata/test1.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test1.json b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test1.json index 7082ebeb3..34b648b16 100644 --- a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test1.json +++ b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test1.json @@ -4,7 +4,7 @@ "company" : "company", "project" : "project", "name" : "test-suite", - "version" : 2, + "version" : 1, "runTimestamp" : NumberLong(1551181031545), "finishedTimestamp" : NumberLong(1551181037358), "statistics" : { From 98ceeb7512f5a6a79d6bfaea51bc5af3f2e716c5 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Fri, 1 Mar 2019 08:18:06 +0100 Subject: [PATCH 24/63] Add localDateTimeProvider interface to facilitate testing --- .../SuitesRemovePredicateProcessor.java | 7 ++++- .../filters/SuiteRemoveCondition.java | 9 +++--- .../cleaner/time/LocalDateTimeProvider.java | 24 +++++++++++++++ .../aet/cleaner/time/SystemLocalDateTime.java | 29 +++++++++++++++++++ .../aet/cleaner/CleanerIntegrationTest.java | 2 ++ .../filters/SuiteRemoveConditionTest.java | 19 ++++++------ 6 files changed, 76 insertions(+), 14 deletions(-) create mode 100644 core/cleaner/src/main/java/com/cognifide/aet/cleaner/time/LocalDateTimeProvider.java create mode 100644 core/cleaner/src/main/java/com/cognifide/aet/cleaner/time/SystemLocalDateTime.java diff --git a/core/cleaner/src/main/java/com/cognifide/aet/cleaner/processors/SuitesRemovePredicateProcessor.java b/core/cleaner/src/main/java/com/cognifide/aet/cleaner/processors/SuitesRemovePredicateProcessor.java index 5996a2c8c..9a018ba3b 100644 --- a/core/cleaner/src/main/java/com/cognifide/aet/cleaner/processors/SuitesRemovePredicateProcessor.java +++ b/core/cleaner/src/main/java/com/cognifide/aet/cleaner/processors/SuitesRemovePredicateProcessor.java @@ -20,6 +20,7 @@ import com.cognifide.aet.cleaner.processors.exchange.AllSuiteVersionsMessageBody; import com.cognifide.aet.cleaner.processors.exchange.SuiteMessageBody; import com.cognifide.aet.cleaner.processors.filters.SuiteRemoveCondition; +import com.cognifide.aet.cleaner.time.LocalDateTimeProvider; import com.cognifide.aet.communication.api.metadata.Suite; import com.cognifide.aet.vs.DBKey; import com.google.common.base.Function; @@ -29,6 +30,7 @@ import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,6 +40,9 @@ public class SuitesRemovePredicateProcessor implements Processor { private static final Logger LOGGER = LoggerFactory .getLogger(SuitesRemovePredicateProcessor.class); + @Reference + private LocalDateTimeProvider dateTimeProvider; + @Override @SuppressWarnings("unchecked") public void process(Exchange exchange) throws Exception { @@ -53,7 +58,7 @@ public void process(Exchange exchange) throws Exception { suiteVersions.size(), dbKey); final SuiteRemoveCondition removeCondition = new SuiteRemoveCondition(suiteVersions, - cleanerContext); + cleanerContext, dateTimeProvider); final ImmutableList body = FluentIterable.from(suiteVersions).transform(new Function() { diff --git a/core/cleaner/src/main/java/com/cognifide/aet/cleaner/processors/filters/SuiteRemoveCondition.java b/core/cleaner/src/main/java/com/cognifide/aet/cleaner/processors/filters/SuiteRemoveCondition.java index 7aef9ee8c..7b7c419f4 100644 --- a/core/cleaner/src/main/java/com/cognifide/aet/cleaner/processors/filters/SuiteRemoveCondition.java +++ b/core/cleaner/src/main/java/com/cognifide/aet/cleaner/processors/filters/SuiteRemoveCondition.java @@ -16,6 +16,7 @@ package com.cognifide.aet.cleaner.processors.filters; import com.cognifide.aet.cleaner.context.CleanerContext; +import com.cognifide.aet.cleaner.time.LocalDateTimeProvider; import com.cognifide.aet.communication.api.metadata.Suite; import com.google.common.collect.Ordering; import java.time.LocalDateTime; @@ -45,9 +46,9 @@ public int compare(Suite o1, Suite o2) { private final Long minKeepVersion; public SuiteRemoveCondition(final Collection suiteRunVersions, - final CleanerContext cleanerContext) { + final CleanerContext cleanerContext, LocalDateTimeProvider dateTimeProvider) { minKeepVersion = getMinKeepVersion(suiteRunVersions, cleanerContext); - removeTimestamp = getRemoveTimestamp(cleanerContext); + removeTimestamp = getRemoveTimestamp(cleanerContext, dateTimeProvider); } public boolean evaluate(final Suite suite) { @@ -86,10 +87,10 @@ private Long getMinKeepVersion(final Collection suiteRunVersions, return minVersionToKeep; } - private Long getRemoveTimestamp(CleanerContext cleanerContext) { + private Long getRemoveTimestamp(CleanerContext cleanerContext, LocalDateTimeProvider dateTimeProvider) { Long removeBeforeTimestamp = null; if (cleanerContext.getRemoveOlderThan() != null) { - LocalDateTime now = LocalDateTime.now(ZoneOffset.UTC); + LocalDateTime now = dateTimeProvider.now(ZoneOffset.UTC); int daysToKeep = cleanerContext.getRemoveOlderThan().intValue(); LocalDateTime then = now.minusDays(daysToKeep); removeBeforeTimestamp = then.toInstant(ZoneOffset.UTC).toEpochMilli(); diff --git a/core/cleaner/src/main/java/com/cognifide/aet/cleaner/time/LocalDateTimeProvider.java b/core/cleaner/src/main/java/com/cognifide/aet/cleaner/time/LocalDateTimeProvider.java new file mode 100644 index 000000000..1814d1495 --- /dev/null +++ b/core/cleaner/src/main/java/com/cognifide/aet/cleaner/time/LocalDateTimeProvider.java @@ -0,0 +1,24 @@ +/** + * AET + * + * Copyright (C) 2013 Cognifide Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.cognifide.aet.cleaner.time; + +import java.time.LocalDateTime; +import java.time.ZoneId; + +public interface LocalDateTimeProvider { + + LocalDateTime now(ZoneId zone); +} diff --git a/core/cleaner/src/main/java/com/cognifide/aet/cleaner/time/SystemLocalDateTime.java b/core/cleaner/src/main/java/com/cognifide/aet/cleaner/time/SystemLocalDateTime.java new file mode 100644 index 000000000..5811316b7 --- /dev/null +++ b/core/cleaner/src/main/java/com/cognifide/aet/cleaner/time/SystemLocalDateTime.java @@ -0,0 +1,29 @@ +/** + * AET + * + * Copyright (C) 2013 Cognifide Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.cognifide.aet.cleaner.time; + +import java.time.LocalDateTime; +import java.time.ZoneId; +import org.osgi.service.component.annotations.Component; + +@Component(service = LocalDateTimeProvider.class) +public class SystemLocalDateTime implements LocalDateTimeProvider { + + @Override + public LocalDateTime now(ZoneId zone) { + return LocalDateTime.now(zone); + } +} diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 4e60379b6..108c810c9 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -41,6 +41,7 @@ import org.bson.Document; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -52,6 +53,7 @@ import org.quartz.JobExecutionException; @RunWith(MockitoJUnitRunner.class) +@Ignore public class CleanerIntegrationTest { @Rule diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/filters/SuiteRemoveConditionTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/filters/SuiteRemoveConditionTest.java index bc4315b27..4ecf0c7a8 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/filters/SuiteRemoveConditionTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/filters/SuiteRemoveConditionTest.java @@ -20,6 +20,7 @@ import static org.mockito.Mockito.when; import com.cognifide.aet.cleaner.context.CleanerContext; +import com.cognifide.aet.cleaner.time.SystemLocalDateTime; import com.cognifide.aet.communication.api.metadata.Suite; import com.cognifide.aet.communication.api.metadata.Suite.Timestamp; import com.googlecode.zohhak.api.Configure; @@ -51,7 +52,7 @@ public void evaluate_whenOnlyOneSuite_expectFalseNoMatterConditions(String allSu final List suites = SUITES_LIST_COERCER.toList(allSuitesVersions); SuiteRemoveCondition condition = new SuiteRemoveCondition(suites, - mockRemoveConditions(removeOlderThan, keepNVersions)); + mockRemoveConditions(removeOlderThan, keepNVersions), new SystemLocalDateTime()); final boolean remove = condition .evaluate(mockSuiteVersionAndCreatedDate(evaluatedSuite, createdDaysAgo)); assertFalse(remove); @@ -81,7 +82,7 @@ public void evaluate_when8SuitesVersionsRemoveOldVersions_expectTrue(String allS final List suites = SUITES_LIST_COERCER.toList(allSuitesVersions); SuiteRemoveCondition condition = new SuiteRemoveCondition(suites, - mockRemoveConditions(removeOlderThan, keepNVersions)); + mockRemoveConditions(removeOlderThan, keepNVersions), new SystemLocalDateTime()); final boolean remove = condition .evaluate(mockSuiteVersionAndCreatedDate(evaluatedSuite, createdDaysAgo)); assertTrue(remove); @@ -107,7 +108,7 @@ public void evaluate_when8SuitesVersionsKeepLastVersions_expectFalse(String allS final List suites = SUITES_LIST_COERCER.toList(allSuitesVersions); SuiteRemoveCondition condition = new SuiteRemoveCondition(suites, - mockRemoveConditions(removeOlderThan, keepNVersions)); + mockRemoveConditions(removeOlderThan, keepNVersions), new SystemLocalDateTime()); final boolean remove = condition .evaluate(mockSuiteVersionAndCreatedDate(evaluatedSuite, createdDaysAgo)); assertFalse(remove); @@ -135,7 +136,7 @@ public void evaluate_when8SuitesRemoveOlderThanButAlwaysKeepLatestVersion_expect final List suites = SUITES_LIST_COERCER.toList(allSuitesVersions); SuiteRemoveCondition condition = new SuiteRemoveCondition(suites, - mockRemoveConditions(removeOlderThan, keepNVersions)); + mockRemoveConditions(removeOlderThan, keepNVersions), new SystemLocalDateTime()); final boolean remove = condition .evaluate(mockSuiteVersionAndCreatedDate(evaluatedSuite, createdDaysAgo)); assertTrue(remove); @@ -154,7 +155,7 @@ public void evaluate_when8SuitesKeepNewerThan_expectFalse(String allSuitesVersio final List suites = SUITES_LIST_COERCER.toList(allSuitesVersions); SuiteRemoveCondition condition = new SuiteRemoveCondition(suites, - mockRemoveConditions(removeOlderThan, keepNVersions)); + mockRemoveConditions(removeOlderThan, keepNVersions), new SystemLocalDateTime()); final boolean remove = condition .evaluate(mockSuiteVersionAndCreatedDate(evaluatedSuite, createdDaysAgo)); assertFalse(remove); @@ -173,7 +174,7 @@ public void evaluate_when8SuitesKeepNewerThanAndAtLeastXVersions_expectTrue( final List suites = SUITES_LIST_COERCER.toList(allSuitesVersions); SuiteRemoveCondition condition = new SuiteRemoveCondition(suites, - mockRemoveConditions(removeOlderThan, keepNVersions)); + mockRemoveConditions(removeOlderThan, keepNVersions), new SystemLocalDateTime()); final boolean remove = condition .evaluate(mockSuiteVersionAndCreatedDate(evaluatedSuite, createdDaysAgo)); assertTrue(remove); @@ -192,7 +193,7 @@ public void evaluate_when8SuitesKeepNewerThanAndAtLeastXVersions_expectFalse( final List suites = SUITES_LIST_COERCER.toList(allSuitesVersions); SuiteRemoveCondition condition = new SuiteRemoveCondition(suites, - mockRemoveConditions(removeOlderThan, keepNVersions)); + mockRemoveConditions(removeOlderThan, keepNVersions), new SystemLocalDateTime()); final boolean remove = condition .evaluate(mockSuiteVersionAndCreatedDate(evaluatedSuite, createdDaysAgo)); assertFalse(remove); @@ -207,7 +208,7 @@ public void evaluate_whenDuplicatedVersion_expectRemoveOnlyOldVersions(String al final List suites = SUITES_LIST_COERCER.toList(allSuitesVersions); SuiteRemoveCondition condition = new SuiteRemoveCondition(suites, - mockRemoveConditions(removeOlderThan, keepNVersions)); + mockRemoveConditions(removeOlderThan, keepNVersions), new SystemLocalDateTime()); final boolean remove = condition .evaluate(mockSuiteVersionAndCreatedDate(evaluatedSuite, createdDaysAgo)); assertTrue(remove); @@ -223,7 +224,7 @@ public void evaluate_whenDuplicatedVersion_expectKeepNewestVersion(String allSui final List suites = SUITES_LIST_COERCER.toList(allSuitesVersions); SuiteRemoveCondition condition = new SuiteRemoveCondition(suites, - mockRemoveConditions(removeOlderThan, keepNVersions)); + mockRemoveConditions(removeOlderThan, keepNVersions), new SystemLocalDateTime()); final boolean remove = condition .evaluate(mockSuiteVersionAndCreatedDate(evaluatedSuite, createdDaysAgo)); assertFalse(remove); From e76ea13268f422b9b7b63bda5c4cc0b241582b08 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Fri, 1 Mar 2019 09:04:06 +0100 Subject: [PATCH 25/63] Add second suite --- .../projectA/metadata/test2.json | 207 ++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json new file mode 100644 index 000000000..d9a404444 --- /dev/null +++ b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json @@ -0,0 +1,207 @@ +{ + "_id" : ObjectId("5c7524ed495d5008b3e6824b"), + "correlationId" : "company-project-test-suite-1551181031550", + "company" : "company", + "project" : "project", + "name" : "test-suite", + "version" : 1, + "runTimestamp" : NumberLong(1551181031550), + "finishedTimestamp" : NumberLong(1551181037358), + "statistics" : { + "duration" : 5813 + }, + "tests" : [ + { + "name" : "first-test", + "proxy" : "rest", + "urls" : [ + { + "name" : "https://en.wikipedia.org/wiki/Main_Page?a=b&c=d", + "url" : "https://en.wikipedia.org/wiki/Main_Page?a=b&c=d", + "collectionStats" : { + "duration" : 1925 + }, + "steps" : [ + { + "index" : 0, + "name" : "open", + "stepResult" : { + "status" : "PAGE_OPENED" + }, + "statistics" : { + "duration" : 1209 + }, + "type" : "open" + }, + { + "index" : 1, + "name" : "resolution", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 120 + }, + "type" : "resolution", + "parameters" : { + "height" : "600", + "width" : "800" + } + }, + { + "index" : 2, + "name" : "sleep", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 150 + }, + "type" : "sleep", + "parameters" : { + "duration" : "150" + } + }, + { + "index" : 3, + "name" : "screen", + "pattern" : "5c7524c5495d5008b3e68247", + "stepResult" : { + "status" : "COLLECTED", + "artifactId" : "5c7524ec495d5008b3e6824a", + "payload" : { + "layoutExclude" : { + "notFoundElements" : [ + "#hplogo" + ] + } + } + }, + "statistics" : { + "duration" : 314 + }, + "comparators" : [ + { + "stepResult" : { + "status" : "FAILED", + "rebaseable" : true, + "acceptable" : true, + "artifactId" : "5c7524ed495d5008b3e6824c", + "data" : { + "heightDifference" : "0", + "widthDifference" : "0", + "collectTimestamp" : "1551181037347", + "percentagePixelDifference" : "31.496875", + "pixelDifference" : "151185", + "patternTimestamp" : "1551180997482", + "excludeMessage" : "The following elements to be excluded have not been found on page: ", + "notFoundCssElements" : "#hplogo" + } + }, + "statistics" : { + "duration" : 412 + }, + "type" : "screen", + "parameters" : { + "comparator" : "layout" + } + } + ], + "type" : "screen", + "parameters" : { + "exclude-elements" : "#hplogo" + } + } + ], + "isReran" : false + }, + { + "name" : "https://google.com", + "url" : "https://google.com", + "collectionStats" : { + "duration" : 2021 + }, + "steps" : [ + { + "index" : 0, + "name" : "open", + "stepResult" : { + "status" : "PAGE_OPENED" + }, + "statistics" : { + "duration" : 1446 + }, + "type" : "open" + }, + { + "index" : 1, + "name" : "resolution", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 114 + }, + "type" : "resolution", + "parameters" : { + "height" : "600", + "width" : "800" + } + }, + { + "index" : 2, + "name" : "sleep", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 150 + }, + "type" : "sleep", + "parameters" : { + "duration" : "150" + } + }, + { + "index" : 3, + "name" : "screen", + "pattern" : "5c7524c1495d5008b3e68245", + "stepResult" : { + "status" : "DUPLICATES_PATTERN", + "artifactId" : "5c7524c1495d5008b3e68245" + }, + "statistics" : { + "duration" : 234 + }, + "comparators" : [ + { + "stepResult" : { + "status" : "PASSED", + "rebaseable" : false, + "acceptable" : false, + "data" : { + "collectTimestamp" : "1551181037047", + "patternTimestamp" : "1551180993118" + } + }, + "statistics" : { + "duration" : 6 + }, + "type" : "screen", + "parameters" : { + "comparator" : "layout" + } + } + ], + "type" : "screen", + "parameters" : { + "exclude-elements" : "#hplogo" + } + } + ], + "isReran" : false + } + ] + } + ] +} \ No newline at end of file From 5a02e1f6447fb70fd34e510859cfe6612964402b Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Fri, 1 Mar 2019 09:23:40 +0100 Subject: [PATCH 26/63] Add mocked current datetime for testing --- .../cognifide/aet/cleaner/CleanerIntegrationTest.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 108c810c9..88567efbf 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -25,6 +25,7 @@ import com.cognifide.aet.cleaner.processors.StartMetadataCleanupProcessor; import com.cognifide.aet.cleaner.processors.SuitesRemovePredicateProcessor; import com.cognifide.aet.cleaner.route.MetadataCleanerRouteBuilder; +import com.cognifide.aet.cleaner.time.LocalDateTimeProvider; import com.cognifide.aet.vs.artifacts.ArtifactsDAOMongoDBImpl; import com.cognifide.aet.vs.metadata.MetadataDAOMongoDBImpl; import com.cognifide.aet.vs.mongodb.MongoDBClient; @@ -36,12 +37,13 @@ import java.io.File; import java.io.IOException; import java.net.InetSocketAddress; +import java.time.Instant; +import java.time.LocalDateTime; import org.apache.commons.io.FileUtils; import org.apache.sling.testing.mock.osgi.junit.OsgiContext; import org.bson.Document; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -53,9 +55,10 @@ import org.quartz.JobExecutionException; @RunWith(MockitoJUnitRunner.class) -@Ignore public class CleanerIntegrationTest { + private static final Long MOCKED_CURRENT_TIMESTAMP = 1551428149000L; //March 1, 2019 + @Rule public final OsgiContext context = new OsgiContext(); @@ -68,6 +71,8 @@ public class CleanerIntegrationTest { private MongoServer server; private String mongoURI; private MetadataCleanerRouteBuilder metadataCleanerRouteBuilder; + private LocalDateTimeProvider mockedDateTimeProvider = zone -> LocalDateTime + .ofInstant(Instant.ofEpochMilli(MOCKED_CURRENT_TIMESTAMP), zone); @Before public void setUp() { @@ -80,6 +85,7 @@ public void setUp() { context.registerInjectActivateService(new MetadataDAOMongoDBImpl()); context.registerInjectActivateService(new ArtifactsDAOMongoDBImpl()); + context.registerService(LocalDateTimeProvider.class, mockedDateTimeProvider); context.registerInjectActivateService(new StartMetadataCleanupProcessor()); context.registerInjectActivateService(new FetchAllProjectSuitesProcessor()); context.registerInjectActivateService(new SuitesRemovePredicateProcessor()); From 919db960f369c582e5ff26fd4b88b5d80f708c7c Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Fri, 1 Mar 2019 09:42:54 +0100 Subject: [PATCH 27/63] Switch to ZohhakRunner --- .../aet/cleaner/CleanerIntegrationTest.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 88567efbf..97b1135b9 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -30,6 +30,7 @@ import com.cognifide.aet.vs.metadata.MetadataDAOMongoDBImpl; import com.cognifide.aet.vs.mongodb.MongoDBClient; import com.google.common.collect.ImmutableMap; +import com.googlecode.zohhak.api.runners.ZohhakRunner; import com.mongodb.MongoClient; import com.mongodb.MongoClientURI; import de.bwaldvogel.mongo.MongoServer; @@ -47,14 +48,13 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.Mockito; import org.quartz.JobDataMap; import org.quartz.JobDetail; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; -@RunWith(MockitoJUnitRunner.class) +@RunWith(ZohhakRunner.class) public class CleanerIntegrationTest { private static final Long MOCKED_CURRENT_TIMESTAMP = 1551428149000L; //March 1, 2019 @@ -62,10 +62,9 @@ public class CleanerIntegrationTest { @Rule public final OsgiContext context = new OsgiContext(); - @Mock - JobExecutionContext jobExecutionContext; - @Mock - JobDetail jobDetail; + private JobExecutionContext jobExecutionContext = Mockito.mock(JobExecutionContext.class); + + private JobDetail jobDetail = Mockito.mock(JobDetail.class); private MongoClient client; private MongoServer server; @@ -97,7 +96,7 @@ public void setUp() { } @Test - public void test() throws JobExecutionException, IOException { + public void clean_whenAllSuitesYounger_keepAllSuites() throws JobExecutionException, IOException { setUpJobData(1L, 1L, "company", "project"); insertDataToDb("company", "project", "projectA"); new CleanerJob().execute(jobExecutionContext); From 98793026618213356f0740e1b5c66063577ce17f Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Fri, 1 Mar 2019 09:47:20 +0100 Subject: [PATCH 28/63] Change timestamps --- .../resources/integrationTest/projectA/metadata/test1.json | 6 +++--- .../resources/integrationTest/projectA/metadata/test2.json | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test1.json b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test1.json index 34b648b16..a353ccdba 100644 --- a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test1.json +++ b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test1.json @@ -1,12 +1,12 @@ { "_id" : ObjectId("5c7524ed495d5008b3e6824e"), - "correlationId" : "company-project-test-suite-1551181031545", + "correlationId" : "company-project-test-suite-1551255349000", "company" : "company", "project" : "project", "name" : "test-suite", "version" : 1, - "runTimestamp" : NumberLong(1551181031545), - "finishedTimestamp" : NumberLong(1551181037358), + "runTimestamp" : NumberLong(1551255349000), + "finishedTimestamp" : NumberLong(1551255359000), "statistics" : { "duration" : 5813 }, diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json index d9a404444..c9d989670 100644 --- a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json +++ b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json @@ -1,12 +1,12 @@ { "_id" : ObjectId("5c7524ed495d5008b3e6824b"), - "correlationId" : "company-project-test-suite-1551181031550", + "correlationId" : "company-project-test-suite-1551341749000", "company" : "company", "project" : "project", "name" : "test-suite", "version" : 1, - "runTimestamp" : NumberLong(1551181031550), - "finishedTimestamp" : NumberLong(1551181037358), + "runTimestamp" : NumberLong(1551341749000), + "finishedTimestamp" : NumberLong(1551341759000), "statistics" : { "duration" : 5813 }, From 73600d8f7eb1386cc73e6c9f845457fe7600df30 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Fri, 1 Mar 2019 10:00:33 +0100 Subject: [PATCH 29/63] Fix suite version --- .../test/resources/integrationTest/projectA/metadata/test2.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json index c9d989670..873e0eb2b 100644 --- a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json +++ b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json @@ -4,7 +4,7 @@ "company" : "company", "project" : "project", "name" : "test-suite", - "version" : 1, + "version" : 2, "runTimestamp" : NumberLong(1551341749000), "finishedTimestamp" : NumberLong(1551341759000), "statistics" : { From b193afe4b2686011409207352e67535c29d5709c Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Fri, 1 Mar 2019 10:17:57 +0100 Subject: [PATCH 30/63] Add first tests --- .../aet/cleaner/CleanerIntegrationTest.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 97b1135b9..31cf266a8 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -30,6 +30,7 @@ import com.cognifide.aet.vs.metadata.MetadataDAOMongoDBImpl; import com.cognifide.aet.vs.mongodb.MongoDBClient; import com.google.common.collect.ImmutableMap; +import com.googlecode.zohhak.api.TestWith; import com.googlecode.zohhak.api.runners.ZohhakRunner; import com.mongodb.MongoClient; import com.mongodb.MongoClientURI; @@ -46,7 +47,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Rule; -import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mockito; import org.quartz.JobDataMap; @@ -68,7 +68,6 @@ public class CleanerIntegrationTest { private MongoClient client; private MongoServer server; - private String mongoURI; private MetadataCleanerRouteBuilder metadataCleanerRouteBuilder; private LocalDateTimeProvider mockedDateTimeProvider = zone -> LocalDateTime .ofInstant(Instant.ofEpochMilli(MOCKED_CURRENT_TIMESTAMP), zone); @@ -77,7 +76,7 @@ public class CleanerIntegrationTest { public void setUp() { server = new MongoServer(new MemoryBackend()); InetSocketAddress address = server.bind(); - mongoURI = String.format("mongodb://localhost:%d", address.getPort()); + String mongoURI = String.format("mongodb://localhost:%d", address.getPort()); client = new MongoClient(new MongoClientURI(mongoURI)); context.registerInjectActivateService(new MongoDBClient(), "mongoURI", mongoURI); @@ -95,13 +94,21 @@ public void setUp() { .registerInjectActivateService(new MetadataCleanerRouteBuilder()); } - @Test - public void clean_whenAllSuitesYounger_keepAllSuites() throws JobExecutionException, IOException { - setUpJobData(1L, 1L, "company", "project"); - insertDataToDb("company", "project", "projectA"); + @TestWith({ + "1,3,projectA", + "1,4,projectA", + "1,5,projectA" + }) + public void clean_whenAllSuitesYounger_keepAllSuites(Long versionsToKeep, Long maxAge, + String projectDataDir) throws JobExecutionException, IOException { + setUpJobData(versionsToKeep, maxAge, "company", "project"); + insertDataToDb("company", "project", projectDataDir); + Long documentsBefore = client.getDatabase("company_project").getCollection("metadata") + .countDocuments(); new CleanerJob().execute(jobExecutionContext); - assertEquals(1, - client.getDatabase("company_project").getCollection("metadata").countDocuments()); + Long documentsAfter = client.getDatabase("company_project").getCollection("metadata") + .countDocuments(); + assertEquals(documentsBefore, documentsAfter); } @After From 8834a69d4b8591d711b1eb59a814473188139d8d Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Fri, 1 Mar 2019 10:24:16 +0100 Subject: [PATCH 31/63] Refactoring --- .../aet/cleaner/CleanerIntegrationTest.java | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 31cf266a8..fa1aa2a48 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -58,12 +58,15 @@ public class CleanerIntegrationTest { private static final Long MOCKED_CURRENT_TIMESTAMP = 1551428149000L; //March 1, 2019 + private static final String MOCKED_COMPANY_NAME = "company"; + private static final String MOCKED_PROJECT_NAME = "project"; + private static final String MOCKED_DB_NAME = String + .format("%s_%s", MOCKED_COMPANY_NAME, MOCKED_PROJECT_NAME); @Rule public final OsgiContext context = new OsgiContext(); private JobExecutionContext jobExecutionContext = Mockito.mock(JobExecutionContext.class); - private JobDetail jobDetail = Mockito.mock(JobDetail.class); private MongoClient client; @@ -101,12 +104,11 @@ public void setUp() { }) public void clean_whenAllSuitesYounger_keepAllSuites(Long versionsToKeep, Long maxAge, String projectDataDir) throws JobExecutionException, IOException { - setUpJobData(versionsToKeep, maxAge, "company", "project"); - insertDataToDb("company", "project", projectDataDir); - Long documentsBefore = client.getDatabase("company_project").getCollection("metadata") + setUpDataForTest(versionsToKeep, maxAge, projectDataDir); + Long documentsBefore = client.getDatabase(MOCKED_DB_NAME).getCollection("metadata") .countDocuments(); new CleanerJob().execute(jobExecutionContext); - Long documentsAfter = client.getDatabase("company_project").getCollection("metadata") + Long documentsAfter = client.getDatabase(MOCKED_DB_NAME).getCollection("metadata") .countDocuments(); assertEquals(documentsBefore, documentsAfter); } @@ -117,23 +119,26 @@ public void tearDown() { server.shutdown(); } - private void setUpJobData(Long versionsToKeep, Long maxAge, String companyName, - String projectName) { + private void setUpDataForTest(Long versionsToKeep, Long maxAge, String projectDataDir) + throws IOException { + createJobData(versionsToKeep, maxAge); + insertDataToDb(projectDataDir); + } + + private void createJobData(Long versionsToKeep, Long maxAge) { final JobDataMap jobData = new JobDataMap(ImmutableMap.builder() .put(CleanerJob.KEY_ROUTE_BUILDER, metadataCleanerRouteBuilder) .put(CleanerJob.KEY_KEEP_N_VERSIONS, versionsToKeep) .put(CleanerJob.KEY_REMOVE_OLDER_THAN, maxAge) - .put(CleanerJob.KEY_COMPANY_FILTER, companyName) - .put(CleanerJob.KEY_PROJECT_FILTER, projectName) + .put(CleanerJob.KEY_COMPANY_FILTER, MOCKED_COMPANY_NAME) + .put(CleanerJob.KEY_PROJECT_FILTER, MOCKED_PROJECT_NAME) .put(CleanerJob.KEY_DRY_RUN, false) .build()); when(jobDetail.getJobDataMap()).thenReturn(jobData); when(jobExecutionContext.getJobDetail()).thenReturn(jobDetail); } - private void insertDataToDb(String companyName, String projectName, String projectDataDir) - throws IOException { - String dbName = String.format("%s_%s", companyName, projectName); + private void insertDataToDb(String projectDataDir) throws IOException { String[] collectionNames = new String[]{"artifacts.chunks", "artifacts.files", "metadata"}; for (String collectionName : collectionNames) { String collectionDir = String @@ -143,7 +148,8 @@ private void insertDataToDb(String companyName, String projectName, String proje if (collectionFiles != null) { for (File file : collectionFiles) { String json = FileUtils.readFileToString(file, "UTF-8"); - client.getDatabase(dbName).getCollection(collectionName).insertOne(Document.parse(json)); + client.getDatabase(MOCKED_DB_NAME).getCollection(collectionName) + .insertOne(Document.parse(json)); } } } From 2013f1d82b2b4ec2c101ef6a0580c407569320a1 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Fri, 1 Mar 2019 10:42:14 +0100 Subject: [PATCH 32/63] Add test for all tests younger --- .../aet/cleaner/CleanerIntegrationTest.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index fa1aa2a48..10d694f17 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -105,14 +105,27 @@ public void setUp() { public void clean_whenAllSuitesYounger_keepAllSuites(Long versionsToKeep, Long maxAge, String projectDataDir) throws JobExecutionException, IOException { setUpDataForTest(versionsToKeep, maxAge, projectDataDir); - Long documentsBefore = client.getDatabase(MOCKED_DB_NAME).getCollection("metadata") + long documentsBefore = client.getDatabase(MOCKED_DB_NAME).getCollection("metadata") .countDocuments(); new CleanerJob().execute(jobExecutionContext); - Long documentsAfter = client.getDatabase(MOCKED_DB_NAME).getCollection("metadata") + long documentsAfter = client.getDatabase(MOCKED_DB_NAME).getCollection("metadata") .countDocuments(); assertEquals(documentsBefore, documentsAfter); } + @TestWith({ + "1,0,projectA", + "1,1,projectA" + }) + public void clean_whenAllSuitesOlder_keepNewestSuite(Long versionsToKeep, Long maxAge, + String projectDataDir) throws JobExecutionException, IOException { + setUpDataForTest(versionsToKeep, maxAge, projectDataDir); + new CleanerJob().execute(jobExecutionContext); + long documentsAfter = client.getDatabase(MOCKED_DB_NAME).getCollection("metadata") + .countDocuments(); + assertEquals(1, documentsAfter); + } + @After public void tearDown() { client.close(); From 0dfc5172e245905fae1d56c4cb2b5f3aec43ef45 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Fri, 1 Mar 2019 12:14:18 +0100 Subject: [PATCH 33/63] Refactoring --- .../aet/cleaner/CleanerIntegrationTest.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 10d694f17..65debb526 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -34,6 +34,7 @@ import com.googlecode.zohhak.api.runners.ZohhakRunner; import com.mongodb.MongoClient; import com.mongodb.MongoClientURI; +import com.mongodb.client.MongoCollection; import de.bwaldvogel.mongo.MongoServer; import de.bwaldvogel.mongo.backend.memory.MemoryBackend; import java.io.File; @@ -105,11 +106,9 @@ public void setUp() { public void clean_whenAllSuitesYounger_keepAllSuites(Long versionsToKeep, Long maxAge, String projectDataDir) throws JobExecutionException, IOException { setUpDataForTest(versionsToKeep, maxAge, projectDataDir); - long documentsBefore = client.getDatabase(MOCKED_DB_NAME).getCollection("metadata") - .countDocuments(); + long documentsBefore = getMetadataDocs().countDocuments(); new CleanerJob().execute(jobExecutionContext); - long documentsAfter = client.getDatabase(MOCKED_DB_NAME).getCollection("metadata") - .countDocuments(); + long documentsAfter = getMetadataDocs().countDocuments(); assertEquals(documentsBefore, documentsAfter); } @@ -121,8 +120,7 @@ public void clean_whenAllSuitesOlder_keepNewestSuite(Long versionsToKeep, Long m String projectDataDir) throws JobExecutionException, IOException { setUpDataForTest(versionsToKeep, maxAge, projectDataDir); new CleanerJob().execute(jobExecutionContext); - long documentsAfter = client.getDatabase(MOCKED_DB_NAME).getCollection("metadata") - .countDocuments(); + long documentsAfter = getMetadataDocs().countDocuments(); assertEquals(1, documentsAfter); } @@ -167,4 +165,8 @@ private void insertDataToDb(String projectDataDir) throws IOException { } } } + + private MongoCollection getMetadataDocs() { + return client.getDatabase(MOCKED_DB_NAME).getCollection("metadata"); + } } \ No newline at end of file From 66f13bb098bba6c7b6e809d8c515bd86bb19bce6 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Fri, 1 Mar 2019 12:36:23 +0100 Subject: [PATCH 34/63] Remove chunks (mongoDB deletes them ootb with file doc) --- .../integrationTest/projectA/artifacts.chunks/chunk1.json | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 core/cleaner/src/test/resources/integrationTest/projectA/artifacts.chunks/chunk1.json diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.chunks/chunk1.json b/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.chunks/chunk1.json deleted file mode 100644 index ad4ae2e29..000000000 --- a/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.chunks/chunk1.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "_id" : ObjectId("5c7524c1495d5008b3e68246"), - "files_id" : ObjectId("5c7524c1495d5008b3e68245"), - "n" : 0, - "data" : { "$binary" :"mockedChunk", "$type" : "00"} -} \ No newline at end of file From 954900d8f0986192117a1d2a948ef97f14b39c81 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Fri, 1 Mar 2019 12:44:25 +0100 Subject: [PATCH 35/63] Add checking for artifacts --- .../aet/cleaner/CleanerIntegrationTest.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 65debb526..6a94670e8 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -106,10 +106,11 @@ public void setUp() { public void clean_whenAllSuitesYounger_keepAllSuites(Long versionsToKeep, Long maxAge, String projectDataDir) throws JobExecutionException, IOException { setUpDataForTest(versionsToKeep, maxAge, projectDataDir); - long documentsBefore = getMetadataDocs().countDocuments(); + long metadataCountBefore = getMetadataDocs().countDocuments(); + long artifactCountBefore = getArtifactDocs().countDocuments(); new CleanerJob().execute(jobExecutionContext); - long documentsAfter = getMetadataDocs().countDocuments(); - assertEquals(documentsBefore, documentsAfter); + assertEquals(metadataCountBefore, getMetadataDocs().countDocuments()); + assertEquals(artifactCountBefore, getArtifactDocs().countDocuments()); } @TestWith({ @@ -120,8 +121,8 @@ public void clean_whenAllSuitesOlder_keepNewestSuite(Long versionsToKeep, Long m String projectDataDir) throws JobExecutionException, IOException { setUpDataForTest(versionsToKeep, maxAge, projectDataDir); new CleanerJob().execute(jobExecutionContext); - long documentsAfter = getMetadataDocs().countDocuments(); - assertEquals(1, documentsAfter); + assertEquals(1, getMetadataDocs().countDocuments()); + assertEquals(1, getMetadataDocs().countDocuments()); } @After @@ -150,7 +151,7 @@ private void createJobData(Long versionsToKeep, Long maxAge) { } private void insertDataToDb(String projectDataDir) throws IOException { - String[] collectionNames = new String[]{"artifacts.chunks", "artifacts.files", "metadata"}; + String[] collectionNames = new String[]{"artifacts.files", "metadata"}; for (String collectionName : collectionNames) { String collectionDir = String .format("/integrationTest/%s/%s", projectDataDir, collectionName); @@ -169,4 +170,8 @@ private void insertDataToDb(String projectDataDir) throws IOException { private MongoCollection getMetadataDocs() { return client.getDatabase(MOCKED_DB_NAME).getCollection("metadata"); } + + private MongoCollection getArtifactDocs(){ + return client.getDatabase(MOCKED_DB_NAME).getCollection("artifacts.files"); + } } \ No newline at end of file From 86e59d8a7193a91c64b2ad1227e2997fa4e42d49 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Fri, 1 Mar 2019 12:54:24 +0100 Subject: [PATCH 36/63] Add test case for removing all --- .../com/cognifide/aet/cleaner/CleanerIntegrationTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 6a94670e8..454375058 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -99,9 +99,13 @@ public void setUp() { } @TestWith({ + //keeping based on age "1,3,projectA", "1,4,projectA", - "1,5,projectA" + "1,5,projectA", + //keeping based on versions + "100,0,projectA", + "100,1,projectA" }) public void clean_whenAllSuitesYounger_keepAllSuites(Long versionsToKeep, Long maxAge, String projectDataDir) throws JobExecutionException, IOException { From 7734bf729ba1a730693e5f2493d8fe9f8aa134b6 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Fri, 1 Mar 2019 12:57:12 +0100 Subject: [PATCH 37/63] Rename methods --- .../com/cognifide/aet/cleaner/CleanerIntegrationTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 454375058..19c91447f 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -107,7 +107,7 @@ public void setUp() { "100,0,projectA", "100,1,projectA" }) - public void clean_whenAllSuitesYounger_keepAllSuites(Long versionsToKeep, Long maxAge, + public void clean_whenKeepAllSuites_removeNothing(Long versionsToKeep, Long maxAge, String projectDataDir) throws JobExecutionException, IOException { setUpDataForTest(versionsToKeep, maxAge, projectDataDir); long metadataCountBefore = getMetadataDocs().countDocuments(); @@ -121,7 +121,7 @@ public void clean_whenAllSuitesYounger_keepAllSuites(Long versionsToKeep, Long m "1,0,projectA", "1,1,projectA" }) - public void clean_whenAllSuitesOlder_keepNewestSuite(Long versionsToKeep, Long maxAge, + public void clean_whenAllSuitesOlder_keepOnlyNewestSuite(Long versionsToKeep, Long maxAge, String projectDataDir) throws JobExecutionException, IOException { setUpDataForTest(versionsToKeep, maxAge, projectDataDir); new CleanerJob().execute(jobExecutionContext); From 2b06e6b67867058cbbb2b94a91c35e7b67969488 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Fri, 1 Mar 2019 12:59:20 +0100 Subject: [PATCH 38/63] Remove redundant test cases --- .../com/cognifide/aet/cleaner/CleanerIntegrationTest.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 19c91447f..171cf1771 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -101,11 +101,10 @@ public void setUp() { @TestWith({ //keeping based on age "1,3,projectA", - "1,4,projectA", - "1,5,projectA", //keeping based on versions "100,0,projectA", - "100,1,projectA" + //both + "100,3,projectA" }) public void clean_whenKeepAllSuites_removeNothing(Long versionsToKeep, Long maxAge, String projectDataDir) throws JobExecutionException, IOException { From baddf154ed7a93cfbfc5b3d6a5846a3d9f5867c7 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Tue, 5 Mar 2019 07:53:09 +0100 Subject: [PATCH 39/63] Add more test files --- .../projectA/metadata/test1.json | 8 +- .../projectA/metadata/test2.json | 6 +- .../projectA/metadata/test3.json | 207 ++++++++++++++++++ .../projectA/metadata/test4.json | 207 ++++++++++++++++++ .../projectA/metadata/test5.json | 207 ++++++++++++++++++ 5 files changed, 628 insertions(+), 7 deletions(-) create mode 100644 core/cleaner/src/test/resources/integrationTest/projectA/metadata/test3.json create mode 100644 core/cleaner/src/test/resources/integrationTest/projectA/metadata/test4.json create mode 100644 core/cleaner/src/test/resources/integrationTest/projectA/metadata/test5.json diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test1.json b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test1.json index a353ccdba..f8547f9fb 100644 --- a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test1.json +++ b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test1.json @@ -1,12 +1,12 @@ { - "_id" : ObjectId("5c7524ed495d5008b3e6824e"), - "correlationId" : "company-project-test-suite-1551255349000", + "_id" : ObjectId("5c7524ed495d5008b3e6824a"), + "correlationId" : "company-project-test-suite-1551341749000", "company" : "company", "project" : "project", "name" : "test-suite", "version" : 1, - "runTimestamp" : NumberLong(1551255349000), - "finishedTimestamp" : NumberLong(1551255359000), + "runTimestamp" : NumberLong(1551341749000), + "finishedTimestamp" : NumberLong(1551341759000), "statistics" : { "duration" : 5813 }, diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json index 873e0eb2b..4b444acb9 100644 --- a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json +++ b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json @@ -1,12 +1,12 @@ { "_id" : ObjectId("5c7524ed495d5008b3e6824b"), - "correlationId" : "company-project-test-suite-1551341749000", + "correlationId" : "company-project-test-suite-1551255349000", "company" : "company", "project" : "project", "name" : "test-suite", "version" : 2, - "runTimestamp" : NumberLong(1551341749000), - "finishedTimestamp" : NumberLong(1551341759000), + "runTimestamp" : NumberLong(1551255349000), + "finishedTimestamp" : NumberLong(1551255359000), "statistics" : { "duration" : 5813 }, diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test3.json b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test3.json new file mode 100644 index 000000000..0d36ff430 --- /dev/null +++ b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test3.json @@ -0,0 +1,207 @@ +{ + "_id" : ObjectId("5c7524ed495d5008b3e6824c"), + "correlationId" : "company-project-test-suite-1551168949000", + "company" : "company", + "project" : "project", + "name" : "test-suite", + "version" : 3, + "runTimestamp" : NumberLong(1551168949000), + "finishedTimestamp" : NumberLong(1551168959000), + "statistics" : { + "duration" : 5813 + }, + "tests" : [ + { + "name" : "first-test", + "proxy" : "rest", + "urls" : [ + { + "name" : "https://en.wikipedia.org/wiki/Main_Page?a=b&c=d", + "url" : "https://en.wikipedia.org/wiki/Main_Page?a=b&c=d", + "collectionStats" : { + "duration" : 1925 + }, + "steps" : [ + { + "index" : 0, + "name" : "open", + "stepResult" : { + "status" : "PAGE_OPENED" + }, + "statistics" : { + "duration" : 1209 + }, + "type" : "open" + }, + { + "index" : 1, + "name" : "resolution", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 120 + }, + "type" : "resolution", + "parameters" : { + "height" : "600", + "width" : "800" + } + }, + { + "index" : 2, + "name" : "sleep", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 150 + }, + "type" : "sleep", + "parameters" : { + "duration" : "150" + } + }, + { + "index" : 3, + "name" : "screen", + "pattern" : "5c7524c5495d5008b3e68247", + "stepResult" : { + "status" : "COLLECTED", + "artifactId" : "5c7524ec495d5008b3e6824a", + "payload" : { + "layoutExclude" : { + "notFoundElements" : [ + "#hplogo" + ] + } + } + }, + "statistics" : { + "duration" : 314 + }, + "comparators" : [ + { + "stepResult" : { + "status" : "FAILED", + "rebaseable" : true, + "acceptable" : true, + "artifactId" : "5c7524ed495d5008b3e6824c", + "data" : { + "heightDifference" : "0", + "widthDifference" : "0", + "collectTimestamp" : "1551181037347", + "percentagePixelDifference" : "31.496875", + "pixelDifference" : "151185", + "patternTimestamp" : "1551180997482", + "excludeMessage" : "The following elements to be excluded have not been found on page: ", + "notFoundCssElements" : "#hplogo" + } + }, + "statistics" : { + "duration" : 412 + }, + "type" : "screen", + "parameters" : { + "comparator" : "layout" + } + } + ], + "type" : "screen", + "parameters" : { + "exclude-elements" : "#hplogo" + } + } + ], + "isReran" : false + }, + { + "name" : "https://google.com", + "url" : "https://google.com", + "collectionStats" : { + "duration" : 2021 + }, + "steps" : [ + { + "index" : 0, + "name" : "open", + "stepResult" : { + "status" : "PAGE_OPENED" + }, + "statistics" : { + "duration" : 1446 + }, + "type" : "open" + }, + { + "index" : 1, + "name" : "resolution", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 114 + }, + "type" : "resolution", + "parameters" : { + "height" : "600", + "width" : "800" + } + }, + { + "index" : 2, + "name" : "sleep", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 150 + }, + "type" : "sleep", + "parameters" : { + "duration" : "150" + } + }, + { + "index" : 3, + "name" : "screen", + "pattern" : "5c7524c1495d5008b3e68245", + "stepResult" : { + "status" : "DUPLICATES_PATTERN", + "artifactId" : "5c7524c1495d5008b3e68245" + }, + "statistics" : { + "duration" : 234 + }, + "comparators" : [ + { + "stepResult" : { + "status" : "PASSED", + "rebaseable" : false, + "acceptable" : false, + "data" : { + "collectTimestamp" : "1551181037047", + "patternTimestamp" : "1551180993118" + } + }, + "statistics" : { + "duration" : 6 + }, + "type" : "screen", + "parameters" : { + "comparator" : "layout" + } + } + ], + "type" : "screen", + "parameters" : { + "exclude-elements" : "#hplogo" + } + } + ], + "isReran" : false + } + ] + } + ] +} \ No newline at end of file diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test4.json b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test4.json new file mode 100644 index 000000000..db075f532 --- /dev/null +++ b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test4.json @@ -0,0 +1,207 @@ +{ + "_id" : ObjectId("5c7524ed495d5008b3e6824f"), + "correlationId" : "company-project-test-suite-1551082549000", + "company" : "company", + "project" : "project", + "name" : "test-suite", + "version" : 4, + "runTimestamp" : NumberLong(1551082549000), + "finishedTimestamp" : NumberLong(1551082559000), + "statistics" : { + "duration" : 5813 + }, + "tests" : [ + { + "name" : "first-test", + "proxy" : "rest", + "urls" : [ + { + "name" : "https://en.wikipedia.org/wiki/Main_Page?a=b&c=d", + "url" : "https://en.wikipedia.org/wiki/Main_Page?a=b&c=d", + "collectionStats" : { + "duration" : 1925 + }, + "steps" : [ + { + "index" : 0, + "name" : "open", + "stepResult" : { + "status" : "PAGE_OPENED" + }, + "statistics" : { + "duration" : 1209 + }, + "type" : "open" + }, + { + "index" : 1, + "name" : "resolution", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 120 + }, + "type" : "resolution", + "parameters" : { + "height" : "600", + "width" : "800" + } + }, + { + "index" : 2, + "name" : "sleep", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 150 + }, + "type" : "sleep", + "parameters" : { + "duration" : "150" + } + }, + { + "index" : 3, + "name" : "screen", + "pattern" : "5c7524c5495d5008b3e68247", + "stepResult" : { + "status" : "COLLECTED", + "artifactId" : "5c7524ec495d5008b3e6824a", + "payload" : { + "layoutExclude" : { + "notFoundElements" : [ + "#hplogo" + ] + } + } + }, + "statistics" : { + "duration" : 314 + }, + "comparators" : [ + { + "stepResult" : { + "status" : "FAILED", + "rebaseable" : true, + "acceptable" : true, + "artifactId" : "5c7524ed495d5008b3e6824c", + "data" : { + "heightDifference" : "0", + "widthDifference" : "0", + "collectTimestamp" : "1551181037347", + "percentagePixelDifference" : "31.496875", + "pixelDifference" : "151185", + "patternTimestamp" : "1551180997482", + "excludeMessage" : "The following elements to be excluded have not been found on page: ", + "notFoundCssElements" : "#hplogo" + } + }, + "statistics" : { + "duration" : 412 + }, + "type" : "screen", + "parameters" : { + "comparator" : "layout" + } + } + ], + "type" : "screen", + "parameters" : { + "exclude-elements" : "#hplogo" + } + } + ], + "isReran" : false + }, + { + "name" : "https://google.com", + "url" : "https://google.com", + "collectionStats" : { + "duration" : 2021 + }, + "steps" : [ + { + "index" : 0, + "name" : "open", + "stepResult" : { + "status" : "PAGE_OPENED" + }, + "statistics" : { + "duration" : 1446 + }, + "type" : "open" + }, + { + "index" : 1, + "name" : "resolution", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 114 + }, + "type" : "resolution", + "parameters" : { + "height" : "600", + "width" : "800" + } + }, + { + "index" : 2, + "name" : "sleep", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 150 + }, + "type" : "sleep", + "parameters" : { + "duration" : "150" + } + }, + { + "index" : 3, + "name" : "screen", + "pattern" : "5c7524c1495d5008b3e68245", + "stepResult" : { + "status" : "DUPLICATES_PATTERN", + "artifactId" : "5c7524c1495d5008b3e68245" + }, + "statistics" : { + "duration" : 234 + }, + "comparators" : [ + { + "stepResult" : { + "status" : "PASSED", + "rebaseable" : false, + "acceptable" : false, + "data" : { + "collectTimestamp" : "1551181037047", + "patternTimestamp" : "1551180993118" + } + }, + "statistics" : { + "duration" : 6 + }, + "type" : "screen", + "parameters" : { + "comparator" : "layout" + } + } + ], + "type" : "screen", + "parameters" : { + "exclude-elements" : "#hplogo" + } + } + ], + "isReran" : false + } + ] + } + ] +} \ No newline at end of file diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test5.json b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test5.json new file mode 100644 index 000000000..479481cee --- /dev/null +++ b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test5.json @@ -0,0 +1,207 @@ +{ + "_id" : ObjectId("5c7524ed495d5008b3e6825a"), + "correlationId" : "company-project-test-suite-1550996149000", + "company" : "company", + "project" : "project", + "name" : "test-suite", + "version" : 5, + "runTimestamp" : NumberLong(1550996149000), + "finishedTimestamp" : NumberLong(1550996159000), + "statistics" : { + "duration" : 5813 + }, + "tests" : [ + { + "name" : "first-test", + "proxy" : "rest", + "urls" : [ + { + "name" : "https://en.wikipedia.org/wiki/Main_Page?a=b&c=d", + "url" : "https://en.wikipedia.org/wiki/Main_Page?a=b&c=d", + "collectionStats" : { + "duration" : 1925 + }, + "steps" : [ + { + "index" : 0, + "name" : "open", + "stepResult" : { + "status" : "PAGE_OPENED" + }, + "statistics" : { + "duration" : 1209 + }, + "type" : "open" + }, + { + "index" : 1, + "name" : "resolution", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 120 + }, + "type" : "resolution", + "parameters" : { + "height" : "600", + "width" : "800" + } + }, + { + "index" : 2, + "name" : "sleep", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 150 + }, + "type" : "sleep", + "parameters" : { + "duration" : "150" + } + }, + { + "index" : 3, + "name" : "screen", + "pattern" : "5c7524c5495d5008b3e68247", + "stepResult" : { + "status" : "COLLECTED", + "artifactId" : "5c7524ec495d5008b3e6824a", + "payload" : { + "layoutExclude" : { + "notFoundElements" : [ + "#hplogo" + ] + } + } + }, + "statistics" : { + "duration" : 314 + }, + "comparators" : [ + { + "stepResult" : { + "status" : "FAILED", + "rebaseable" : true, + "acceptable" : true, + "artifactId" : "5c7524ed495d5008b3e6824c", + "data" : { + "heightDifference" : "0", + "widthDifference" : "0", + "collectTimestamp" : "1551181037347", + "percentagePixelDifference" : "31.496875", + "pixelDifference" : "151185", + "patternTimestamp" : "1551180997482", + "excludeMessage" : "The following elements to be excluded have not been found on page: ", + "notFoundCssElements" : "#hplogo" + } + }, + "statistics" : { + "duration" : 412 + }, + "type" : "screen", + "parameters" : { + "comparator" : "layout" + } + } + ], + "type" : "screen", + "parameters" : { + "exclude-elements" : "#hplogo" + } + } + ], + "isReran" : false + }, + { + "name" : "https://google.com", + "url" : "https://google.com", + "collectionStats" : { + "duration" : 2021 + }, + "steps" : [ + { + "index" : 0, + "name" : "open", + "stepResult" : { + "status" : "PAGE_OPENED" + }, + "statistics" : { + "duration" : 1446 + }, + "type" : "open" + }, + { + "index" : 1, + "name" : "resolution", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 114 + }, + "type" : "resolution", + "parameters" : { + "height" : "600", + "width" : "800" + } + }, + { + "index" : 2, + "name" : "sleep", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 150 + }, + "type" : "sleep", + "parameters" : { + "duration" : "150" + } + }, + { + "index" : 3, + "name" : "screen", + "pattern" : "5c7524c1495d5008b3e68245", + "stepResult" : { + "status" : "DUPLICATES_PATTERN", + "artifactId" : "5c7524c1495d5008b3e68245" + }, + "statistics" : { + "duration" : 234 + }, + "comparators" : [ + { + "stepResult" : { + "status" : "PASSED", + "rebaseable" : false, + "acceptable" : false, + "data" : { + "collectTimestamp" : "1551181037047", + "patternTimestamp" : "1551180993118" + } + }, + "statistics" : { + "duration" : 6 + }, + "type" : "screen", + "parameters" : { + "comparator" : "layout" + } + } + ], + "type" : "screen", + "parameters" : { + "exclude-elements" : "#hplogo" + } + } + ], + "isReran" : false + } + ] + } + ] +} \ No newline at end of file From 79383f4dcf925ea7a76af75550c9ba3eeb333caf Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Tue, 5 Mar 2019 07:56:58 +0100 Subject: [PATCH 40/63] Fix test cases --- .../com/cognifide/aet/cleaner/CleanerIntegrationTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 171cf1771..0355c6a95 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -100,11 +100,11 @@ public void setUp() { @TestWith({ //keeping based on age - "1,3,projectA", + "1,5,projectA", //keeping based on versions - "100,0,projectA", + "5,0,projectA", //both - "100,3,projectA" + "5,3,projectA" }) public void clean_whenKeepAllSuites_removeNothing(Long versionsToKeep, Long maxAge, String projectDataDir) throws JobExecutionException, IOException { From d2cf95ed1bce84b3363563439a6e9285b50fca3d Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Tue, 5 Mar 2019 09:01:40 +0100 Subject: [PATCH 41/63] Change test files to "AET in 10 minutes" example --- .../projectA/artifacts.files/file1.json | 8 +- .../projectA/metadata/test1.json | 189 +++++++++--------- .../projectA/metadata/test2.json | 187 +++++++++-------- .../projectA/metadata/test3.json | 189 +++++++++--------- .../projectA/metadata/test4.json | 186 +++++++++-------- .../projectA/metadata/test5.json | 186 +++++++++-------- 6 files changed, 464 insertions(+), 481 deletions(-) diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/file1.json b/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/file1.json index f82892d1d..7b4d51e9d 100644 --- a/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/file1.json +++ b/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/file1.json @@ -1,10 +1,10 @@ { - "_id" : ObjectId("5c7524c1495d5008b3e68245"), + "_id" : ObjectId("5c7e291f6798f408cf3d1da7"), "filename" : null, "aliases" : null, "chunkSize" : NumberLong(261120), - "uploadDate" : ISODate("2019-02-26T11:36:33.118Z"), - "length" : NumberLong(25254), + "uploadDate" : ISODate("2019-02-28T08:15:49.056Z"), + "length" : NumberLong(198205), "contentType" : "image/png", - "md5" : "fde31b5c87109abc68b0e3a456e5015a" + "md5" : "6e0ac5f99d67c5d707fb97993021f95a" } \ No newline at end of file diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test1.json b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test1.json index f8547f9fb..d9f01f1eb 100644 --- a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test1.json +++ b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test1.json @@ -1,5 +1,5 @@ { - "_id" : ObjectId("5c7524ed495d5008b3e6824a"), + "_id" : ObjectId("5c7e29206798f408cf3d1db3"), "correlationId" : "company-project-test-suite-1551341749000", "company" : "company", "project" : "project", @@ -8,7 +8,7 @@ "runTimestamp" : NumberLong(1551341749000), "finishedTimestamp" : NumberLong(1551341759000), "statistics" : { - "duration" : 5813 + "duration" : 6791 }, "tests" : [ { @@ -16,10 +16,10 @@ "proxy" : "rest", "urls" : [ { - "name" : "https://en.wikipedia.org/wiki/Main_Page?a=b&c=d", - "url" : "https://en.wikipedia.org/wiki/Main_Page?a=b&c=d", + "name" : "https://en.wikipedia.org/wiki/Main_Page", + "url" : "https://en.wikipedia.org/wiki/Main_Page", "collectionStats" : { - "duration" : 1925 + "duration" : 3368 }, "steps" : [ { @@ -29,7 +29,7 @@ "status" : "PAGE_OPENED" }, "statistics" : { - "duration" : 1209 + "duration" : 1232 }, "type" : "open" }, @@ -40,7 +40,7 @@ "status" : "MODIFIED" }, "statistics" : { - "duration" : 120 + "duration" : 115 }, "type" : "resolution", "parameters" : { @@ -55,51 +55,37 @@ "status" : "MODIFIED" }, "statistics" : { - "duration" : 150 + "duration" : 1505 }, "type" : "sleep", "parameters" : { - "duration" : "150" + "duration" : "1500" } }, { "index" : 3, "name" : "screen", - "pattern" : "5c7524c5495d5008b3e68247", + "pattern" : "5c7e291f6798f408cf3d1da7", "stepResult" : { - "status" : "COLLECTED", - "artifactId" : "5c7524ec495d5008b3e6824a", - "payload" : { - "layoutExclude" : { - "notFoundElements" : [ - "#hplogo" - ] - } - } + "status" : "DUPLICATES_PATTERN", + "artifactId" : "5c7e291f6798f408cf3d1da7" }, "statistics" : { - "duration" : 314 + "duration" : 281 }, "comparators" : [ { "stepResult" : { - "status" : "FAILED", - "rebaseable" : true, - "acceptable" : true, - "artifactId" : "5c7524ed495d5008b3e6824c", + "status" : "PASSED", + "rebaseable" : false, + "acceptable" : false, "data" : { - "heightDifference" : "0", - "widthDifference" : "0", - "collectTimestamp" : "1551181037347", - "percentagePixelDifference" : "31.496875", - "pixelDifference" : "151185", - "patternTimestamp" : "1551180997482", - "excludeMessage" : "The following elements to be excluded have not been found on page: ", - "notFoundCssElements" : "#hplogo" + "collectTimestamp" : "1551772127005", + "patternTimestamp" : "1551771935056" } }, "statistics" : { - "duration" : 412 + "duration" : 15 }, "type" : "screen", "parameters" : { @@ -107,99 +93,110 @@ } } ], - "type" : "screen", - "parameters" : { - "exclude-elements" : "#hplogo" - } - } - ], - "isReran" : false - }, - { - "name" : "https://google.com", - "url" : "https://google.com", - "collectionStats" : { - "duration" : 2021 - }, - "steps" : [ - { - "index" : 0, - "name" : "open", - "stepResult" : { - "status" : "PAGE_OPENED" - }, - "statistics" : { - "duration" : 1446 - }, - "type" : "open" + "type" : "screen" }, { - "index" : 1, - "name" : "resolution", + "index" : 4, + "name" : "source", + "pattern" : "5c7e291f6798f408cf3d1da9", "stepResult" : { - "status" : "MODIFIED" + "status" : "COLLECTED", + "artifactId" : "5c7e29de6798f408cf3d1db4" }, "statistics" : { - "duration" : 114 + "duration" : 127 }, - "type" : "resolution", - "parameters" : { - "height" : "600", - "width" : "800" - } + "comparators" : [ + { + "stepResult" : { + "status" : "FAILED", + "rebaseable" : false, + "acceptable" : false, + "artifactId" : "5c7e29df6798f408cf3d1dbc", + "data" : { + "warningCount" : "0", + "errorCount" : "19" + } + }, + "statistics" : { + "duration" : 223 + }, + "type" : "source", + "parameters" : { + "comparator" : "w3c-html5" + } + } + ], + "type" : "source" }, { - "index" : 2, - "name" : "sleep", + "index" : 5, + "name" : "status-codes", + "pattern" : "5c7e291f6798f408cf3d1dab", "stepResult" : { - "status" : "MODIFIED" + "status" : "COLLECTED", + "artifactId" : "5c7e29de6798f408cf3d1db6" }, "statistics" : { - "duration" : 150 + "duration" : 40 }, - "type" : "sleep", - "parameters" : { - "duration" : "150" - } + "comparators" : [ + { + "stepResult" : { + "status" : "PASSED", + "rebaseable" : false, + "acceptable" : false, + "artifactId" : "5c7e29df6798f408cf3d1dba" + }, + "statistics" : { + "duration" : 14 + }, + "type" : "status-codes", + "parameters" : { + "filterRange" : "400,600" + } + } + ], + "type" : "status-codes" }, { - "index" : 3, - "name" : "screen", - "pattern" : "5c7524c1495d5008b3e68245", + "index" : 6, + "name" : "js-errors", + "pattern" : "5c7e291f6798f408cf3d1dad", "stepResult" : { - "status" : "DUPLICATES_PATTERN", - "artifactId" : "5c7524c1495d5008b3e68245" + "status" : "COLLECTED", + "artifactId" : "5c7e29de6798f408cf3d1db8" }, "statistics" : { - "duration" : 234 + "duration" : 16 }, "comparators" : [ { "stepResult" : { "status" : "PASSED", "rebaseable" : false, - "acceptable" : false, - "data" : { - "collectTimestamp" : "1551181037047", - "patternTimestamp" : "1551180993118" - } + "acceptable" : false }, + "filters" : [ + { + "type" : "js-errors-filter", + "parameters" : { + "line" : "2", + "source" : "http://w.iplsc.com/external/jquery/jquery-1.8.3.js" + } + } + ], "statistics" : { - "duration" : 6 + "duration" : 16 }, - "type" : "screen", - "parameters" : { - "comparator" : "layout" - } + "type" : "js-errors" } ], - "type" : "screen", - "parameters" : { - "exclude-elements" : "#hplogo" - } + "type" : "js-errors" } ], - "isReran" : false + "isReran" : true, + "rerunTimestamp" : NumberLong(1551772120452) } ] } diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json index 4b444acb9..7f3e8aae8 100644 --- a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json +++ b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json @@ -1,5 +1,5 @@ { - "_id" : ObjectId("5c7524ed495d5008b3e6824b"), + "_id" : ObjectId("5c7e2b066798f408cf3d1dc8"), "correlationId" : "company-project-test-suite-1551255349000", "company" : "company", "project" : "project", @@ -8,7 +8,7 @@ "runTimestamp" : NumberLong(1551255349000), "finishedTimestamp" : NumberLong(1551255359000), "statistics" : { - "duration" : 5813 + "duration" : 6299 }, "tests" : [ { @@ -16,10 +16,10 @@ "proxy" : "rest", "urls" : [ { - "name" : "https://en.wikipedia.org/wiki/Main_Page?a=b&c=d", - "url" : "https://en.wikipedia.org/wiki/Main_Page?a=b&c=d", + "name" : "https://en.wikipedia.org/wiki/Main_Page", + "url" : "https://en.wikipedia.org/wiki/Main_Page", "collectionStats" : { - "duration" : 1925 + "duration" : 2839 }, "steps" : [ { @@ -29,7 +29,7 @@ "status" : "PAGE_OPENED" }, "statistics" : { - "duration" : 1209 + "duration" : 674 }, "type" : "open" }, @@ -40,7 +40,7 @@ "status" : "MODIFIED" }, "statistics" : { - "duration" : 120 + "duration" : 112 }, "type" : "resolution", "parameters" : { @@ -55,51 +55,37 @@ "status" : "MODIFIED" }, "statistics" : { - "duration" : 150 + "duration" : 1502 }, "type" : "sleep", "parameters" : { - "duration" : "150" + "duration" : "1500" } }, { "index" : 3, "name" : "screen", - "pattern" : "5c7524c5495d5008b3e68247", + "pattern" : "5c7e291f6798f408cf3d1da7", "stepResult" : { - "status" : "COLLECTED", - "artifactId" : "5c7524ec495d5008b3e6824a", - "payload" : { - "layoutExclude" : { - "notFoundElements" : [ - "#hplogo" - ] - } - } + "status" : "DUPLICATES_PATTERN", + "artifactId" : "5c7e291f6798f408cf3d1da7" }, "statistics" : { - "duration" : 314 + "duration" : 275 }, "comparators" : [ { "stepResult" : { - "status" : "FAILED", - "rebaseable" : true, - "acceptable" : true, - "artifactId" : "5c7524ed495d5008b3e6824c", + "status" : "PASSED", + "rebaseable" : false, + "acceptable" : false, "data" : { - "heightDifference" : "0", - "widthDifference" : "0", - "collectTimestamp" : "1551181037347", - "percentagePixelDifference" : "31.496875", - "pixelDifference" : "151185", - "patternTimestamp" : "1551180997482", - "excludeMessage" : "The following elements to be excluded have not been found on page: ", - "notFoundCssElements" : "#hplogo" + "collectTimestamp" : "1551772421150", + "patternTimestamp" : "1551771935056" } }, "statistics" : { - "duration" : 412 + "duration" : 7 }, "type" : "screen", "parameters" : { @@ -107,99 +93,110 @@ } } ], - "type" : "screen", - "parameters" : { - "exclude-elements" : "#hplogo" - } - } - ], - "isReran" : false - }, - { - "name" : "https://google.com", - "url" : "https://google.com", - "collectionStats" : { - "duration" : 2021 - }, - "steps" : [ - { - "index" : 0, - "name" : "open", - "stepResult" : { - "status" : "PAGE_OPENED" - }, - "statistics" : { - "duration" : 1446 - }, - "type" : "open" + "type" : "screen" }, { - "index" : 1, - "name" : "resolution", + "index" : 4, + "name" : "source", + "pattern" : "5c7e291f6798f408cf3d1da9", "stepResult" : { - "status" : "MODIFIED" + "status" : "COLLECTED", + "artifactId" : "5c7e2b056798f408cf3d1dbe" }, "statistics" : { - "duration" : 114 + "duration" : 122 }, - "type" : "resolution", - "parameters" : { - "height" : "600", - "width" : "800" - } + "comparators" : [ + { + "stepResult" : { + "status" : "FAILED", + "rebaseable" : false, + "acceptable" : false, + "artifactId" : "5c7e2b056798f408cf3d1dc6", + "data" : { + "warningCount" : "0", + "errorCount" : "19" + } + }, + "statistics" : { + "duration" : 226 + }, + "type" : "source", + "parameters" : { + "comparator" : "w3c-html5" + } + } + ], + "type" : "source" }, { - "index" : 2, - "name" : "sleep", + "index" : 5, + "name" : "status-codes", + "pattern" : "5c7e291f6798f408cf3d1dab", "stepResult" : { - "status" : "MODIFIED" + "status" : "COLLECTED", + "artifactId" : "5c7e2b056798f408cf3d1dc0" }, "statistics" : { - "duration" : 150 + "duration" : 39 }, - "type" : "sleep", - "parameters" : { - "duration" : "150" - } + "comparators" : [ + { + "stepResult" : { + "status" : "PASSED", + "rebaseable" : false, + "acceptable" : false, + "artifactId" : "5c7e2b056798f408cf3d1dc4" + }, + "statistics" : { + "duration" : 10 + }, + "type" : "status-codes", + "parameters" : { + "filterRange" : "400,600" + } + } + ], + "type" : "status-codes" }, { - "index" : 3, - "name" : "screen", - "pattern" : "5c7524c1495d5008b3e68245", + "index" : 6, + "name" : "js-errors", + "pattern" : "5c7e291f6798f408cf3d1dad", "stepResult" : { - "status" : "DUPLICATES_PATTERN", - "artifactId" : "5c7524c1495d5008b3e68245" + "status" : "COLLECTED", + "artifactId" : "5c7e2b056798f408cf3d1dc2" }, "statistics" : { - "duration" : 234 + "duration" : 14 }, "comparators" : [ { "stepResult" : { "status" : "PASSED", "rebaseable" : false, - "acceptable" : false, - "data" : { - "collectTimestamp" : "1551181037047", - "patternTimestamp" : "1551180993118" - } + "acceptable" : false }, + "filters" : [ + { + "type" : "js-errors-filter", + "parameters" : { + "line" : "2", + "source" : "http://w.iplsc.com/external/jquery/jquery-1.8.3.js" + } + } + ], "statistics" : { "duration" : 6 }, - "type" : "screen", - "parameters" : { - "comparator" : "layout" - } + "type" : "js-errors" } ], - "type" : "screen", - "parameters" : { - "exclude-elements" : "#hplogo" - } + "type" : "js-errors" } ], - "isReran" : false + "isReran" : true, + "rerunTimestamp" : NumberLong(1551772120452) } ] } diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test3.json b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test3.json index 0d36ff430..523255238 100644 --- a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test3.json +++ b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test3.json @@ -1,5 +1,5 @@ { - "_id" : ObjectId("5c7524ed495d5008b3e6824c"), + "_id" : ObjectId("5c7e2b316798f408cf3d1dd3"), "correlationId" : "company-project-test-suite-1551168949000", "company" : "company", "project" : "project", @@ -8,7 +8,7 @@ "runTimestamp" : NumberLong(1551168949000), "finishedTimestamp" : NumberLong(1551168959000), "statistics" : { - "duration" : 5813 + "duration" : 6309 }, "tests" : [ { @@ -16,10 +16,10 @@ "proxy" : "rest", "urls" : [ { - "name" : "https://en.wikipedia.org/wiki/Main_Page?a=b&c=d", - "url" : "https://en.wikipedia.org/wiki/Main_Page?a=b&c=d", + "name" : "https://en.wikipedia.org/wiki/Main_Page", + "url" : "https://en.wikipedia.org/wiki/Main_Page", "collectionStats" : { - "duration" : 1925 + "duration" : 2913 }, "steps" : [ { @@ -29,7 +29,7 @@ "status" : "PAGE_OPENED" }, "statistics" : { - "duration" : 1209 + "duration" : 739 }, "type" : "open" }, @@ -40,7 +40,7 @@ "status" : "MODIFIED" }, "statistics" : { - "duration" : 120 + "duration" : 112 }, "type" : "resolution", "parameters" : { @@ -55,51 +55,37 @@ "status" : "MODIFIED" }, "statistics" : { - "duration" : 150 + "duration" : 1500 }, "type" : "sleep", "parameters" : { - "duration" : "150" + "duration" : "1500" } }, { "index" : 3, "name" : "screen", - "pattern" : "5c7524c5495d5008b3e68247", + "pattern" : "5c7e291f6798f408cf3d1da7", "stepResult" : { - "status" : "COLLECTED", - "artifactId" : "5c7524ec495d5008b3e6824a", - "payload" : { - "layoutExclude" : { - "notFoundElements" : [ - "#hplogo" - ] - } - } + "status" : "DUPLICATES_PATTERN", + "artifactId" : "5c7e291f6798f408cf3d1da7" }, "statistics" : { - "duration" : 314 + "duration" : 293 }, "comparators" : [ { "stepResult" : { - "status" : "FAILED", - "rebaseable" : true, - "acceptable" : true, - "artifactId" : "5c7524ed495d5008b3e6824c", + "status" : "PASSED", + "rebaseable" : false, + "acceptable" : false, "data" : { - "heightDifference" : "0", - "widthDifference" : "0", - "collectTimestamp" : "1551181037347", - "percentagePixelDifference" : "31.496875", - "pixelDifference" : "151185", - "patternTimestamp" : "1551180997482", - "excludeMessage" : "The following elements to be excluded have not been found on page: ", - "notFoundCssElements" : "#hplogo" + "collectTimestamp" : "1551772464265", + "patternTimestamp" : "1551771935056" } }, "statistics" : { - "duration" : 412 + "duration" : 4 }, "type" : "screen", "parameters" : { @@ -107,99 +93,110 @@ } } ], - "type" : "screen", - "parameters" : { - "exclude-elements" : "#hplogo" - } - } - ], - "isReran" : false - }, - { - "name" : "https://google.com", - "url" : "https://google.com", - "collectionStats" : { - "duration" : 2021 - }, - "steps" : [ - { - "index" : 0, - "name" : "open", - "stepResult" : { - "status" : "PAGE_OPENED" - }, - "statistics" : { - "duration" : 1446 - }, - "type" : "open" + "type" : "screen" }, { - "index" : 1, - "name" : "resolution", + "index" : 4, + "name" : "source", + "pattern" : "5c7e291f6798f408cf3d1da9", "stepResult" : { - "status" : "MODIFIED" + "status" : "COLLECTED", + "artifactId" : "5c7e2b306798f408cf3d1dc9" }, "statistics" : { - "duration" : 114 + "duration" : 129 }, - "type" : "resolution", - "parameters" : { - "height" : "600", - "width" : "800" - } + "comparators" : [ + { + "stepResult" : { + "status" : "FAILED", + "rebaseable" : false, + "acceptable" : false, + "artifactId" : "5c7e2b306798f408cf3d1dd1", + "data" : { + "warningCount" : "0", + "errorCount" : "19" + } + }, + "statistics" : { + "duration" : 213 + }, + "type" : "source", + "parameters" : { + "comparator" : "w3c-html5" + } + } + ], + "type" : "source" }, { - "index" : 2, - "name" : "sleep", + "index" : 5, + "name" : "status-codes", + "pattern" : "5c7e291f6798f408cf3d1dab", "stepResult" : { - "status" : "MODIFIED" + "status" : "COLLECTED", + "artifactId" : "5c7e2b306798f408cf3d1dcb" }, "statistics" : { - "duration" : 150 + "duration" : 30 }, - "type" : "sleep", - "parameters" : { - "duration" : "150" - } + "comparators" : [ + { + "stepResult" : { + "status" : "PASSED", + "rebaseable" : false, + "acceptable" : false, + "artifactId" : "5c7e2b306798f408cf3d1dcf" + }, + "statistics" : { + "duration" : 34 + }, + "type" : "status-codes", + "parameters" : { + "filterRange" : "400,600" + } + } + ], + "type" : "status-codes" }, { - "index" : 3, - "name" : "screen", - "pattern" : "5c7524c1495d5008b3e68245", + "index" : 6, + "name" : "js-errors", + "pattern" : "5c7e291f6798f408cf3d1dad", "stepResult" : { - "status" : "DUPLICATES_PATTERN", - "artifactId" : "5c7524c1495d5008b3e68245" + "status" : "COLLECTED", + "artifactId" : "5c7e2b306798f408cf3d1dcd" }, "statistics" : { - "duration" : 234 + "duration" : 16 }, "comparators" : [ { "stepResult" : { "status" : "PASSED", "rebaseable" : false, - "acceptable" : false, - "data" : { - "collectTimestamp" : "1551181037047", - "patternTimestamp" : "1551180993118" - } + "acceptable" : false }, + "filters" : [ + { + "type" : "js-errors-filter", + "parameters" : { + "line" : "2", + "source" : "http://w.iplsc.com/external/jquery/jquery-1.8.3.js" + } + } + ], "statistics" : { - "duration" : 6 + "duration" : 10 }, - "type" : "screen", - "parameters" : { - "comparator" : "layout" - } + "type" : "js-errors" } ], - "type" : "screen", - "parameters" : { - "exclude-elements" : "#hplogo" - } + "type" : "js-errors" } ], - "isReran" : false + "isReran" : true, + "rerunTimestamp" : NumberLong(1551772120452) } ] } diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test4.json b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test4.json index db075f532..1e1010bc4 100644 --- a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test4.json +++ b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test4.json @@ -1,5 +1,5 @@ { - "_id" : ObjectId("5c7524ed495d5008b3e6824f"), + "_id" : ObjectId("5c7e2b8f6798f408cf3d1dde"), "correlationId" : "company-project-test-suite-1551082549000", "company" : "company", "project" : "project", @@ -8,7 +8,7 @@ "runTimestamp" : NumberLong(1551082549000), "finishedTimestamp" : NumberLong(1551082559000), "statistics" : { - "duration" : 5813 + "duration" : 6377 }, "tests" : [ { @@ -16,10 +16,10 @@ "proxy" : "rest", "urls" : [ { - "name" : "https://en.wikipedia.org/wiki/Main_Page?a=b&c=d", - "url" : "https://en.wikipedia.org/wiki/Main_Page?a=b&c=d", + "name" : "https://en.wikipedia.org/wiki/Main_Page", + "url" : "https://en.wikipedia.org/wiki/Main_Page", "collectionStats" : { - "duration" : 1925 + "duration" : 3052 }, "steps" : [ { @@ -29,7 +29,7 @@ "status" : "PAGE_OPENED" }, "statistics" : { - "duration" : 1209 + "duration" : 931 }, "type" : "open" }, @@ -40,7 +40,7 @@ "status" : "MODIFIED" }, "statistics" : { - "duration" : 120 + "duration" : 115 }, "type" : "resolution", "parameters" : { @@ -55,51 +55,37 @@ "status" : "MODIFIED" }, "statistics" : { - "duration" : 150 + "duration" : 1500 }, "type" : "sleep", "parameters" : { - "duration" : "150" + "duration" : "1500" } }, { "index" : 3, "name" : "screen", - "pattern" : "5c7524c5495d5008b3e68247", + "pattern" : "5c7e291f6798f408cf3d1da7", "stepResult" : { - "status" : "COLLECTED", - "artifactId" : "5c7524ec495d5008b3e6824a", - "payload" : { - "layoutExclude" : { - "notFoundElements" : [ - "#hplogo" - ] - } - } + "status" : "DUPLICATES_PATTERN", + "artifactId" : "5c7e291f6798f408cf3d1da7" }, "statistics" : { - "duration" : 314 + "duration" : 289 }, "comparators" : [ { "stepResult" : { - "status" : "FAILED", - "rebaseable" : true, - "acceptable" : true, - "artifactId" : "5c7524ed495d5008b3e6824c", + "status" : "PASSED", + "rebaseable" : false, + "acceptable" : false, "data" : { - "heightDifference" : "0", - "widthDifference" : "0", - "collectTimestamp" : "1551181037347", - "percentagePixelDifference" : "31.496875", - "pixelDifference" : "151185", - "patternTimestamp" : "1551180997482", - "excludeMessage" : "The following elements to be excluded have not been found on page: ", - "notFoundCssElements" : "#hplogo" + "collectTimestamp" : "1551772559111", + "patternTimestamp" : "1551771935056" } }, "statistics" : { - "duration" : 412 + "duration" : 10 }, "type" : "screen", "parameters" : { @@ -107,96 +93,106 @@ } } ], - "type" : "screen", - "parameters" : { - "exclude-elements" : "#hplogo" - } - } - ], - "isReran" : false - }, - { - "name" : "https://google.com", - "url" : "https://google.com", - "collectionStats" : { - "duration" : 2021 - }, - "steps" : [ - { - "index" : 0, - "name" : "open", - "stepResult" : { - "status" : "PAGE_OPENED" - }, - "statistics" : { - "duration" : 1446 - }, - "type" : "open" + "type" : "screen" }, { - "index" : 1, - "name" : "resolution", + "index" : 4, + "name" : "source", + "pattern" : "5c7e291f6798f408cf3d1da9", "stepResult" : { - "status" : "MODIFIED" + "status" : "COLLECTED", + "artifactId" : "5c7e2b8f6798f408cf3d1dd4" }, "statistics" : { - "duration" : 114 + "duration" : 121 }, - "type" : "resolution", - "parameters" : { - "height" : "600", - "width" : "800" - } + "comparators" : [ + { + "stepResult" : { + "status" : "FAILED", + "rebaseable" : false, + "acceptable" : false, + "artifactId" : "5c7e2b8f6798f408cf3d1ddc", + "data" : { + "warningCount" : "0", + "errorCount" : "19" + } + }, + "statistics" : { + "duration" : 205 + }, + "type" : "source", + "parameters" : { + "comparator" : "w3c-html5" + } + } + ], + "type" : "source" }, { - "index" : 2, - "name" : "sleep", + "index" : 5, + "name" : "status-codes", + "pattern" : "5c7e291f6798f408cf3d1dab", "stepResult" : { - "status" : "MODIFIED" + "status" : "COLLECTED", + "artifactId" : "5c7e2b8f6798f408cf3d1dd6" }, "statistics" : { - "duration" : 150 + "duration" : 20 }, - "type" : "sleep", - "parameters" : { - "duration" : "150" - } + "comparators" : [ + { + "stepResult" : { + "status" : "PASSED", + "rebaseable" : false, + "acceptable" : false, + "artifactId" : "5c7e2b8f6798f408cf3d1dda" + }, + "statistics" : { + "duration" : 27 + }, + "type" : "status-codes", + "parameters" : { + "filterRange" : "400,600" + } + } + ], + "type" : "status-codes" }, { - "index" : 3, - "name" : "screen", - "pattern" : "5c7524c1495d5008b3e68245", + "index" : 6, + "name" : "js-errors", + "pattern" : "5c7e291f6798f408cf3d1dad", "stepResult" : { - "status" : "DUPLICATES_PATTERN", - "artifactId" : "5c7524c1495d5008b3e68245" + "status" : "COLLECTED", + "artifactId" : "5c7e2b8f6798f408cf3d1dd8" }, "statistics" : { - "duration" : 234 + "duration" : 18 }, "comparators" : [ { "stepResult" : { "status" : "PASSED", "rebaseable" : false, - "acceptable" : false, - "data" : { - "collectTimestamp" : "1551181037047", - "patternTimestamp" : "1551180993118" - } + "acceptable" : false }, + "filters" : [ + { + "type" : "js-errors-filter", + "parameters" : { + "line" : "2", + "source" : "http://w.iplsc.com/external/jquery/jquery-1.8.3.js" + } + } + ], "statistics" : { - "duration" : 6 + "duration" : 9 }, - "type" : "screen", - "parameters" : { - "comparator" : "layout" - } + "type" : "js-errors" } ], - "type" : "screen", - "parameters" : { - "exclude-elements" : "#hplogo" - } + "type" : "js-errors" } ], "isReran" : false diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test5.json b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test5.json index 479481cee..c151189d7 100644 --- a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test5.json +++ b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test5.json @@ -1,5 +1,5 @@ { - "_id" : ObjectId("5c7524ed495d5008b3e6825a"), + "_id" : ObjectId("5c7e2bc46798f408cf3d1de9"), "correlationId" : "company-project-test-suite-1550996149000", "company" : "company", "project" : "project", @@ -8,7 +8,7 @@ "runTimestamp" : NumberLong(1550996149000), "finishedTimestamp" : NumberLong(1550996159000), "statistics" : { - "duration" : 5813 + "duration" : 6281 }, "tests" : [ { @@ -16,10 +16,10 @@ "proxy" : "rest", "urls" : [ { - "name" : "https://en.wikipedia.org/wiki/Main_Page?a=b&c=d", - "url" : "https://en.wikipedia.org/wiki/Main_Page?a=b&c=d", + "name" : "https://en.wikipedia.org/wiki/Main_Page", + "url" : "https://en.wikipedia.org/wiki/Main_Page", "collectionStats" : { - "duration" : 1925 + "duration" : 2952 }, "steps" : [ { @@ -29,7 +29,7 @@ "status" : "PAGE_OPENED" }, "statistics" : { - "duration" : 1209 + "duration" : 748 }, "type" : "open" }, @@ -40,7 +40,7 @@ "status" : "MODIFIED" }, "statistics" : { - "duration" : 120 + "duration" : 113 }, "type" : "resolution", "parameters" : { @@ -55,51 +55,37 @@ "status" : "MODIFIED" }, "statistics" : { - "duration" : 150 + "duration" : 1502 }, "type" : "sleep", "parameters" : { - "duration" : "150" + "duration" : "1500" } }, { "index" : 3, "name" : "screen", - "pattern" : "5c7524c5495d5008b3e68247", + "pattern" : "5c7e291f6798f408cf3d1da7", "stepResult" : { - "status" : "COLLECTED", - "artifactId" : "5c7524ec495d5008b3e6824a", - "payload" : { - "layoutExclude" : { - "notFoundElements" : [ - "#hplogo" - ] - } - } + "status" : "DUPLICATES_PATTERN", + "artifactId" : "5c7e291f6798f408cf3d1da7" }, "statistics" : { - "duration" : 314 + "duration" : 280 }, "comparators" : [ { "stepResult" : { - "status" : "FAILED", - "rebaseable" : true, - "acceptable" : true, - "artifactId" : "5c7524ed495d5008b3e6824c", + "status" : "PASSED", + "rebaseable" : false, + "acceptable" : false, "data" : { - "heightDifference" : "0", - "widthDifference" : "0", - "collectTimestamp" : "1551181037347", - "percentagePixelDifference" : "31.496875", - "pixelDifference" : "151185", - "patternTimestamp" : "1551180997482", - "excludeMessage" : "The following elements to be excluded have not been found on page: ", - "notFoundCssElements" : "#hplogo" + "collectTimestamp" : "1551772611875", + "patternTimestamp" : "1551771935056" } }, "statistics" : { - "duration" : 412 + "duration" : 17 }, "type" : "screen", "parameters" : { @@ -107,96 +93,106 @@ } } ], - "type" : "screen", - "parameters" : { - "exclude-elements" : "#hplogo" - } - } - ], - "isReran" : false - }, - { - "name" : "https://google.com", - "url" : "https://google.com", - "collectionStats" : { - "duration" : 2021 - }, - "steps" : [ - { - "index" : 0, - "name" : "open", - "stepResult" : { - "status" : "PAGE_OPENED" - }, - "statistics" : { - "duration" : 1446 - }, - "type" : "open" + "type" : "screen" }, { - "index" : 1, - "name" : "resolution", + "index" : 4, + "name" : "source", + "pattern" : "5c7e291f6798f408cf3d1da9", "stepResult" : { - "status" : "MODIFIED" + "status" : "COLLECTED", + "artifactId" : "5c7e2bc36798f408cf3d1ddf" }, "statistics" : { - "duration" : 114 + "duration" : 164 }, - "type" : "resolution", - "parameters" : { - "height" : "600", - "width" : "800" - } + "comparators" : [ + { + "stepResult" : { + "status" : "FAILED", + "rebaseable" : false, + "acceptable" : false, + "artifactId" : "5c7e2bc46798f408cf3d1de7", + "data" : { + "warningCount" : "0", + "errorCount" : "19" + } + }, + "statistics" : { + "duration" : 191 + }, + "type" : "source", + "parameters" : { + "comparator" : "w3c-html5" + } + } + ], + "type" : "source" }, { - "index" : 2, - "name" : "sleep", + "index" : 5, + "name" : "status-codes", + "pattern" : "5c7e291f6798f408cf3d1dab", "stepResult" : { - "status" : "MODIFIED" + "status" : "COLLECTED", + "artifactId" : "5c7e2bc36798f408cf3d1de1" }, "statistics" : { - "duration" : 150 + "duration" : 34 }, - "type" : "sleep", - "parameters" : { - "duration" : "150" - } + "comparators" : [ + { + "stepResult" : { + "status" : "PASSED", + "rebaseable" : false, + "acceptable" : false, + "artifactId" : "5c7e2bc36798f408cf3d1de5" + }, + "statistics" : { + "duration" : 13 + }, + "type" : "status-codes", + "parameters" : { + "filterRange" : "400,600" + } + } + ], + "type" : "status-codes" }, { - "index" : 3, - "name" : "screen", - "pattern" : "5c7524c1495d5008b3e68245", + "index" : 6, + "name" : "js-errors", + "pattern" : "5c7e291f6798f408cf3d1dad", "stepResult" : { - "status" : "DUPLICATES_PATTERN", - "artifactId" : "5c7524c1495d5008b3e68245" + "status" : "COLLECTED", + "artifactId" : "5c7e2bc36798f408cf3d1de3" }, "statistics" : { - "duration" : 234 + "duration" : 14 }, "comparators" : [ { "stepResult" : { "status" : "PASSED", "rebaseable" : false, - "acceptable" : false, - "data" : { - "collectTimestamp" : "1551181037047", - "patternTimestamp" : "1551180993118" - } + "acceptable" : false }, + "filters" : [ + { + "type" : "js-errors-filter", + "parameters" : { + "line" : "2", + "source" : "http://w.iplsc.com/external/jquery/jquery-1.8.3.js" + } + } + ], "statistics" : { - "duration" : 6 + "duration" : 13 }, - "type" : "screen", - "parameters" : { - "comparator" : "layout" - } + "type" : "js-errors" } ], - "type" : "screen", - "parameters" : { - "exclude-elements" : "#hplogo" - } + "type" : "js-errors" } ], "isReran" : false From 8c274bca2801b400f2c9ecd3fc45c0efdf58b9bf Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Tue, 5 Mar 2019 09:11:40 +0100 Subject: [PATCH 42/63] Add some rebased test file --- .../artifacts.files/{file1.json => img1.json} | 0 .../projectA/artifacts.files/img2.json | 10 ++++ .../projectA/artifacts.files/img3.json | 10 ++++ .../projectA/metadata/test4.json | 55 ++++++++++--------- .../projectA/metadata/test5.json | 55 ++++++++++--------- 5 files changed, 80 insertions(+), 50 deletions(-) rename core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/{file1.json => img1.json} (100%) create mode 100644 core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img2.json create mode 100644 core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img3.json diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/file1.json b/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img1.json similarity index 100% rename from core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/file1.json rename to core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img1.json diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img2.json b/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img2.json new file mode 100644 index 000000000..2d4edd454 --- /dev/null +++ b/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img2.json @@ -0,0 +1,10 @@ +{ + "_id" : ObjectId("5c7e2d436798f408cf3d1dea"), + "filename" : null, + "aliases" : null, + "chunkSize" : NumberLong(261120), + "uploadDate" : ISODate("2019-03-05T08:03:15.436Z"), + "length" : NumberLong(198215), + "contentType" : "image/png", + "md5" : "23208250b3fca1423bc53341b193d94a" +} \ No newline at end of file diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img3.json b/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img3.json new file mode 100644 index 000000000..5f6381778 --- /dev/null +++ b/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img3.json @@ -0,0 +1,10 @@ +{ + "_id" : ObjectId("5c7e2d446798f408cf3d1df6"), + "filename" : null, + "aliases" : null, + "chunkSize" : NumberLong(261120), + "uploadDate" : ISODate("2019-03-05T08:03:16.029Z"), + "length" : NumberLong(1996), + "contentType" : "image/png", + "md5" : "3a04c3acbc4b3e6d41561b7ecc6b2077" +} \ No newline at end of file diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test4.json b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test4.json index 1e1010bc4..448471b16 100644 --- a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test4.json +++ b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test4.json @@ -1,5 +1,5 @@ { - "_id" : ObjectId("5c7e2b8f6798f408cf3d1dde"), + "_id" : ObjectId("5c7e2d446798f408cf3d1df8"), "correlationId" : "company-project-test-suite-1551082549000", "company" : "company", "project" : "project", @@ -8,7 +8,7 @@ "runTimestamp" : NumberLong(1551082549000), "finishedTimestamp" : NumberLong(1551082559000), "statistics" : { - "duration" : 6377 + "duration" : 6693 }, "tests" : [ { @@ -19,7 +19,7 @@ "name" : "https://en.wikipedia.org/wiki/Main_Page", "url" : "https://en.wikipedia.org/wiki/Main_Page", "collectionStats" : { - "duration" : 3052 + "duration" : 2981 }, "steps" : [ { @@ -29,7 +29,7 @@ "status" : "PAGE_OPENED" }, "statistics" : { - "duration" : 931 + "duration" : 828 }, "type" : "open" }, @@ -40,7 +40,7 @@ "status" : "MODIFIED" }, "statistics" : { - "duration" : 115 + "duration" : 113 }, "type" : "resolution", "parameters" : { @@ -55,7 +55,7 @@ "status" : "MODIFIED" }, "statistics" : { - "duration" : 1500 + "duration" : 1501 }, "type" : "sleep", "parameters" : { @@ -67,25 +67,30 @@ "name" : "screen", "pattern" : "5c7e291f6798f408cf3d1da7", "stepResult" : { - "status" : "DUPLICATES_PATTERN", - "artifactId" : "5c7e291f6798f408cf3d1da7" + "status" : "COLLECTED", + "artifactId" : "5c7e2d436798f408cf3d1dea" }, "statistics" : { - "duration" : 289 + "duration" : 276 }, "comparators" : [ { "stepResult" : { - "status" : "PASSED", - "rebaseable" : false, - "acceptable" : false, + "status" : "FAILED", + "rebaseable" : true, + "acceptable" : true, + "artifactId" : "5c7e2d446798f408cf3d1df6", "data" : { - "collectTimestamp" : "1551772559111", + "heightDifference" : "0", + "widthDifference" : "0", + "collectTimestamp" : "1551772996036", + "percentagePixelDifference" : "0.006458333333333333", + "pixelDifference" : "31", "patternTimestamp" : "1551771935056" } }, "statistics" : { - "duration" : 10 + "duration" : 419 }, "type" : "screen", "parameters" : { @@ -101,10 +106,10 @@ "pattern" : "5c7e291f6798f408cf3d1da9", "stepResult" : { "status" : "COLLECTED", - "artifactId" : "5c7e2b8f6798f408cf3d1dd4" + "artifactId" : "5c7e2d436798f408cf3d1dec" }, "statistics" : { - "duration" : 121 + "duration" : 119 }, "comparators" : [ { @@ -112,14 +117,14 @@ "status" : "FAILED", "rebaseable" : false, "acceptable" : false, - "artifactId" : "5c7e2b8f6798f408cf3d1ddc", + "artifactId" : "5c7e2d436798f408cf3d1df4", "data" : { "warningCount" : "0", "errorCount" : "19" } }, "statistics" : { - "duration" : 205 + "duration" : 286 }, "type" : "source", "parameters" : { @@ -135,10 +140,10 @@ "pattern" : "5c7e291f6798f408cf3d1dab", "stepResult" : { "status" : "COLLECTED", - "artifactId" : "5c7e2b8f6798f408cf3d1dd6" + "artifactId" : "5c7e2d436798f408cf3d1dee" }, "statistics" : { - "duration" : 20 + "duration" : 22 }, "comparators" : [ { @@ -146,10 +151,10 @@ "status" : "PASSED", "rebaseable" : false, "acceptable" : false, - "artifactId" : "5c7e2b8f6798f408cf3d1dda" + "artifactId" : "5c7e2d436798f408cf3d1df2" }, "statistics" : { - "duration" : 27 + "duration" : 11 }, "type" : "status-codes", "parameters" : { @@ -165,10 +170,10 @@ "pattern" : "5c7e291f6798f408cf3d1dad", "stepResult" : { "status" : "COLLECTED", - "artifactId" : "5c7e2b8f6798f408cf3d1dd8" + "artifactId" : "5c7e2d436798f408cf3d1df0" }, "statistics" : { - "duration" : 18 + "duration" : 15 }, "comparators" : [ { @@ -187,7 +192,7 @@ } ], "statistics" : { - "duration" : 9 + "duration" : 18 }, "type" : "js-errors" } diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test5.json b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test5.json index c151189d7..1d44e4728 100644 --- a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test5.json +++ b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test5.json @@ -1,5 +1,5 @@ { - "_id" : ObjectId("5c7e2bc46798f408cf3d1de9"), + "_id" : ObjectId("5c7e2dbd6798f408cf3d1df9"), "correlationId" : "company-project-test-suite-1550996149000", "company" : "company", "project" : "project", @@ -8,7 +8,7 @@ "runTimestamp" : NumberLong(1550996149000), "finishedTimestamp" : NumberLong(1550996159000), "statistics" : { - "duration" : 6281 + "duration" : 6693 }, "tests" : [ { @@ -19,7 +19,7 @@ "name" : "https://en.wikipedia.org/wiki/Main_Page", "url" : "https://en.wikipedia.org/wiki/Main_Page", "collectionStats" : { - "duration" : 2952 + "duration" : 2981 }, "steps" : [ { @@ -29,7 +29,7 @@ "status" : "PAGE_OPENED" }, "statistics" : { - "duration" : 748 + "duration" : 828 }, "type" : "open" }, @@ -55,7 +55,7 @@ "status" : "MODIFIED" }, "statistics" : { - "duration" : 1502 + "duration" : 1501 }, "type" : "sleep", "parameters" : { @@ -65,27 +65,32 @@ { "index" : 3, "name" : "screen", - "pattern" : "5c7e291f6798f408cf3d1da7", + "pattern" : "5c7e2d436798f408cf3d1dea", "stepResult" : { - "status" : "DUPLICATES_PATTERN", - "artifactId" : "5c7e291f6798f408cf3d1da7" + "status" : "COLLECTED", + "artifactId" : "5c7e2d436798f408cf3d1dea" }, "statistics" : { - "duration" : 280 + "duration" : 276 }, "comparators" : [ { "stepResult" : { - "status" : "PASSED", - "rebaseable" : false, - "acceptable" : false, + "status" : "REBASED", + "rebaseable" : true, + "acceptable" : true, + "artifactId" : "5c7e2d446798f408cf3d1df6", "data" : { - "collectTimestamp" : "1551772611875", + "heightDifference" : "0", + "widthDifference" : "0", + "collectTimestamp" : "1551772996036", + "percentagePixelDifference" : "0.006458333333333333", + "pixelDifference" : "31", "patternTimestamp" : "1551771935056" } }, "statistics" : { - "duration" : 17 + "duration" : 419 }, "type" : "screen", "parameters" : { @@ -101,10 +106,10 @@ "pattern" : "5c7e291f6798f408cf3d1da9", "stepResult" : { "status" : "COLLECTED", - "artifactId" : "5c7e2bc36798f408cf3d1ddf" + "artifactId" : "5c7e2d436798f408cf3d1dec" }, "statistics" : { - "duration" : 164 + "duration" : 119 }, "comparators" : [ { @@ -112,14 +117,14 @@ "status" : "FAILED", "rebaseable" : false, "acceptable" : false, - "artifactId" : "5c7e2bc46798f408cf3d1de7", + "artifactId" : "5c7e2d436798f408cf3d1df4", "data" : { "warningCount" : "0", "errorCount" : "19" } }, "statistics" : { - "duration" : 191 + "duration" : 286 }, "type" : "source", "parameters" : { @@ -135,10 +140,10 @@ "pattern" : "5c7e291f6798f408cf3d1dab", "stepResult" : { "status" : "COLLECTED", - "artifactId" : "5c7e2bc36798f408cf3d1de1" + "artifactId" : "5c7e2d436798f408cf3d1dee" }, "statistics" : { - "duration" : 34 + "duration" : 22 }, "comparators" : [ { @@ -146,10 +151,10 @@ "status" : "PASSED", "rebaseable" : false, "acceptable" : false, - "artifactId" : "5c7e2bc36798f408cf3d1de5" + "artifactId" : "5c7e2d436798f408cf3d1df2" }, "statistics" : { - "duration" : 13 + "duration" : 11 }, "type" : "status-codes", "parameters" : { @@ -165,10 +170,10 @@ "pattern" : "5c7e291f6798f408cf3d1dad", "stepResult" : { "status" : "COLLECTED", - "artifactId" : "5c7e2bc36798f408cf3d1de3" + "artifactId" : "5c7e2d436798f408cf3d1df0" }, "statistics" : { - "duration" : 14 + "duration" : 15 }, "comparators" : [ { @@ -187,7 +192,7 @@ } ], "statistics" : { - "duration" : 13 + "duration" : 18 }, "type" : "js-errors" } From 63076adf96fcd3b522d389774a9ff42d3f1a78e3 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Tue, 5 Mar 2019 09:17:27 +0100 Subject: [PATCH 43/63] Fix chronological order --- .../integrationTest/projectA/artifacts.files/img1.json | 2 +- .../integrationTest/projectA/artifacts.files/img2.json | 2 +- .../integrationTest/projectA/artifacts.files/img3.json | 2 +- .../resources/integrationTest/projectA/metadata/test1.json | 6 +++--- .../resources/integrationTest/projectA/metadata/test2.json | 6 +++--- .../resources/integrationTest/projectA/metadata/test4.json | 6 +++--- .../resources/integrationTest/projectA/metadata/test5.json | 6 +++--- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img1.json b/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img1.json index 7b4d51e9d..c19fba98d 100644 --- a/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img1.json +++ b/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img1.json @@ -3,7 +3,7 @@ "filename" : null, "aliases" : null, "chunkSize" : NumberLong(261120), - "uploadDate" : ISODate("2019-02-28T08:15:49.056Z"), + "uploadDate" : ISODate("2019-02-24T08:15:49.056Z"), "length" : NumberLong(198205), "contentType" : "image/png", "md5" : "6e0ac5f99d67c5d707fb97993021f95a" diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img2.json b/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img2.json index 2d4edd454..74c2011c1 100644 --- a/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img2.json +++ b/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img2.json @@ -3,7 +3,7 @@ "filename" : null, "aliases" : null, "chunkSize" : NumberLong(261120), - "uploadDate" : ISODate("2019-03-05T08:03:15.436Z"), + "uploadDate" : ISODate("2019-02-27T08:15:49.056Z"), "length" : NumberLong(198215), "contentType" : "image/png", "md5" : "23208250b3fca1423bc53341b193d94a" diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img3.json b/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img3.json index 5f6381778..fcdb4cb3e 100644 --- a/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img3.json +++ b/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img3.json @@ -3,7 +3,7 @@ "filename" : null, "aliases" : null, "chunkSize" : NumberLong(261120), - "uploadDate" : ISODate("2019-03-05T08:03:16.029Z"), + "uploadDate" : ISODate("2019-02-28T08:15:49.056Z"), "length" : NumberLong(1996), "contentType" : "image/png", "md5" : "3a04c3acbc4b3e6d41561b7ecc6b2077" diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test1.json b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test1.json index d9f01f1eb..6121d51a9 100644 --- a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test1.json +++ b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test1.json @@ -1,12 +1,12 @@ { "_id" : ObjectId("5c7e29206798f408cf3d1db3"), - "correlationId" : "company-project-test-suite-1551341749000", + "correlationId" : "company-project-test-suite-1550996149000", "company" : "company", "project" : "project", "name" : "test-suite", "version" : 1, - "runTimestamp" : NumberLong(1551341749000), - "finishedTimestamp" : NumberLong(1551341759000), + "runTimestamp" : NumberLong(1550996149000), + "finishedTimestamp" : NumberLong(1550996159000), "statistics" : { "duration" : 6791 }, diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json index 7f3e8aae8..39ec4b698 100644 --- a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json +++ b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json @@ -1,12 +1,12 @@ { "_id" : ObjectId("5c7e2b066798f408cf3d1dc8"), - "correlationId" : "company-project-test-suite-1551255349000", + "correlationId" : "company-project-test-suite-1551082549000", "company" : "company", "project" : "project", "name" : "test-suite", "version" : 2, - "runTimestamp" : NumberLong(1551255349000), - "finishedTimestamp" : NumberLong(1551255359000), + "runTimestamp" : NumberLong(1551082549000), + "finishedTimestamp" : NumberLong(1551082559000), "statistics" : { "duration" : 6299 }, diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test4.json b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test4.json index 448471b16..6219560f1 100644 --- a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test4.json +++ b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test4.json @@ -1,12 +1,12 @@ { "_id" : ObjectId("5c7e2d446798f408cf3d1df8"), - "correlationId" : "company-project-test-suite-1551082549000", + "correlationId" : "company-project-test-suite-1551255349000", "company" : "company", "project" : "project", "name" : "test-suite", "version" : 4, - "runTimestamp" : NumberLong(1551082549000), - "finishedTimestamp" : NumberLong(1551082559000), + "runTimestamp" : NumberLong(1551255349000), + "finishedTimestamp" : NumberLong(1551255359000), "statistics" : { "duration" : 6693 }, diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test5.json b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test5.json index 1d44e4728..83fb44acc 100644 --- a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test5.json +++ b/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test5.json @@ -1,12 +1,12 @@ { "_id" : ObjectId("5c7e2dbd6798f408cf3d1df9"), - "correlationId" : "company-project-test-suite-1550996149000", + "correlationId" : "company-project-test-suite-1551341749000", "company" : "company", "project" : "project", "name" : "test-suite", "version" : 5, - "runTimestamp" : NumberLong(1550996149000), - "finishedTimestamp" : NumberLong(1550996159000), + "runTimestamp" : NumberLong(1551341749000), + "finishedTimestamp" : NumberLong(1551341759000), "statistics" : { "duration" : 6693 }, From 1206ebf50a937bb85f9f1816cee5aa24f4f09a45 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Tue, 5 Mar 2019 09:19:41 +0100 Subject: [PATCH 44/63] Add more detailed timestamp comment --- .../java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 0355c6a95..0cd40ba19 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -58,7 +58,7 @@ @RunWith(ZohhakRunner.class) public class CleanerIntegrationTest { - private static final Long MOCKED_CURRENT_TIMESTAMP = 1551428149000L; //March 1, 2019 + private static final Long MOCKED_CURRENT_TIMESTAMP = 1551428149000L; //March 1, 2019 8:15:49 AM private static final String MOCKED_COMPANY_NAME = "company"; private static final String MOCKED_PROJECT_NAME = "project"; private static final String MOCKED_DB_NAME = String From b55c341c4b61529657dcac87be487951df326b14 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Tue, 5 Mar 2019 09:22:25 +0100 Subject: [PATCH 45/63] Fix test case (removing is inclusive) --- .../java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 0cd40ba19..006c4852f 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -100,7 +100,7 @@ public void setUp() { @TestWith({ //keeping based on age - "1,5,projectA", + "1,6,projectA", //keeping based on versions "5,0,projectA", //both From f0c791a2e42d550fb0ac18f6bd801725dc633849 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Tue, 5 Mar 2019 09:44:09 +0100 Subject: [PATCH 46/63] Add second test files (two tests in one suite) --- .../projectB/artifacts.files/img1.json | 10 + .../projectB/artifacts.files/img2.json | 10 + .../projectB/artifacts.files/img3.json | 10 + .../projectB/artifacts.files/img4.json | 10 + .../projectB/artifacts.files/img5.json | 10 + .../projectB/artifacts.files/img6.json | 10 + .../projectB/metadata/test1.json | 193 +++++++++++++++++ .../projectB/metadata/test2.json | 198 ++++++++++++++++++ .../projectB/metadata/test3.json | 198 ++++++++++++++++++ .../projectB/metadata/test4.json | 198 ++++++++++++++++++ .../projectB/metadata/test5.json | 198 ++++++++++++++++++ 11 files changed, 1045 insertions(+) create mode 100644 core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img1.json create mode 100644 core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img2.json create mode 100644 core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img3.json create mode 100644 core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img4.json create mode 100644 core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img5.json create mode 100644 core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img6.json create mode 100644 core/cleaner/src/test/resources/integrationTest/projectB/metadata/test1.json create mode 100644 core/cleaner/src/test/resources/integrationTest/projectB/metadata/test2.json create mode 100644 core/cleaner/src/test/resources/integrationTest/projectB/metadata/test3.json create mode 100644 core/cleaner/src/test/resources/integrationTest/projectB/metadata/test4.json create mode 100644 core/cleaner/src/test/resources/integrationTest/projectB/metadata/test5.json diff --git a/core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img1.json b/core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img1.json new file mode 100644 index 000000000..9c031a5dd --- /dev/null +++ b/core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img1.json @@ -0,0 +1,10 @@ +{ + "_id" : ObjectId("5c7e349c6798f408cf3d1e0e"), + "filename" : null, + "aliases" : null, + "chunkSize" : NumberLong(261120), + "uploadDate" : ISODate("2019-02-24T08:15:49.056Z"), + "length" : NumberLong(161021), + "contentType" : "image/png", + "md5" : "5a01e3d4a6a148d3c69467ae94810c31" +} \ No newline at end of file diff --git a/core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img2.json b/core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img2.json new file mode 100644 index 000000000..f4f19e79b --- /dev/null +++ b/core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img2.json @@ -0,0 +1,10 @@ +{ + "_id" : ObjectId("5c7e349e6798f408cf3d1e10"), + "filename" : null, + "aliases" : null, + "chunkSize" : NumberLong(261120), + "uploadDate" : ISODate("2019-02-24T08:15:49.056Z"), + "length" : NumberLong(68955), + "contentType" : "image/png", + "md5" : "8b5d3e10b08b0a69e550a09a23336ee5" +} \ No newline at end of file diff --git a/core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img3.json b/core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img3.json new file mode 100644 index 000000000..fe9b74a4e --- /dev/null +++ b/core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img3.json @@ -0,0 +1,10 @@ +{ + "_id" : ObjectId("5c7e34c86798f408cf3d1e13"), + "filename" : null, + "aliases" : null, + "chunkSize" : NumberLong(261120), + "uploadDate" : ISODate("2019-02-25T08:15:49.056Z"), + "length" : NumberLong(170825), + "contentType" : "image/png", + "md5" : "522923551e74512101e475869cd3e4aa" +} \ No newline at end of file diff --git a/core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img4.json b/core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img4.json new file mode 100644 index 000000000..8aab498a4 --- /dev/null +++ b/core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img4.json @@ -0,0 +1,10 @@ +{ + "_id" : ObjectId("5c7e34c86798f408cf3d1e15"), + "filename" : null, + "aliases" : null, + "chunkSize" : NumberLong(261120), + "uploadDate" : ISODate("2019-02-26T08:15:49.056Z"), + "length" : NumberLong(2816), + "contentType" : "image/png", + "md5" : "bfdcad6d0f271b079d1078fbf49fc59d" +} \ No newline at end of file diff --git a/core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img5.json b/core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img5.json new file mode 100644 index 000000000..ba89b8a84 --- /dev/null +++ b/core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img5.json @@ -0,0 +1,10 @@ +{ + "_id" : ObjectId("5c7e35236798f408cf3d1e19"), + "filename" : null, + "aliases" : null, + "chunkSize" : NumberLong(261120), + "uploadDate" : ISODate("2019-02-27T08:15:49.056Z"), + "length" : NumberLong(136183), + "contentType" : "image/png", + "md5" : "3c81bf249818192dbf4384c5153ca336" +} \ No newline at end of file diff --git a/core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img6.json b/core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img6.json new file mode 100644 index 000000000..d889652f4 --- /dev/null +++ b/core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img6.json @@ -0,0 +1,10 @@ +{ + "_id" : ObjectId("5c7e35236798f408cf3d1e1b"), + "filename" : null, + "aliases" : null, + "chunkSize" : NumberLong(261120), + "uploadDate" : ISODate("2019-02-28T08:15:49.056Z"), + "length" : NumberLong(2816), + "contentType" : "image/png", + "md5" : "bfdcad6d0f271b079d1078fbf49fc59d" +} \ No newline at end of file diff --git a/core/cleaner/src/test/resources/integrationTest/projectB/metadata/test1.json b/core/cleaner/src/test/resources/integrationTest/projectB/metadata/test1.json new file mode 100644 index 000000000..347f5deac --- /dev/null +++ b/core/cleaner/src/test/resources/integrationTest/projectB/metadata/test1.json @@ -0,0 +1,193 @@ +{ + "_id" : ObjectId("5c7e349e6798f408cf3d1e12"), + "correlationId" : "company2-project-test-suite-1550996149000", + "company" : "company2", + "project" : "project", + "name" : "test-suite", + "version" : 1, + "runTimestamp" : NumberLong(1550996149000), + "finishedTimestamp" : NumberLong(1550996159000), + "statistics" : { + "duration" : 7338 + }, + "tests" : [ + { + "name" : "first-test", + "proxy" : "rest", + "urls" : [ + { + "name" : "https://www.cognifide.com", + "url" : "https://www.cognifide.com", + "collectionStats" : { + "duration" : 4031 + }, + "steps" : [ + { + "index" : 0, + "name" : "open", + "stepResult" : { + "status" : "PAGE_OPENED" + }, + "statistics" : { + "duration" : 2121 + }, + "type" : "open" + }, + { + "index" : 1, + "name" : "resolution", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 110 + }, + "type" : "resolution", + "parameters" : { + "height" : "600", + "width" : "800" + } + }, + { + "index" : 2, + "name" : "sleep", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 1501 + }, + "type" : "sleep", + "parameters" : { + "duration" : "1500" + } + }, + { + "index" : 3, + "name" : "screen", + "pattern" : "5c7e349e6798f408cf3d1e10", + "stepResult" : { + "status" : "COLLECTED", + "artifactId" : "5c7e349e6798f408cf3d1e10" + }, + "statistics" : { + "duration" : 251 + }, + "comparators" : [ + { + "stepResult" : { + "status" : "PASSED", + "rebaseable" : false, + "acceptable" : false, + "data" : { + "collectTimestamp" : "1551774878017", + "patternTimestamp" : "1551774878005" + } + }, + "statistics" : { + "duration" : 2 + }, + "type" : "screen", + "parameters" : { + "comparator" : "layout" + } + } + ], + "type" : "screen" + } + ], + "isReran" : false + } + ] + }, + { + "name" : "second-test", + "proxy" : "rest", + "urls" : [ + { + "name" : "https://thiscatdoesnotexist.com", + "url" : "https://thiscatdoesnotexist.com", + "collectionStats" : { + "duration" : 2368 + }, + "steps" : [ + { + "index" : 0, + "name" : "open", + "stepResult" : { + "status" : "PAGE_OPENED" + }, + "statistics" : { + "duration" : 394 + }, + "type" : "open" + }, + { + "index" : 1, + "name" : "resolution", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 115 + }, + "type" : "resolution", + "parameters" : { + "height" : "600", + "width" : "800" + } + }, + { + "index" : 2, + "name" : "sleep", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 1500 + }, + "type" : "sleep", + "parameters" : { + "duration" : "1500" + } + }, + { + "index" : 3, + "name" : "screen", + "pattern" : "5c7e349c6798f408cf3d1e0e", + "stepResult" : { + "status" : "COLLECTED", + "artifactId" : "5c7e349c6798f408cf3d1e0e" + }, + "statistics" : { + "duration" : 294 + }, + "comparators" : [ + { + "stepResult" : { + "status" : "PASSED", + "rebaseable" : false, + "acceptable" : false, + "data" : { + "collectTimestamp" : "1551774876335", + "patternTimestamp" : "1551774876317" + } + }, + "statistics" : { + "duration" : 4 + }, + "type" : "screen", + "parameters" : { + "comparator" : "layout" + } + } + ], + "type" : "screen" + } + ], + "isReran" : false + } + ] + } + ] +} \ No newline at end of file diff --git a/core/cleaner/src/test/resources/integrationTest/projectB/metadata/test2.json b/core/cleaner/src/test/resources/integrationTest/projectB/metadata/test2.json new file mode 100644 index 000000000..3f8319546 --- /dev/null +++ b/core/cleaner/src/test/resources/integrationTest/projectB/metadata/test2.json @@ -0,0 +1,198 @@ +{ + "_id" : ObjectId("5c7e34cb6798f408cf3d1e17"), + "correlationId" : "company2-project-test-suite-1551082549000", + "company" : "company2", + "project" : "project", + "name" : "test-suite", + "version" : 2, + "runTimestamp" : NumberLong(1551082549000), + "finishedTimestamp" : NumberLong(1551082559000), + "statistics" : { + "duration" : 7506 + }, + "tests" : [ + { + "name" : "first-test", + "proxy" : "rest", + "urls" : [ + { + "name" : "https://www.cognifide.com", + "url" : "https://www.cognifide.com", + "collectionStats" : { + "duration" : 4194 + }, + "steps" : [ + { + "index" : 0, + "name" : "open", + "stepResult" : { + "status" : "PAGE_OPENED" + }, + "statistics" : { + "duration" : 2220 + }, + "type" : "open" + }, + { + "index" : 1, + "name" : "resolution", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 112 + }, + "type" : "resolution", + "parameters" : { + "height" : "600", + "width" : "800" + } + }, + { + "index" : 2, + "name" : "sleep", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 1501 + }, + "type" : "sleep", + "parameters" : { + "duration" : "1500" + } + }, + { + "index" : 3, + "name" : "screen", + "pattern" : "5c7e349e6798f408cf3d1e10", + "stepResult" : { + "status" : "DUPLICATES_PATTERN", + "artifactId" : "5c7e349e6798f408cf3d1e10" + }, + "statistics" : { + "duration" : 250 + }, + "comparators" : [ + { + "stepResult" : { + "status" : "PASSED", + "rebaseable" : false, + "acceptable" : false, + "data" : { + "collectTimestamp" : "1551774922458", + "patternTimestamp" : "1551774878005" + } + }, + "statistics" : { + "duration" : 7 + }, + "type" : "screen", + "parameters" : { + "comparator" : "layout" + } + } + ], + "type" : "screen" + } + ], + "isReran" : false + } + ] + }, + { + "name" : "second-test", + "proxy" : "rest", + "urls" : [ + { + "name" : "https://thiscatdoesnotexist.com", + "url" : "https://thiscatdoesnotexist.com", + "collectionStats" : { + "duration" : 2407 + }, + "steps" : [ + { + "index" : 0, + "name" : "open", + "stepResult" : { + "status" : "PAGE_OPENED" + }, + "statistics" : { + "duration" : 444 + }, + "type" : "open" + }, + { + "index" : 1, + "name" : "resolution", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 117 + }, + "type" : "resolution", + "parameters" : { + "height" : "600", + "width" : "800" + } + }, + { + "index" : 2, + "name" : "sleep", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 1501 + }, + "type" : "sleep", + "parameters" : { + "duration" : "1500" + } + }, + { + "index" : 3, + "name" : "screen", + "pattern" : "5c7e349c6798f408cf3d1e0e", + "stepResult" : { + "status" : "COLLECTED", + "artifactId" : "5c7e34c86798f408cf3d1e13" + }, + "statistics" : { + "duration" : 284 + }, + "comparators" : [ + { + "stepResult" : { + "status" : "FAILED", + "rebaseable" : true, + "acceptable" : true, + "artifactId" : "5c7e34c86798f408cf3d1e15", + "data" : { + "heightDifference" : "0", + "widthDifference" : "0", + "collectTimestamp" : "1551774920792", + "percentagePixelDifference" : "13.653333333333334", + "pixelDifference" : "65536", + "patternTimestamp" : "1551774876317" + } + }, + "statistics" : { + "duration" : 89 + }, + "type" : "screen", + "parameters" : { + "comparator" : "layout" + } + } + ], + "type" : "screen" + } + ], + "isReran" : false + } + ] + } + ] +} \ No newline at end of file diff --git a/core/cleaner/src/test/resources/integrationTest/projectB/metadata/test3.json b/core/cleaner/src/test/resources/integrationTest/projectB/metadata/test3.json new file mode 100644 index 000000000..320e520a1 --- /dev/null +++ b/core/cleaner/src/test/resources/integrationTest/projectB/metadata/test3.json @@ -0,0 +1,198 @@ +{ + "_id" : ObjectId("5c7e35146798f408cf3d1e18"), + "correlationId" : "company2-project-test-suite-1551168949000", + "company" : "company2", + "project" : "project", + "name" : "test-suite", + "version" : 3, + "runTimestamp" : NumberLong(1551168949000), + "finishedTimestamp" : NumberLong(1551168959000), + "statistics" : { + "duration" : 7506 + }, + "tests" : [ + { + "name" : "first-test", + "proxy" : "rest", + "urls" : [ + { + "name" : "https://www.cognifide.com", + "url" : "https://www.cognifide.com", + "collectionStats" : { + "duration" : 4194 + }, + "steps" : [ + { + "index" : 0, + "name" : "open", + "stepResult" : { + "status" : "PAGE_OPENED" + }, + "statistics" : { + "duration" : 2220 + }, + "type" : "open" + }, + { + "index" : 1, + "name" : "resolution", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 112 + }, + "type" : "resolution", + "parameters" : { + "height" : "600", + "width" : "800" + } + }, + { + "index" : 2, + "name" : "sleep", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 1501 + }, + "type" : "sleep", + "parameters" : { + "duration" : "1500" + } + }, + { + "index" : 3, + "name" : "screen", + "pattern" : "5c7e349e6798f408cf3d1e10", + "stepResult" : { + "status" : "DUPLICATES_PATTERN", + "artifactId" : "5c7e349e6798f408cf3d1e10" + }, + "statistics" : { + "duration" : 250 + }, + "comparators" : [ + { + "stepResult" : { + "status" : "PASSED", + "rebaseable" : false, + "acceptable" : false, + "data" : { + "collectTimestamp" : "1551774922458", + "patternTimestamp" : "1551774878005" + } + }, + "statistics" : { + "duration" : 7 + }, + "type" : "screen", + "parameters" : { + "comparator" : "layout" + } + } + ], + "type" : "screen" + } + ], + "isReran" : false + } + ] + }, + { + "name" : "second-test", + "proxy" : "rest", + "urls" : [ + { + "name" : "https://thiscatdoesnotexist.com", + "url" : "https://thiscatdoesnotexist.com", + "collectionStats" : { + "duration" : 2407 + }, + "steps" : [ + { + "index" : 0, + "name" : "open", + "stepResult" : { + "status" : "PAGE_OPENED" + }, + "statistics" : { + "duration" : 444 + }, + "type" : "open" + }, + { + "index" : 1, + "name" : "resolution", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 117 + }, + "type" : "resolution", + "parameters" : { + "height" : "600", + "width" : "800" + } + }, + { + "index" : 2, + "name" : "sleep", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 1501 + }, + "type" : "sleep", + "parameters" : { + "duration" : "1500" + } + }, + { + "index" : 3, + "name" : "screen", + "pattern" : "5c7e34c86798f408cf3d1e13", + "stepResult" : { + "status" : "COLLECTED", + "artifactId" : "5c7e34c86798f408cf3d1e13" + }, + "statistics" : { + "duration" : 284 + }, + "comparators" : [ + { + "stepResult" : { + "status" : "REBASED", + "rebaseable" : true, + "acceptable" : true, + "artifactId" : "5c7e34c86798f408cf3d1e15", + "data" : { + "heightDifference" : "0", + "widthDifference" : "0", + "collectTimestamp" : "1551774920792", + "percentagePixelDifference" : "13.653333333333334", + "pixelDifference" : "65536", + "patternTimestamp" : "1551774876317" + } + }, + "statistics" : { + "duration" : 89 + }, + "type" : "screen", + "parameters" : { + "comparator" : "layout" + } + } + ], + "type" : "screen" + } + ], + "isReran" : false + } + ] + } + ] +} \ No newline at end of file diff --git a/core/cleaner/src/test/resources/integrationTest/projectB/metadata/test4.json b/core/cleaner/src/test/resources/integrationTest/projectB/metadata/test4.json new file mode 100644 index 000000000..995e8b8a7 --- /dev/null +++ b/core/cleaner/src/test/resources/integrationTest/projectB/metadata/test4.json @@ -0,0 +1,198 @@ +{ + "_id" : ObjectId("5c7e35266798f408cf3d1e1d"), + "correlationId" : "company2-project-test-suite-1551255349000", + "company" : "company2", + "project" : "project", + "name" : "test-suite", + "version" : 4, + "runTimestamp" : NumberLong(1551255349000), + "finishedTimestamp" : NumberLong(1551255359000), + "statistics" : { + "duration" : 8185 + }, + "tests" : [ + { + "name" : "first-test", + "proxy" : "rest", + "urls" : [ + { + "name" : "https://www.cognifide.com", + "url" : "https://www.cognifide.com", + "collectionStats" : { + "duration" : 4946 + }, + "steps" : [ + { + "index" : 0, + "name" : "open", + "stepResult" : { + "status" : "PAGE_OPENED" + }, + "statistics" : { + "duration" : 2618 + }, + "type" : "open" + }, + { + "index" : 1, + "name" : "resolution", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 110 + }, + "type" : "resolution", + "parameters" : { + "height" : "600", + "width" : "800" + } + }, + { + "index" : 2, + "name" : "sleep", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 1502 + }, + "type" : "sleep", + "parameters" : { + "duration" : "1500" + } + }, + { + "index" : 3, + "name" : "screen", + "pattern" : "5c7e349e6798f408cf3d1e10", + "stepResult" : { + "status" : "DUPLICATES_PATTERN", + "artifactId" : "5c7e349e6798f408cf3d1e10" + }, + "statistics" : { + "duration" : 237 + }, + "comparators" : [ + { + "stepResult" : { + "status" : "PASSED", + "rebaseable" : false, + "acceptable" : false, + "data" : { + "collectTimestamp" : "1551775013739", + "patternTimestamp" : "1551774878005" + } + }, + "statistics" : { + "duration" : 4 + }, + "type" : "screen", + "parameters" : { + "comparator" : "layout" + } + } + ], + "type" : "screen" + } + ], + "isReran" : false + } + ] + }, + { + "name" : "second-test", + "proxy" : "rest", + "urls" : [ + { + "name" : "https://thiscatdoesnotexist.com", + "url" : "https://thiscatdoesnotexist.com", + "collectionStats" : { + "duration" : 2476 + }, + "steps" : [ + { + "index" : 0, + "name" : "open", + "stepResult" : { + "status" : "PAGE_OPENED" + }, + "statistics" : { + "duration" : 517 + }, + "type" : "open" + }, + { + "index" : 1, + "name" : "resolution", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 112 + }, + "type" : "resolution", + "parameters" : { + "height" : "600", + "width" : "800" + } + }, + { + "index" : 2, + "name" : "sleep", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 1505 + }, + "type" : "sleep", + "parameters" : { + "duration" : "1500" + } + }, + { + "index" : 3, + "name" : "screen", + "pattern" : "5c7e34c86798f408cf3d1e13", + "stepResult" : { + "status" : "COLLECTED", + "artifactId" : "5c7e35236798f408cf3d1e19" + }, + "statistics" : { + "duration" : 279 + }, + "comparators" : [ + { + "stepResult" : { + "status" : "FAILED", + "rebaseable" : true, + "acceptable" : true, + "artifactId" : "5c7e35236798f408cf3d1e1b", + "data" : { + "heightDifference" : "0", + "widthDifference" : "0", + "collectTimestamp" : "1551775011420", + "percentagePixelDifference" : "13.653333333333334", + "pixelDifference" : "65536", + "patternTimestamp" : "1551774920684" + } + }, + "statistics" : { + "duration" : 97 + }, + "type" : "screen", + "parameters" : { + "comparator" : "layout" + } + } + ], + "type" : "screen" + } + ], + "isReran" : false + } + ] + } + ] +} \ No newline at end of file diff --git a/core/cleaner/src/test/resources/integrationTest/projectB/metadata/test5.json b/core/cleaner/src/test/resources/integrationTest/projectB/metadata/test5.json new file mode 100644 index 000000000..129783f0a --- /dev/null +++ b/core/cleaner/src/test/resources/integrationTest/projectB/metadata/test5.json @@ -0,0 +1,198 @@ +{ + "_id" : ObjectId("5c7e35626798f408cf3d1e1e"), + "correlationId" : "company2-project-test-suite-1551341749000", + "company" : "company2", + "project" : "project", + "name" : "test-suite", + "version" : 5, + "runTimestamp" : NumberLong(1551341749000), + "finishedTimestamp" : NumberLong(1551341759000), + "statistics" : { + "duration" : 8185 + }, + "tests" : [ + { + "name" : "first-test", + "proxy" : "rest", + "urls" : [ + { + "name" : "https://www.cognifide.com", + "url" : "https://www.cognifide.com", + "collectionStats" : { + "duration" : 4946 + }, + "steps" : [ + { + "index" : 0, + "name" : "open", + "stepResult" : { + "status" : "PAGE_OPENED" + }, + "statistics" : { + "duration" : 2618 + }, + "type" : "open" + }, + { + "index" : 1, + "name" : "resolution", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 110 + }, + "type" : "resolution", + "parameters" : { + "height" : "600", + "width" : "800" + } + }, + { + "index" : 2, + "name" : "sleep", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 1502 + }, + "type" : "sleep", + "parameters" : { + "duration" : "1500" + } + }, + { + "index" : 3, + "name" : "screen", + "pattern" : "5c7e349e6798f408cf3d1e10", + "stepResult" : { + "status" : "DUPLICATES_PATTERN", + "artifactId" : "5c7e349e6798f408cf3d1e10" + }, + "statistics" : { + "duration" : 237 + }, + "comparators" : [ + { + "stepResult" : { + "status" : "PASSED", + "rebaseable" : false, + "acceptable" : false, + "data" : { + "collectTimestamp" : "1551775013739", + "patternTimestamp" : "1551774878005" + } + }, + "statistics" : { + "duration" : 4 + }, + "type" : "screen", + "parameters" : { + "comparator" : "layout" + } + } + ], + "type" : "screen" + } + ], + "isReran" : false + } + ] + }, + { + "name" : "second-test", + "proxy" : "rest", + "urls" : [ + { + "name" : "https://thiscatdoesnotexist.com", + "url" : "https://thiscatdoesnotexist.com", + "collectionStats" : { + "duration" : 2476 + }, + "steps" : [ + { + "index" : 0, + "name" : "open", + "stepResult" : { + "status" : "PAGE_OPENED" + }, + "statistics" : { + "duration" : 517 + }, + "type" : "open" + }, + { + "index" : 1, + "name" : "resolution", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 112 + }, + "type" : "resolution", + "parameters" : { + "height" : "600", + "width" : "800" + } + }, + { + "index" : 2, + "name" : "sleep", + "stepResult" : { + "status" : "MODIFIED" + }, + "statistics" : { + "duration" : 1505 + }, + "type" : "sleep", + "parameters" : { + "duration" : "1500" + } + }, + { + "index" : 3, + "name" : "screen", + "pattern" : "5c7e35236798f408cf3d1e19", + "stepResult" : { + "status" : "COLLECTED", + "artifactId" : "5c7e35236798f408cf3d1e19" + }, + "statistics" : { + "duration" : 279 + }, + "comparators" : [ + { + "stepResult" : { + "status" : "REBASED", + "rebaseable" : true, + "acceptable" : true, + "artifactId" : "5c7e35236798f408cf3d1e1b", + "data" : { + "heightDifference" : "0", + "widthDifference" : "0", + "collectTimestamp" : "1551775011420", + "percentagePixelDifference" : "13.653333333333334", + "pixelDifference" : "65536", + "patternTimestamp" : "1551774920684" + } + }, + "statistics" : { + "duration" : 97 + }, + "type" : "screen", + "parameters" : { + "comparator" : "layout" + } + } + ], + "type" : "screen" + } + ], + "isReran" : false + } + ] + } + ] +} \ No newline at end of file From 2312bef5b9088fcb216328a9bb955ec84a1fb044 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Tue, 5 Mar 2019 09:47:08 +0100 Subject: [PATCH 47/63] Add tests for second suite --- .../com/cognifide/aet/cleaner/CleanerIntegrationTest.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 006c4852f..8cad8d6a0 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -101,10 +101,13 @@ public void setUp() { @TestWith({ //keeping based on age "1,6,projectA", + "1,6,projectB", //keeping based on versions "5,0,projectA", + "5,0,projectB", //both - "5,3,projectA" + "5,6,projectA", + "5,6,projectB" }) public void clean_whenKeepAllSuites_removeNothing(Long versionsToKeep, Long maxAge, String projectDataDir) throws JobExecutionException, IOException { From cf6dc72beb5450f4b2127276a94b3b603911edc1 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Tue, 5 Mar 2019 10:18:19 +0100 Subject: [PATCH 48/63] Fix keeping newest test --- .../com/cognifide/aet/cleaner/CleanerIntegrationTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 8cad8d6a0..d8c78a0b8 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -120,15 +120,15 @@ public void clean_whenKeepAllSuites_removeNothing(Long versionsToKeep, Long maxA } @TestWith({ - "1,0,projectA", - "1,1,projectA" + "1,0,projectA,2", + "1,1,projectA,2" }) public void clean_whenAllSuitesOlder_keepOnlyNewestSuite(Long versionsToKeep, Long maxAge, - String projectDataDir) throws JobExecutionException, IOException { + String projectDataDir, int expectedArtifactsLeft) throws JobExecutionException, IOException { setUpDataForTest(versionsToKeep, maxAge, projectDataDir); new CleanerJob().execute(jobExecutionContext); assertEquals(1, getMetadataDocs().countDocuments()); - assertEquals(1, getMetadataDocs().countDocuments()); + assertEquals(expectedArtifactsLeft, getArtifactDocs().countDocuments()); } @After From e2e5355ac56f7457789efaac73ddeb9cccf94481 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Tue, 5 Mar 2019 10:22:49 +0100 Subject: [PATCH 49/63] Add tests for projectB --- .../com/cognifide/aet/cleaner/CleanerIntegrationTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index d8c78a0b8..a0d118345 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -121,7 +121,9 @@ public void clean_whenKeepAllSuites_removeNothing(Long versionsToKeep, Long maxA @TestWith({ "1,0,projectA,2", - "1,1,projectA,2" + "1,1,projectA,2", + "1,0,projectB,3", + "1,1,projectB,3" }) public void clean_whenAllSuitesOlder_keepOnlyNewestSuite(Long versionsToKeep, Long maxAge, String projectDataDir, int expectedArtifactsLeft) throws JobExecutionException, IOException { From 378ec59e8eb5724ac91534ff3b3bce333291b916 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Thu, 7 Mar 2019 13:03:56 +0100 Subject: [PATCH 50/63] Add injecting camelContextCreator for test purposes --- .../com/cognifide/aet/cleaner/CleanerJob.java | 8 +++- .../aet/cleaner/CleanerScheduler.java | 5 +++ .../cleaner/camel/CamelContextCreator.java | 23 +++++++++++ .../camel/DefaultCamelContextCreator.java | 29 ++++++++++++++ .../aet/cleaner/CleanerIntegrationTest.java | 3 +- .../cleaner/TimeoutCamelContextCreator.java | 39 +++++++++++++++++++ 6 files changed, 104 insertions(+), 3 deletions(-) create mode 100644 core/cleaner/src/main/java/com/cognifide/aet/cleaner/camel/CamelContextCreator.java create mode 100644 core/cleaner/src/main/java/com/cognifide/aet/cleaner/camel/DefaultCamelContextCreator.java create mode 100644 core/cleaner/src/test/java/com/cognifide/aet/cleaner/TimeoutCamelContextCreator.java diff --git a/core/cleaner/src/main/java/com/cognifide/aet/cleaner/CleanerJob.java b/core/cleaner/src/main/java/com/cognifide/aet/cleaner/CleanerJob.java index b83deb23b..36016249b 100644 --- a/core/cleaner/src/main/java/com/cognifide/aet/cleaner/CleanerJob.java +++ b/core/cleaner/src/main/java/com/cognifide/aet/cleaner/CleanerJob.java @@ -16,11 +16,11 @@ package com.cognifide.aet.cleaner; +import com.cognifide.aet.cleaner.camel.CamelContextCreator; import com.cognifide.aet.cleaner.context.CleanerContext; import com.cognifide.aet.cleaner.route.MetadataCleanerRouteBuilder; import org.apache.camel.CamelContext; import org.apache.camel.ProducerTemplate; -import org.apache.camel.impl.DefaultCamelContext; import org.quartz.Job; import org.quartz.JobDataMap; import org.quartz.JobExecutionContext; @@ -46,6 +46,8 @@ public class CleanerJob implements Job { static final String KEY_DRY_RUN = "dryRun"; + static final String KEY_CAMEL_CONTEXT_CREATOR = "camelContextCreator"; + @Override public void execute(JobExecutionContext context) throws JobExecutionException { CamelContext camelContext = null; @@ -59,8 +61,10 @@ public void execute(JobExecutionContext context) throws JobExecutionException { final String companyFilter = (String) jobDataMap.get(KEY_COMPANY_FILTER); final String projectFilter = (String) jobDataMap.get(KEY_PROJECT_FILTER); final Boolean dryRun = (Boolean) jobDataMap.get(KEY_DRY_RUN); + final CamelContextCreator contextCreator = (CamelContextCreator) jobDataMap + .get(KEY_CAMEL_CONTEXT_CREATOR); - camelContext = new DefaultCamelContext(); + camelContext = contextCreator.create(); camelContext.setAllowUseOriginalMessage(false); camelContext.addRoutes(cleanerRouteBuilder); camelContext.start(); diff --git a/core/cleaner/src/main/java/com/cognifide/aet/cleaner/CleanerScheduler.java b/core/cleaner/src/main/java/com/cognifide/aet/cleaner/CleanerScheduler.java index 23a621ef2..9b26d24e4 100644 --- a/core/cleaner/src/main/java/com/cognifide/aet/cleaner/CleanerScheduler.java +++ b/core/cleaner/src/main/java/com/cognifide/aet/cleaner/CleanerScheduler.java @@ -15,6 +15,7 @@ */ package com.cognifide.aet.cleaner; +import com.cognifide.aet.cleaner.camel.CamelContextCreator; import com.cognifide.aet.cleaner.configuration.CleanerSchedulerConf; import com.cognifide.aet.cleaner.route.MetadataCleanerRouteBuilder; import com.cognifide.aet.cleaner.validation.CleanerSchedulerValidator; @@ -58,6 +59,9 @@ public class CleanerScheduler { @Reference private MetadataCleanerRouteBuilder metadataCleanerRouteBuilder; + @Reference + private CamelContextCreator camelContextCreator; + @Reference private ValidationResultBuilderFactory validationResultBuilderFactory; @@ -118,6 +122,7 @@ private String registerCleaningJob() throws SchedulerException { final ImmutableMap jobData = ImmutableMap.builder() .put(CleanerJob.KEY_ROUTE_BUILDER, metadataCleanerRouteBuilder) + .put(CleanerJob.KEY_CAMEL_CONTEXT_CREATOR, camelContextCreator) .put(CleanerJob.KEY_KEEP_N_VERSIONS, config.keepNVersions()) .put(CleanerJob.KEY_REMOVE_OLDER_THAN, config.removeOlderThan()) .put(CleanerJob.KEY_COMPANY_FILTER, config.companyName()) diff --git a/core/cleaner/src/main/java/com/cognifide/aet/cleaner/camel/CamelContextCreator.java b/core/cleaner/src/main/java/com/cognifide/aet/cleaner/camel/CamelContextCreator.java new file mode 100644 index 000000000..c85e6babc --- /dev/null +++ b/core/cleaner/src/main/java/com/cognifide/aet/cleaner/camel/CamelContextCreator.java @@ -0,0 +1,23 @@ +/** + * AET + * + * Copyright (C) 2013 Cognifide Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.cognifide.aet.cleaner.camel; + +import org.apache.camel.CamelContext; + +public interface CamelContextCreator { + + CamelContext create(); +} diff --git a/core/cleaner/src/main/java/com/cognifide/aet/cleaner/camel/DefaultCamelContextCreator.java b/core/cleaner/src/main/java/com/cognifide/aet/cleaner/camel/DefaultCamelContextCreator.java new file mode 100644 index 000000000..2183853c8 --- /dev/null +++ b/core/cleaner/src/main/java/com/cognifide/aet/cleaner/camel/DefaultCamelContextCreator.java @@ -0,0 +1,29 @@ +/** + * AET + * + * Copyright (C) 2013 Cognifide Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.cognifide.aet.cleaner.camel; + +import org.apache.camel.CamelContext; +import org.apache.camel.impl.DefaultCamelContext; +import org.osgi.service.component.annotations.Component; + +@Component(service = CamelContextCreator.class) +public class DefaultCamelContextCreator implements CamelContextCreator { + + @Override + public CamelContext create() { + return new DefaultCamelContext(); + } +} diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index a0d118345..25e83b124 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -153,6 +153,7 @@ private void createJobData(Long versionsToKeep, Long maxAge) { .put(CleanerJob.KEY_COMPANY_FILTER, MOCKED_COMPANY_NAME) .put(CleanerJob.KEY_PROJECT_FILTER, MOCKED_PROJECT_NAME) .put(CleanerJob.KEY_DRY_RUN, false) + .put(CleanerJob.KEY_CAMEL_CONTEXT_CREATOR, new TimeoutCamelContextCreator(1L)) .build()); when(jobDetail.getJobDataMap()).thenReturn(jobData); when(jobExecutionContext.getJobDetail()).thenReturn(jobDetail); @@ -179,7 +180,7 @@ private MongoCollection getMetadataDocs() { return client.getDatabase(MOCKED_DB_NAME).getCollection("metadata"); } - private MongoCollection getArtifactDocs(){ + private MongoCollection getArtifactDocs() { return client.getDatabase(MOCKED_DB_NAME).getCollection("artifacts.files"); } } \ No newline at end of file diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/TimeoutCamelContextCreator.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/TimeoutCamelContextCreator.java new file mode 100644 index 000000000..f2247ebb5 --- /dev/null +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/TimeoutCamelContextCreator.java @@ -0,0 +1,39 @@ +/** + * AET + * + * Copyright (C) 2013 Cognifide Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.cognifide.aet.cleaner; + +import com.cognifide.aet.cleaner.camel.CamelContextCreator; +import java.util.concurrent.TimeUnit; +import org.apache.camel.CamelContext; +import org.apache.camel.impl.DefaultCamelContext; + +public class TimeoutCamelContextCreator implements CamelContextCreator { + + private final long timeout; + + TimeoutCamelContextCreator(long timeoutMillis) { + this.timeout = timeoutMillis; + } + + @Override + public CamelContext create() { + CamelContext context = new DefaultCamelContext(); + context.getShutdownStrategy().setTimeUnit(TimeUnit.MILLISECONDS); + context.getShutdownStrategy().setTimeout(timeout); + context.getShutdownStrategy().setShutdownNowOnTimeout(true); + return context; + } +} From 85c45342206e6dec8f4f75c9a8b49bbe7bdd363b Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Thu, 7 Mar 2019 13:07:24 +0100 Subject: [PATCH 51/63] Rename tests --- .../com/cognifide/aet/cleaner/CleanerIntegrationTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 25e83b124..da7a0bd4e 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -109,7 +109,7 @@ public void setUp() { "5,6,projectA", "5,6,projectB" }) - public void clean_whenKeepAllSuites_removeNothing(Long versionsToKeep, Long maxAge, + public void clean_whenNoSuiteMatchesRemoveCondition_keepEverything(Long versionsToKeep, Long maxAge, String projectDataDir) throws JobExecutionException, IOException { setUpDataForTest(versionsToKeep, maxAge, projectDataDir); long metadataCountBefore = getMetadataDocs().countDocuments(); @@ -125,7 +125,7 @@ public void clean_whenKeepAllSuites_removeNothing(Long versionsToKeep, Long maxA "1,0,projectB,3", "1,1,projectB,3" }) - public void clean_whenAllSuitesOlder_keepOnlyNewestSuite(Long versionsToKeep, Long maxAge, + public void clean_whenAllSuitesTooOld_keepOnlyNewestSuite(Long versionsToKeep, Long maxAge, String projectDataDir, int expectedArtifactsLeft) throws JobExecutionException, IOException { setUpDataForTest(versionsToKeep, maxAge, projectDataDir); new CleanerJob().execute(jobExecutionContext); From 994f436f16bea63aa356e643b181adc67d2e6cc0 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Thu, 7 Mar 2019 13:55:04 +0100 Subject: [PATCH 52/63] Add test with specific ids check --- .../aet/cleaner/CleanerIntegrationTest.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index da7a0bd4e..0214857c7 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -16,6 +16,7 @@ package com.cognifide.aet.cleaner; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.when; import com.cognifide.aet.cleaner.processors.FetchAllProjectSuitesProcessor; @@ -32,6 +33,7 @@ import com.google.common.collect.ImmutableMap; import com.googlecode.zohhak.api.TestWith; import com.googlecode.zohhak.api.runners.ZohhakRunner; +import com.mongodb.BasicDBObject; import com.mongodb.MongoClient; import com.mongodb.MongoClientURI; import com.mongodb.client.MongoCollection; @@ -42,9 +44,11 @@ import java.net.InetSocketAddress; import java.time.Instant; import java.time.LocalDateTime; +import java.util.Arrays; import org.apache.commons.io.FileUtils; import org.apache.sling.testing.mock.osgi.junit.OsgiContext; import org.bson.Document; +import org.bson.types.ObjectId; import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -133,6 +137,26 @@ public void clean_whenAllSuitesTooOld_keepOnlyNewestSuite(Long versionsToKeep, L assertEquals(expectedArtifactsLeft, getArtifactDocs().countDocuments()); } + @TestWith({ + "1,0,projectA,5c7e2d446798f408cf3d1df6;5c7e2d436798f408cf3d1dea", + "2,0,projectA,5c7e2d446798f408cf3d1df6;5c7e2d436798f408cf3d1dea;5c7e291f6798f408cf3d1da7", + "1,0,projectB,5c7e349e6798f408cf3d1e10;5c7e35236798f408cf3d1e19;5c7e35236798f408cf3d1e1b", + "2,0,projectB,5c7e349e6798f408cf3d1e10;5c7e35236798f408cf3d1e19;5c7e35236798f408cf3d1e1b;5c7e34c86798f408cf3d1e13" + }) + public void clean_whenRemoveSomeSuites_keepOnlyReferencedArtifacts(Long versionsToKeep, + Long maxAge, String projectDataDir, String artifactsToKeep) + throws IOException, JobExecutionException { + String[] artifactsToKeepIds = artifactsToKeep.split(";"); + setUpDataForTest(versionsToKeep, maxAge, projectDataDir); + new CleanerJob().execute(jobExecutionContext); + Arrays.stream(artifactsToKeepIds).forEach(artifactId -> { + BasicDBObject query = new BasicDBObject(); + query.put("_id", new ObjectId(artifactId)); + assertTrue(getArtifactDocs().find(query).iterator().hasNext()); + }); + assertEquals(artifactsToKeepIds.length, getArtifactDocs().countDocuments()); + } + @After public void tearDown() { client.close(); From b94125774d730aa6ab912b4b088b9628a4d08e3d Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Thu, 7 Mar 2019 14:27:05 +0100 Subject: [PATCH 53/63] Refactor (extract db-related stuff to separate class) --- .../aet/cleaner/CleanerIntegrationTest.java | 75 +++++------------ .../com/cognifide/aet/cleaner/InMemoryDB.java | 84 +++++++++++++++++++ 2 files changed, 105 insertions(+), 54 deletions(-) create mode 100644 core/cleaner/src/test/java/com/cognifide/aet/cleaner/InMemoryDB.java diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 0214857c7..71249241c 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -34,20 +34,11 @@ import com.googlecode.zohhak.api.TestWith; import com.googlecode.zohhak.api.runners.ZohhakRunner; import com.mongodb.BasicDBObject; -import com.mongodb.MongoClient; -import com.mongodb.MongoClientURI; -import com.mongodb.client.MongoCollection; -import de.bwaldvogel.mongo.MongoServer; -import de.bwaldvogel.mongo.backend.memory.MemoryBackend; -import java.io.File; import java.io.IOException; -import java.net.InetSocketAddress; import java.time.Instant; import java.time.LocalDateTime; import java.util.Arrays; -import org.apache.commons.io.FileUtils; import org.apache.sling.testing.mock.osgi.junit.OsgiContext; -import org.bson.Document; import org.bson.types.ObjectId; import org.junit.After; import org.junit.Before; @@ -63,8 +54,12 @@ public class CleanerIntegrationTest { private static final Long MOCKED_CURRENT_TIMESTAMP = 1551428149000L; //March 1, 2019 8:15:49 AM + private static final Long CAMEL_CONTEXT_STOP_TIMEOUT = 1L; private static final String MOCKED_COMPANY_NAME = "company"; private static final String MOCKED_PROJECT_NAME = "project"; + private static final String DATA_DIR = "/integrationTest"; + private static final String METADATA_COL_NAME = "metadata"; + private static final String ARTIFACTS_COL_NAME = "artifacts.files"; private static final String MOCKED_DB_NAME = String .format("%s_%s", MOCKED_COMPANY_NAME, MOCKED_PROJECT_NAME); @@ -74,20 +69,17 @@ public class CleanerIntegrationTest { private JobExecutionContext jobExecutionContext = Mockito.mock(JobExecutionContext.class); private JobDetail jobDetail = Mockito.mock(JobDetail.class); - private MongoClient client; - private MongoServer server; + private InMemoryDB db; + private MetadataCleanerRouteBuilder metadataCleanerRouteBuilder; private LocalDateTimeProvider mockedDateTimeProvider = zone -> LocalDateTime .ofInstant(Instant.ofEpochMilli(MOCKED_CURRENT_TIMESTAMP), zone); @Before public void setUp() { - server = new MongoServer(new MemoryBackend()); - InetSocketAddress address = server.bind(); - String mongoURI = String.format("mongodb://localhost:%d", address.getPort()); - client = new MongoClient(new MongoClientURI(mongoURI)); + db = new InMemoryDB(MOCKED_DB_NAME, DATA_DIR, METADATA_COL_NAME, ARTIFACTS_COL_NAME); - context.registerInjectActivateService(new MongoDBClient(), "mongoURI", mongoURI); + context.registerInjectActivateService(new MongoDBClient(), "mongoURI", db.getURI()); context.registerInjectActivateService(new MetadataDAOMongoDBImpl()); context.registerInjectActivateService(new ArtifactsDAOMongoDBImpl()); @@ -113,14 +105,15 @@ public void setUp() { "5,6,projectA", "5,6,projectB" }) - public void clean_whenNoSuiteMatchesRemoveCondition_keepEverything(Long versionsToKeep, Long maxAge, + public void clean_whenNoSuiteMatchesRemoveCondition_keepEverything(Long versionsToKeep, + Long maxAge, String projectDataDir) throws JobExecutionException, IOException { setUpDataForTest(versionsToKeep, maxAge, projectDataDir); - long metadataCountBefore = getMetadataDocs().countDocuments(); - long artifactCountBefore = getArtifactDocs().countDocuments(); + long metadataCountBefore = db.getMetadataDocsCount(); + long artifactCountBefore = db.getArtifactsDocsCount(); new CleanerJob().execute(jobExecutionContext); - assertEquals(metadataCountBefore, getMetadataDocs().countDocuments()); - assertEquals(artifactCountBefore, getArtifactDocs().countDocuments()); + assertEquals(metadataCountBefore, db.getMetadataDocsCount()); + assertEquals(artifactCountBefore, db.getArtifactsDocsCount()); } @TestWith({ @@ -133,8 +126,8 @@ public void clean_whenAllSuitesTooOld_keepOnlyNewestSuite(Long versionsToKeep, L String projectDataDir, int expectedArtifactsLeft) throws JobExecutionException, IOException { setUpDataForTest(versionsToKeep, maxAge, projectDataDir); new CleanerJob().execute(jobExecutionContext); - assertEquals(1, getMetadataDocs().countDocuments()); - assertEquals(expectedArtifactsLeft, getArtifactDocs().countDocuments()); + assertEquals(1, db.getMetadataDocsCount()); + assertEquals(expectedArtifactsLeft, db.getArtifactsDocsCount()); } @TestWith({ @@ -152,21 +145,20 @@ public void clean_whenRemoveSomeSuites_keepOnlyReferencedArtifacts(Long versions Arrays.stream(artifactsToKeepIds).forEach(artifactId -> { BasicDBObject query = new BasicDBObject(); query.put("_id", new ObjectId(artifactId)); - assertTrue(getArtifactDocs().find(query).iterator().hasNext()); + assertTrue(db.getArtifactDocs().find(query).iterator().hasNext()); }); - assertEquals(artifactsToKeepIds.length, getArtifactDocs().countDocuments()); + assertEquals(artifactsToKeepIds.length, db.getArtifactDocs().countDocuments()); } @After public void tearDown() { - client.close(); - server.shutdown(); + db.shutdown(); } private void setUpDataForTest(Long versionsToKeep, Long maxAge, String projectDataDir) throws IOException { createJobData(versionsToKeep, maxAge); - insertDataToDb(projectDataDir); + db.loadProjectData(projectDataDir); } private void createJobData(Long versionsToKeep, Long maxAge) { @@ -177,34 +169,9 @@ private void createJobData(Long versionsToKeep, Long maxAge) { .put(CleanerJob.KEY_COMPANY_FILTER, MOCKED_COMPANY_NAME) .put(CleanerJob.KEY_PROJECT_FILTER, MOCKED_PROJECT_NAME) .put(CleanerJob.KEY_DRY_RUN, false) - .put(CleanerJob.KEY_CAMEL_CONTEXT_CREATOR, new TimeoutCamelContextCreator(1L)) + .put(CleanerJob.KEY_CAMEL_CONTEXT_CREATOR, new TimeoutCamelContextCreator(CAMEL_CONTEXT_STOP_TIMEOUT)) .build()); when(jobDetail.getJobDataMap()).thenReturn(jobData); when(jobExecutionContext.getJobDetail()).thenReturn(jobDetail); } - - private void insertDataToDb(String projectDataDir) throws IOException { - String[] collectionNames = new String[]{"artifacts.files", "metadata"}; - for (String collectionName : collectionNames) { - String collectionDir = String - .format("/integrationTest/%s/%s", projectDataDir, collectionName); - File[] collectionFiles = new File(getClass().getResource(collectionDir).getFile()) - .listFiles(); - if (collectionFiles != null) { - for (File file : collectionFiles) { - String json = FileUtils.readFileToString(file, "UTF-8"); - client.getDatabase(MOCKED_DB_NAME).getCollection(collectionName) - .insertOne(Document.parse(json)); - } - } - } - } - - private MongoCollection getMetadataDocs() { - return client.getDatabase(MOCKED_DB_NAME).getCollection("metadata"); - } - - private MongoCollection getArtifactDocs() { - return client.getDatabase(MOCKED_DB_NAME).getCollection("artifacts.files"); - } } \ No newline at end of file diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/InMemoryDB.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/InMemoryDB.java new file mode 100644 index 000000000..e92e14af0 --- /dev/null +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/InMemoryDB.java @@ -0,0 +1,84 @@ +package com.cognifide.aet.cleaner; + +import com.mongodb.MongoClient; +import com.mongodb.MongoClientURI; +import com.mongodb.client.MongoCollection; +import com.mongodb.client.MongoDatabase; +import de.bwaldvogel.mongo.MongoServer; +import de.bwaldvogel.mongo.backend.memory.MemoryBackend; +import java.io.File; +import java.io.IOException; +import java.net.InetSocketAddress; +import org.apache.commons.io.FileUtils; +import org.bson.Document; + +public class InMemoryDB { + + private static final String URI_PATTERN = "mongodb://localhost:%d"; + + private final MongoClient client; + private final MongoServer server; + private final String URI; + private final String dbName; + private final String dataDir; + private final String artifactsColName; + private final String metadataColName; + + public InMemoryDB(String dbName, String dataDir, String metadataColName, String artifactsColName) { + this.dbName = dbName; + this.dataDir = dataDir; + this.metadataColName = metadataColName; + this.artifactsColName = artifactsColName; + + server = new MongoServer(new MemoryBackend()); + InetSocketAddress address = server.bind(); + URI = String.format(URI_PATTERN, address.getPort()); + client = new MongoClient(new MongoClientURI(URI)); + } + + public void shutdown() { + server.shutdown(); + client.close(); + } + + + public void loadProjectData(String projectDataDir) throws IOException { + String[] collectionNames = new String[]{artifactsColName, metadataColName}; + for (String collectionName : collectionNames) { + String collectionDir = String + .format("%s/%s/%s", dataDir, projectDataDir, collectionName); + File[] collectionFiles = new File(getClass().getResource(collectionDir).getFile()) + .listFiles(); + if (collectionFiles != null) { + for (File file : collectionFiles) { + String json = FileUtils.readFileToString(file, "UTF-8"); + getDatabase().getCollection(collectionName).insertOne(Document.parse(json)); + } + } + } + } + + public String getURI() { + return URI; + } + + public MongoCollection getMetadataDocs() { + return getDatabase().getCollection(metadataColName); + } + + public MongoCollection getArtifactDocs() { + return getDatabase().getCollection(artifactsColName); + } + + public long getMetadataDocsCount() { + return getMetadataDocs().countDocuments(); + } + + public long getArtifactsDocsCount() { + return getArtifactDocs().countDocuments(); + } + + private MongoDatabase getDatabase() { + return client.getDatabase(dbName); + } +} From c174fe82980726a96c70422652b911a733f2cbe6 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Thu, 7 Mar 2019 14:29:23 +0100 Subject: [PATCH 54/63] Add missing license --- .../com/cognifide/aet/cleaner/InMemoryDB.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/InMemoryDB.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/InMemoryDB.java index e92e14af0..0dcccbbc7 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/InMemoryDB.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/InMemoryDB.java @@ -1,3 +1,18 @@ +/** + * AET + * + * Copyright (C) 2013 Cognifide Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ package com.cognifide.aet.cleaner; import com.mongodb.MongoClient; From e437559c8a732e777e26379640aa1a4e2546f93f Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Thu, 7 Mar 2019 15:40:52 +0100 Subject: [PATCH 55/63] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 034da9836..6b3768f72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ All notable changes to AET will be documented in this file. - [PR-413](https://github.com/Cognifide/aet/pull/413) Added ability to show full page source when there has been no difference discovered ([#369](https://github.com/Cognifide/aet/issues/369)) - [PR-463](https://github.com/Cognifide/aet/pull/463) Removed dependency to Joda time library +- [PR-489](https://github.com/Cognifide/aet/pull/489) Cleaner integration tests ## Version 3.2.0 From c0537b895447c4892542cbcb8be33e817a3b7272 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Thu, 7 Mar 2019 17:46:03 +0100 Subject: [PATCH 56/63] Add system local datetime provider --- .../filters/SuiteRemoveConditionTest.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/filters/SuiteRemoveConditionTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/filters/SuiteRemoveConditionTest.java index 965d68ada..61479f62b 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/filters/SuiteRemoveConditionTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/processors/filters/SuiteRemoveConditionTest.java @@ -20,6 +20,7 @@ import static org.mockito.Mockito.when; import com.cognifide.aet.cleaner.context.CleanerContext; +import com.cognifide.aet.cleaner.time.SystemLocalDateTime; import com.cognifide.aet.communication.api.metadata.Suite; import com.cognifide.aet.communication.api.metadata.Suite.Timestamp; import com.googlecode.zohhak.api.Configure; @@ -52,7 +53,7 @@ public void evaluate_whenOnlyOneSuite_expectFalseNoMatterConditions(String allSu Suite suite = mockSuiteVersionAndCreatedDate(evaluatedSuite, createdDaysAgo); SuiteRemoveCondition condition = new SuiteRemoveCondition(suites, - mockRemoveConditions(removeOlderThan, keepNVersions)); + mockRemoveConditions(removeOlderThan, keepNVersions), new SystemLocalDateTime()); final boolean remove = condition.evaluate(suite); assertFalse(remove); } @@ -82,7 +83,7 @@ public void evaluate_when8SuitesVersionsRemoveOldVersions_expectTrue(String allS Suite suite = mockSuiteVersionAndCreatedDate(evaluatedSuite, createdDaysAgo); SuiteRemoveCondition condition = new SuiteRemoveCondition(suites, - mockRemoveConditions(removeOlderThan, keepNVersions)); + mockRemoveConditions(removeOlderThan, keepNVersions), new SystemLocalDateTime()); final boolean remove = condition.evaluate(suite); assertTrue(remove); } @@ -108,7 +109,7 @@ public void evaluate_when8SuitesVersionsKeepLastVersions_expectFalse(String allS Suite suite = mockSuiteVersionAndCreatedDate(evaluatedSuite, createdDaysAgo); SuiteRemoveCondition condition = new SuiteRemoveCondition(suites, - mockRemoveConditions(removeOlderThan, keepNVersions)); + mockRemoveConditions(removeOlderThan, keepNVersions), new SystemLocalDateTime()); final boolean remove = condition.evaluate(suite); assertFalse(remove); } @@ -136,7 +137,7 @@ public void evaluate_when8SuitesRemoveOlderThanButAlwaysKeepLatestVersion_expect Suite suite = mockSuiteVersionAndCreatedDate(evaluatedSuite, createdDaysAgo); SuiteRemoveCondition condition = new SuiteRemoveCondition(suites, - mockRemoveConditions(removeOlderThan, keepNVersions)); + mockRemoveConditions(removeOlderThan, keepNVersions), new SystemLocalDateTime()); final boolean remove = condition.evaluate(suite); assertTrue(remove); } @@ -155,7 +156,7 @@ public void evaluate_when8SuitesKeepNewerThan_expectFalse(String allSuitesVersio Suite suite = mockSuiteVersionAndCreatedDate(evaluatedSuite, createdDaysAgo); SuiteRemoveCondition condition = new SuiteRemoveCondition(suites, - mockRemoveConditions(removeOlderThan, keepNVersions)); + mockRemoveConditions(removeOlderThan, keepNVersions), new SystemLocalDateTime()); final boolean remove = condition.evaluate(suite); assertFalse(remove); } @@ -174,7 +175,7 @@ public void evaluate_when8SuitesKeepNewerThanAndAtLeastXVersions_expectTrue( Suite suite = mockSuiteVersionAndCreatedDate(evaluatedSuite, createdDaysAgo); SuiteRemoveCondition condition = new SuiteRemoveCondition(suites, - mockRemoveConditions(removeOlderThan, keepNVersions)); + mockRemoveConditions(removeOlderThan, keepNVersions), new SystemLocalDateTime()); final boolean remove = condition.evaluate(suite); assertTrue(remove); } @@ -193,7 +194,7 @@ public void evaluate_when8SuitesKeepNewerThanAndAtLeastXVersions_expectFalse( Suite suite = mockSuiteVersionAndCreatedDate(evaluatedSuite, createdDaysAgo); SuiteRemoveCondition condition = new SuiteRemoveCondition(suites, - mockRemoveConditions(removeOlderThan, keepNVersions)); + mockRemoveConditions(removeOlderThan, keepNVersions), new SystemLocalDateTime()); final boolean remove = condition.evaluate(suite); assertFalse(remove); } @@ -208,7 +209,7 @@ public void evaluate_whenDuplicatedVersion_expectRemoveOnlyOldVersions(String al Suite suite = mockSuiteVersionAndCreatedDate(evaluatedSuite, createdDaysAgo); SuiteRemoveCondition condition = new SuiteRemoveCondition(suites, - mockRemoveConditions(removeOlderThan, keepNVersions)); + mockRemoveConditions(removeOlderThan, keepNVersions), new SystemLocalDateTime()); final boolean remove = condition.evaluate(suite); assertTrue(remove); } @@ -224,7 +225,7 @@ public void evaluate_whenDuplicatedVersion_expectKeepNewestVersion(String allSui Suite suite = mockSuiteVersionAndCreatedDate(evaluatedSuite, createdDaysAgo); SuiteRemoveCondition condition = new SuiteRemoveCondition(suites, - mockRemoveConditions(removeOlderThan, keepNVersions)); + mockRemoveConditions(removeOlderThan, keepNVersions), new SystemLocalDateTime()); final boolean remove = condition.evaluate(suite); assertFalse(remove); } From 719c0e4430aa8cb825e74cfb3b04d22f3c42c0b7 Mon Sep 17 00:00:00 2001 From: Wojciech Blachowski Date: Tue, 12 Mar 2019 08:18:30 +0100 Subject: [PATCH 57/63] Add test scopes in dependencyManagement --- core/cleaner/pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/cleaner/pom.xml b/core/cleaner/pom.xml index 212c5a803..e615d1d71 100644 --- a/core/cleaner/pom.xml +++ b/core/cleaner/pom.xml @@ -39,11 +39,13 @@ de.bwaldvogel mongo-java-server 1.12.0 + test org.apache.sling org.apache.sling.testing.osgi-mock.junit4 2.4.6 + test From 27e9a5feec4f4b3e1e3b1849eab7ae5e4e33d811 Mon Sep 17 00:00:00 2001 From: Tomasz Kaik Date: Wed, 3 Jul 2019 17:10:07 +0200 Subject: [PATCH 58/63] CHANGELOG entry moved to Unrelease section --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8e44e4a5..d45003906 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ All notable changes to AET will be documented in this file. ## Unreleased **List of changes that are finished but not yet released in any final version.** +- [PR-489](https://github.com/Cognifide/aet/pull/489) Cleaner integration tests ## Version 3.2.2 @@ -29,7 +30,6 @@ All notable changes to AET will be documented in this file. - [PR-413](https://github.com/Cognifide/aet/pull/413) Added ability to show full page source when there has been no difference discovered ([#369](https://github.com/Cognifide/aet/issues/369)) - [PR-463](https://github.com/Cognifide/aet/pull/463) Removed dependency to Joda time library - [PR-488](https://github.com/Cognifide/aet/pull/488) Fix SuiteRemoveCondition unit test -- [PR-489](https://github.com/Cognifide/aet/pull/489) Cleaner integration tests - [PR-490](https://github.com/Cognifide/aet/pull/490) Fix removing too many artifacts by cleaner job by terminating processing in case of timeout ## Version 3.2.0 From c735c3ce2777b8b9864bd897ac0750ef6c5715ce Mon Sep 17 00:00:00 2001 From: Tomasz Kaik Date: Wed, 3 Jul 2019 17:11:23 +0200 Subject: [PATCH 59/63] maven-bundle-plugin config and osgi-mock dependencyMgmt moved to root pom.xml --- core/cleaner/pom.xml | 23 ----------------------- core/datastorage/pom.xml | 16 ---------------- pom.xml | 24 ++++++++++++++++++++++++ 3 files changed, 24 insertions(+), 39 deletions(-) diff --git a/core/cleaner/pom.xml b/core/cleaner/pom.xml index e94ce0822..4805b2e8e 100644 --- a/core/cleaner/pom.xml +++ b/core/cleaner/pom.xml @@ -41,16 +41,9 @@ 1.12.0 test - - org.apache.sling - org.apache.sling.testing.osgi-mock.junit4 - 2.4.6 - test - - com.cognifide.aet @@ -165,22 +158,6 @@ maven-bundle-plugin true - - scr-metadata - - manifest - - - true - true - - - <_dsannotations>* - - <_metatypeannotations>* - - - default-bundle diff --git a/core/datastorage/pom.xml b/core/datastorage/pom.xml index 717fac281..9e21c4e12 100644 --- a/core/datastorage/pom.xml +++ b/core/datastorage/pom.xml @@ -121,22 +121,6 @@ maven-bundle-plugin true - - scr-metadata - - manifest - - - true - true - - - <_dsannotations>* - - <_metatypeannotations>* - - - default-bundle diff --git a/pom.xml b/pom.xml index 329f1cf7b..e895c13a7 100644 --- a/pom.xml +++ b/pom.xml @@ -525,6 +525,12 @@ 1.18.0 test + + org.apache.sling + org.apache.sling.testing.osgi-mock.junit4 + 2.4.6 + test + @@ -633,6 +639,24 @@ maven-bundle-plugin 4.0.0 true + + + scr-metadata + + manifest + + + true + true + + + <_dsannotations>* + + <_metatypeannotations>* + + + + From 095158bb9fbceed8f9aea91889e93da70bb5731a Mon Sep 17 00:00:00 2001 From: Tomasz Kaik Date: Wed, 3 Jul 2019 17:17:09 +0200 Subject: [PATCH 60/63] methods order in CleanerIntegrationTest --- .../cognifide/aet/cleaner/CleanerIntegrationTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java index 71249241c..323ef2bfd 100644 --- a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java +++ b/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java @@ -94,6 +94,11 @@ public void setUp() { .registerInjectActivateService(new MetadataCleanerRouteBuilder()); } + @After + public void tearDown() { + db.shutdown(); + } + @TestWith({ //keeping based on age "1,6,projectA", @@ -150,11 +155,6 @@ public void clean_whenRemoveSomeSuites_keepOnlyReferencedArtifacts(Long versions assertEquals(artifactsToKeepIds.length, db.getArtifactDocs().countDocuments()); } - @After - public void tearDown() { - db.shutdown(); - } - private void setUpDataForTest(Long versionsToKeep, Long maxAge, String projectDataDir) throws IOException { createJobData(versionsToKeep, maxAge); From b53a26c8b000327bbd309e9fe649709dc8bcc7c3 Mon Sep 17 00:00:00 2001 From: Tomasz Kaik Date: Thu, 4 Jul 2019 16:19:32 +0200 Subject: [PATCH 61/63] Cleaner integration tests in seperate maven module under integration-tests --- integration-tests/README.md | 7 + integration-tests/cleaner-test/LICENSE | 201 ++++++++++++++++++ integration-tests/cleaner-test/pom.xml | 178 ++++++++++++++++ .../com/cognifide/aet/cleaner/InMemoryDB.java | 0 .../cleaner/TimeoutCamelContextCreator.java | 0 .../aet/cleaner/CleanerIntegrationTest.java | 0 .../projectA/artifacts.files/img1.json | 0 .../projectA/artifacts.files/img2.json | 0 .../projectA/artifacts.files/img3.json | 0 .../projectA/metadata/test1.json | 0 .../projectA/metadata/test2.json | 0 .../projectA/metadata/test3.json | 0 .../projectA/metadata/test4.json | 0 .../projectA/metadata/test5.json | 0 .../projectB/artifacts.files/img1.json | 0 .../projectB/artifacts.files/img2.json | 0 .../projectB/artifacts.files/img3.json | 0 .../projectB/artifacts.files/img4.json | 0 .../projectB/artifacts.files/img5.json | 0 .../projectB/artifacts.files/img6.json | 0 .../projectB/metadata/test1.json | 0 .../projectB/metadata/test2.json | 0 .../projectB/metadata/test3.json | 0 .../projectB/metadata/test4.json | 0 .../projectB/metadata/test5.json | 0 pom.xml | 7 + 26 files changed, 393 insertions(+) create mode 100644 integration-tests/cleaner-test/LICENSE create mode 100644 integration-tests/cleaner-test/pom.xml rename {core/cleaner/src/test => integration-tests/cleaner-test/src/main}/java/com/cognifide/aet/cleaner/InMemoryDB.java (100%) rename {core/cleaner/src/test => integration-tests/cleaner-test/src/main}/java/com/cognifide/aet/cleaner/TimeoutCamelContextCreator.java (100%) rename {core/cleaner => integration-tests/cleaner-test}/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java (100%) rename {core/cleaner => integration-tests/cleaner-test}/src/test/resources/integrationTest/projectA/artifacts.files/img1.json (100%) rename {core/cleaner => integration-tests/cleaner-test}/src/test/resources/integrationTest/projectA/artifacts.files/img2.json (100%) rename {core/cleaner => integration-tests/cleaner-test}/src/test/resources/integrationTest/projectA/artifacts.files/img3.json (100%) rename {core/cleaner => integration-tests/cleaner-test}/src/test/resources/integrationTest/projectA/metadata/test1.json (100%) rename {core/cleaner => integration-tests/cleaner-test}/src/test/resources/integrationTest/projectA/metadata/test2.json (100%) rename {core/cleaner => integration-tests/cleaner-test}/src/test/resources/integrationTest/projectA/metadata/test3.json (100%) rename {core/cleaner => integration-tests/cleaner-test}/src/test/resources/integrationTest/projectA/metadata/test4.json (100%) rename {core/cleaner => integration-tests/cleaner-test}/src/test/resources/integrationTest/projectA/metadata/test5.json (100%) rename {core/cleaner => integration-tests/cleaner-test}/src/test/resources/integrationTest/projectB/artifacts.files/img1.json (100%) rename {core/cleaner => integration-tests/cleaner-test}/src/test/resources/integrationTest/projectB/artifacts.files/img2.json (100%) rename {core/cleaner => integration-tests/cleaner-test}/src/test/resources/integrationTest/projectB/artifacts.files/img3.json (100%) rename {core/cleaner => integration-tests/cleaner-test}/src/test/resources/integrationTest/projectB/artifacts.files/img4.json (100%) rename {core/cleaner => integration-tests/cleaner-test}/src/test/resources/integrationTest/projectB/artifacts.files/img5.json (100%) rename {core/cleaner => integration-tests/cleaner-test}/src/test/resources/integrationTest/projectB/artifacts.files/img6.json (100%) rename {core/cleaner => integration-tests/cleaner-test}/src/test/resources/integrationTest/projectB/metadata/test1.json (100%) rename {core/cleaner => integration-tests/cleaner-test}/src/test/resources/integrationTest/projectB/metadata/test2.json (100%) rename {core/cleaner => integration-tests/cleaner-test}/src/test/resources/integrationTest/projectB/metadata/test3.json (100%) rename {core/cleaner => integration-tests/cleaner-test}/src/test/resources/integrationTest/projectB/metadata/test4.json (100%) rename {core/cleaner => integration-tests/cleaner-test}/src/test/resources/integrationTest/projectB/metadata/test5.json (100%) diff --git a/integration-tests/README.md b/integration-tests/README.md index 2fd814acb..7b708b79c 100644 --- a/integration-tests/README.md +++ b/integration-tests/README.md @@ -61,3 +61,10 @@ or in `.../config/common/webdriver.properties` file. To start the Bobcat tests, run `mvn clean test` from the `sanity-functional` directory level [Chromedriver]: https://sites.google.com/a/chromium.org/chromedriver/ + +### cleaner-test + +Cleaner Integration Tests are using [mocked OSGi context](https://sling.apache.org/documentation/development/osgi-mock.html) +and an [in-memory mock of MongoDB server](https://github.com/bwaldvogel/mongo-java-server). +Tests check various combinations of Cleaner parameters (versions to keep and suite max age) +and verify whether correct metadata and artifacts documents have been removed from database. \ No newline at end of file diff --git a/integration-tests/cleaner-test/LICENSE b/integration-tests/cleaner-test/LICENSE new file mode 100644 index 000000000..6ed9f8d74 --- /dev/null +++ b/integration-tests/cleaner-test/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2013 Cognifide Limited + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/integration-tests/cleaner-test/pom.xml b/integration-tests/cleaner-test/pom.xml new file mode 100644 index 000000000..494afd90d --- /dev/null +++ b/integration-tests/cleaner-test/pom.xml @@ -0,0 +1,178 @@ + + + + 4.0.0 + + + aet-root + com.cognifide.aet + 3.2.3-SNAPSHOT + ../.. + + + cleaner-test + jar + + AET :: Integration Tests :: Cleaner Test + Cleaner Integration Tests + + + + + de.bwaldvogel + mongo-java-server + 1.12.0 + + + + + + + com.cognifide.aet + cleaner + + + com.cognifide.aet + communication-api + + + com.cognifide.aet + datastorage-api + + + com.cognifide.aet + validation-api + + + com.cognifide.aet + datastorage + + + com.cognifide.aet + validation + + + + org.osgi + org.osgi.core + + + org.osgi + org.osgi.compendium + + + org.osgi + org.osgi.service.component.annotations + + + org.osgi + org.osgi.annotation + + + org.osgi + org.osgi.service.metatype.annotations + + + com.google.guava + guava + + + org.apache.commons + commons-lang3 + + + org.apache.activemq + activemq-osgi + + + org.apache.servicemix.bundles + org.apache.servicemix.bundles.quartz + + + org.apache.camel + camel-core + + + + junit + junit + + + org.mockito + mockito-all + + + org.hamcrest + hamcrest-all + + + com.googlecode.zohhak + zohhak + + + com.google.code.gson + gson + test + + + + com.google.code.findbugs + jsr305 + + + + de.bwaldvogel + mongo-java-server + + + org.mongodb + mongo-java-driver + + + org.apache.sling + org.apache.sling.testing.osgi-mock.junit4 + test + + + + + + + org.apache.felix + maven-bundle-plugin + true + + + default-bundle + + + Cognifide Ltd. + javax.annotation;resolution:=optional,* + com.cognifide.aet.cleaner.* + + + + + + + + + diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/InMemoryDB.java b/integration-tests/cleaner-test/src/main/java/com/cognifide/aet/cleaner/InMemoryDB.java similarity index 100% rename from core/cleaner/src/test/java/com/cognifide/aet/cleaner/InMemoryDB.java rename to integration-tests/cleaner-test/src/main/java/com/cognifide/aet/cleaner/InMemoryDB.java diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/TimeoutCamelContextCreator.java b/integration-tests/cleaner-test/src/main/java/com/cognifide/aet/cleaner/TimeoutCamelContextCreator.java similarity index 100% rename from core/cleaner/src/test/java/com/cognifide/aet/cleaner/TimeoutCamelContextCreator.java rename to integration-tests/cleaner-test/src/main/java/com/cognifide/aet/cleaner/TimeoutCamelContextCreator.java diff --git a/core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java b/integration-tests/cleaner-test/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java similarity index 100% rename from core/cleaner/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java rename to integration-tests/cleaner-test/src/test/java/com/cognifide/aet/cleaner/CleanerIntegrationTest.java diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img1.json b/integration-tests/cleaner-test/src/test/resources/integrationTest/projectA/artifacts.files/img1.json similarity index 100% rename from core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img1.json rename to integration-tests/cleaner-test/src/test/resources/integrationTest/projectA/artifacts.files/img1.json diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img2.json b/integration-tests/cleaner-test/src/test/resources/integrationTest/projectA/artifacts.files/img2.json similarity index 100% rename from core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img2.json rename to integration-tests/cleaner-test/src/test/resources/integrationTest/projectA/artifacts.files/img2.json diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img3.json b/integration-tests/cleaner-test/src/test/resources/integrationTest/projectA/artifacts.files/img3.json similarity index 100% rename from core/cleaner/src/test/resources/integrationTest/projectA/artifacts.files/img3.json rename to integration-tests/cleaner-test/src/test/resources/integrationTest/projectA/artifacts.files/img3.json diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test1.json b/integration-tests/cleaner-test/src/test/resources/integrationTest/projectA/metadata/test1.json similarity index 100% rename from core/cleaner/src/test/resources/integrationTest/projectA/metadata/test1.json rename to integration-tests/cleaner-test/src/test/resources/integrationTest/projectA/metadata/test1.json diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json b/integration-tests/cleaner-test/src/test/resources/integrationTest/projectA/metadata/test2.json similarity index 100% rename from core/cleaner/src/test/resources/integrationTest/projectA/metadata/test2.json rename to integration-tests/cleaner-test/src/test/resources/integrationTest/projectA/metadata/test2.json diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test3.json b/integration-tests/cleaner-test/src/test/resources/integrationTest/projectA/metadata/test3.json similarity index 100% rename from core/cleaner/src/test/resources/integrationTest/projectA/metadata/test3.json rename to integration-tests/cleaner-test/src/test/resources/integrationTest/projectA/metadata/test3.json diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test4.json b/integration-tests/cleaner-test/src/test/resources/integrationTest/projectA/metadata/test4.json similarity index 100% rename from core/cleaner/src/test/resources/integrationTest/projectA/metadata/test4.json rename to integration-tests/cleaner-test/src/test/resources/integrationTest/projectA/metadata/test4.json diff --git a/core/cleaner/src/test/resources/integrationTest/projectA/metadata/test5.json b/integration-tests/cleaner-test/src/test/resources/integrationTest/projectA/metadata/test5.json similarity index 100% rename from core/cleaner/src/test/resources/integrationTest/projectA/metadata/test5.json rename to integration-tests/cleaner-test/src/test/resources/integrationTest/projectA/metadata/test5.json diff --git a/core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img1.json b/integration-tests/cleaner-test/src/test/resources/integrationTest/projectB/artifacts.files/img1.json similarity index 100% rename from core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img1.json rename to integration-tests/cleaner-test/src/test/resources/integrationTest/projectB/artifacts.files/img1.json diff --git a/core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img2.json b/integration-tests/cleaner-test/src/test/resources/integrationTest/projectB/artifacts.files/img2.json similarity index 100% rename from core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img2.json rename to integration-tests/cleaner-test/src/test/resources/integrationTest/projectB/artifacts.files/img2.json diff --git a/core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img3.json b/integration-tests/cleaner-test/src/test/resources/integrationTest/projectB/artifacts.files/img3.json similarity index 100% rename from core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img3.json rename to integration-tests/cleaner-test/src/test/resources/integrationTest/projectB/artifacts.files/img3.json diff --git a/core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img4.json b/integration-tests/cleaner-test/src/test/resources/integrationTest/projectB/artifacts.files/img4.json similarity index 100% rename from core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img4.json rename to integration-tests/cleaner-test/src/test/resources/integrationTest/projectB/artifacts.files/img4.json diff --git a/core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img5.json b/integration-tests/cleaner-test/src/test/resources/integrationTest/projectB/artifacts.files/img5.json similarity index 100% rename from core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img5.json rename to integration-tests/cleaner-test/src/test/resources/integrationTest/projectB/artifacts.files/img5.json diff --git a/core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img6.json b/integration-tests/cleaner-test/src/test/resources/integrationTest/projectB/artifacts.files/img6.json similarity index 100% rename from core/cleaner/src/test/resources/integrationTest/projectB/artifacts.files/img6.json rename to integration-tests/cleaner-test/src/test/resources/integrationTest/projectB/artifacts.files/img6.json diff --git a/core/cleaner/src/test/resources/integrationTest/projectB/metadata/test1.json b/integration-tests/cleaner-test/src/test/resources/integrationTest/projectB/metadata/test1.json similarity index 100% rename from core/cleaner/src/test/resources/integrationTest/projectB/metadata/test1.json rename to integration-tests/cleaner-test/src/test/resources/integrationTest/projectB/metadata/test1.json diff --git a/core/cleaner/src/test/resources/integrationTest/projectB/metadata/test2.json b/integration-tests/cleaner-test/src/test/resources/integrationTest/projectB/metadata/test2.json similarity index 100% rename from core/cleaner/src/test/resources/integrationTest/projectB/metadata/test2.json rename to integration-tests/cleaner-test/src/test/resources/integrationTest/projectB/metadata/test2.json diff --git a/core/cleaner/src/test/resources/integrationTest/projectB/metadata/test3.json b/integration-tests/cleaner-test/src/test/resources/integrationTest/projectB/metadata/test3.json similarity index 100% rename from core/cleaner/src/test/resources/integrationTest/projectB/metadata/test3.json rename to integration-tests/cleaner-test/src/test/resources/integrationTest/projectB/metadata/test3.json diff --git a/core/cleaner/src/test/resources/integrationTest/projectB/metadata/test4.json b/integration-tests/cleaner-test/src/test/resources/integrationTest/projectB/metadata/test4.json similarity index 100% rename from core/cleaner/src/test/resources/integrationTest/projectB/metadata/test4.json rename to integration-tests/cleaner-test/src/test/resources/integrationTest/projectB/metadata/test4.json diff --git a/core/cleaner/src/test/resources/integrationTest/projectB/metadata/test5.json b/integration-tests/cleaner-test/src/test/resources/integrationTest/projectB/metadata/test5.json similarity index 100% rename from core/cleaner/src/test/resources/integrationTest/projectB/metadata/test5.json rename to integration-tests/cleaner-test/src/test/resources/integrationTest/projectB/metadata/test5.json diff --git a/pom.xml b/pom.xml index e895c13a7..0ebb7a6b1 100644 --- a/pom.xml +++ b/pom.xml @@ -74,6 +74,7 @@ client core documentation + integration-tests/cleaner-test integration-tests/sample-site integration-tests/test-suite osgi-dependencies @@ -428,6 +429,12 @@ ${project.version} provided + + com.cognifide.aet + cleaner + ${project.version} + provided + From 24c45bc9290f17374d67b942218896c30cee4be0 Mon Sep 17 00:00:00 2001 From: Tomasz Kaik Date: Thu, 4 Jul 2019 16:56:02 +0200 Subject: [PATCH 62/63] cleaner/cleaner-test dependencies cleanup --- core/cleaner/pom.xml | 36 ------------------- core/datastorage/pom.xml | 1 - integration-tests/cleaner-test/pom.xml | 50 ++------------------------ 3 files changed, 2 insertions(+), 85 deletions(-) diff --git a/core/cleaner/pom.xml b/core/cleaner/pom.xml index 4805b2e8e..7a32a4b55 100644 --- a/core/cleaner/pom.xml +++ b/core/cleaner/pom.xml @@ -33,17 +33,6 @@ AET :: Core :: Cleaner Cleaner responsible for removing outdated AET artifacts from datastorage - - - - de.bwaldvogel - mongo-java-server - 1.12.0 - test - - - - com.cognifide.aet @@ -66,14 +55,6 @@ validation - - org.osgi - org.osgi.core - - - org.osgi - org.osgi.compendium - org.osgi org.osgi.service.component.annotations @@ -133,22 +114,6 @@ com.google.code.findbugs jsr305 - - - de.bwaldvogel - mongo-java-server - test - - - org.mongodb - mongo-java-driver - test - - - org.apache.sling - org.apache.sling.testing.osgi-mock.junit4 - test - @@ -156,7 +121,6 @@ org.apache.felix maven-bundle-plugin - true default-bundle diff --git a/core/datastorage/pom.xml b/core/datastorage/pom.xml index 9e21c4e12..a003170fc 100644 --- a/core/datastorage/pom.xml +++ b/core/datastorage/pom.xml @@ -119,7 +119,6 @@ org.apache.felix maven-bundle-plugin - true default-bundle diff --git a/integration-tests/cleaner-test/pom.xml b/integration-tests/cleaner-test/pom.xml index 494afd90d..c14591c2b 100644 --- a/integration-tests/cleaner-test/pom.xml +++ b/integration-tests/cleaner-test/pom.xml @@ -45,30 +45,22 @@ - - com.cognifide.aet - cleaner - com.cognifide.aet communication-api com.cognifide.aet - datastorage-api + cleaner com.cognifide.aet - validation-api + datastorage-api com.cognifide.aet datastorage - - com.cognifide.aet - validation - org.osgi @@ -78,18 +70,6 @@ org.osgi org.osgi.compendium - - org.osgi - org.osgi.service.component.annotations - - - org.osgi - org.osgi.annotation - - - org.osgi - org.osgi.service.metatype.annotations - com.google.guava guava @@ -98,10 +78,6 @@ org.apache.commons commons-lang3 - - org.apache.activemq - activemq-osgi - org.apache.servicemix.bundles org.apache.servicemix.bundles.quartz @@ -153,26 +129,4 @@ - - - - org.apache.felix - maven-bundle-plugin - true - - - default-bundle - - - Cognifide Ltd. - javax.annotation;resolution:=optional,* - com.cognifide.aet.cleaner.* - - - - - - - - From cd8852d56139ba84bc53771fac74a70e438f662e Mon Sep 17 00:00:00 2001 From: Tomasz Kaik Date: Mon, 8 Jul 2019 09:44:38 +0200 Subject: [PATCH 63/63] move all code in clenaer-test module to src/test/java --- integration-tests/cleaner-test/pom.xml | 3 +++ .../java/com/cognifide/aet/cleaner/InMemoryDB.java | 0 .../com/cognifide/aet/cleaner/TimeoutCamelContextCreator.java | 0 3 files changed, 3 insertions(+) rename integration-tests/cleaner-test/src/{main => test}/java/com/cognifide/aet/cleaner/InMemoryDB.java (100%) rename integration-tests/cleaner-test/src/{main => test}/java/com/cognifide/aet/cleaner/TimeoutCamelContextCreator.java (100%) diff --git a/integration-tests/cleaner-test/pom.xml b/integration-tests/cleaner-test/pom.xml index c14591c2b..629e013ca 100644 --- a/integration-tests/cleaner-test/pom.xml +++ b/integration-tests/cleaner-test/pom.xml @@ -40,6 +40,7 @@ de.bwaldvogel mongo-java-server 1.12.0 + test @@ -117,10 +118,12 @@ de.bwaldvogel mongo-java-server + test org.mongodb mongo-java-driver + test org.apache.sling diff --git a/integration-tests/cleaner-test/src/main/java/com/cognifide/aet/cleaner/InMemoryDB.java b/integration-tests/cleaner-test/src/test/java/com/cognifide/aet/cleaner/InMemoryDB.java similarity index 100% rename from integration-tests/cleaner-test/src/main/java/com/cognifide/aet/cleaner/InMemoryDB.java rename to integration-tests/cleaner-test/src/test/java/com/cognifide/aet/cleaner/InMemoryDB.java diff --git a/integration-tests/cleaner-test/src/main/java/com/cognifide/aet/cleaner/TimeoutCamelContextCreator.java b/integration-tests/cleaner-test/src/test/java/com/cognifide/aet/cleaner/TimeoutCamelContextCreator.java similarity index 100% rename from integration-tests/cleaner-test/src/main/java/com/cognifide/aet/cleaner/TimeoutCamelContextCreator.java rename to integration-tests/cleaner-test/src/test/java/com/cognifide/aet/cleaner/TimeoutCamelContextCreator.java