ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpav...@apache.org
Subject [ignite-teamcity-bot] 02/02: IGNITE-10071 Test reproducing issue was added.
Date Fri, 30 Nov 2018 15:10:21 GMT
This is an automated email from the ASF dual-hosted git repository.

dpavlov pushed a commit to branch ignite-10071
in repository https://gitbox.apache.org/repos/asf/ignite-teamcity-bot.git

commit 275a14d64db4f296002a5277604866784e9fc6b4
Author: Dmitriy Pavlov <dpavlov@apache.org>
AuthorDate: Fri Nov 30 18:10:16 2018 +0300

    IGNITE-10071 Test reproducing issue was added.
---
 .../ignite/ci/teamcity/ignited/BuildRefDao.java    | 12 ++++--
 .../ignited/fatbuild/ProactiveFatBuildSync.java    |  2 +
 .../ignited/IgnitedTcInMemoryIntegrationTest.java  | 45 ++++++++++++++++++++++
 3 files changed, 55 insertions(+), 4 deletions(-)

diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/BuildRefDao.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/BuildRefDao.java
index 5e4a1cb..cbb4645 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/BuildRefDao.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/BuildRefDao.java
@@ -86,7 +86,7 @@ public class BuildRefDao {
      * @param ghData Gh data.
      */
     @AutoProfiling
-    public Set<Long> saveChunk(long srvId, List<BuildRef> ghData) {
+    public Set<Long> saveChunk(int srvId, List<BuildRef> ghData) {
         Set<Long> ids = ghData.stream().map(BuildRef::getId)
             .filter(Objects::nonNull)
             .map(buildId -> buildIdToCacheKey(srvId, buildId))
@@ -228,12 +228,16 @@ public class BuildRefDao {
     public int[] getAllIds(int srvId) {
         GridIntList res = new GridIntList(buildRefsCache.size());
 
-        StreamSupport.stream(buildRefsCache.spliterator(), false)
-                .map(Cache.Entry::getKey)
-                .filter(entry -> isKeyForServer(entry, srvId))
+        getAllBuilds(srvId)
                 .map(BuildRefDao::cacheKeyToBuildId)
                 .forEach(res::add);
 
         return res.array();
     }
+
+    @NotNull public Stream<Long> getAllBuilds(int srvId) {
+        return StreamSupport.stream(buildRefsCache.spliterator(), false)
+                .map(Cache.Entry::getKey)
+                .filter(entry -> isKeyForServer(entry, srvId));
+    }
 }
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/fatbuild/ProactiveFatBuildSync.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/fatbuild/ProactiveFatBuildSync.java
index 6a63289..3cd1a5d 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/fatbuild/ProactiveFatBuildSync.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/teamcity/ignited/fatbuild/ProactiveFatBuildSync.java
@@ -130,6 +130,8 @@ public class ProactiveFatBuildSync {
         int totalAskedToLoad = 0;
 
         for (int buildRefKey : buildRefKeys) {
+            //todo
+            // !existingBuild.isRunning(compactor) && !existingBuild.isQueued(compactor);
             if (!fatBuildDao.containsKey(srvIdMaskHigh, buildRefKey))
                 buildsIdsToLoad.add(buildRefKey);
 
diff --git a/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/teamcity/ignited/IgnitedTcInMemoryIntegrationTest.java
b/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/teamcity/ignited/IgnitedTcInMemoryIntegrationTest.java
index c472447..a9140e5 100644
--- a/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/teamcity/ignited/IgnitedTcInMemoryIntegrationTest.java
+++ b/ignite-tc-helper-web/src/test/java/org/apache/ignite/ci/teamcity/ignited/IgnitedTcInMemoryIntegrationTest.java
@@ -33,6 +33,7 @@ import javax.xml.bind.JAXBException;
 import com.google.inject.internal.SingletonScope;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.Ignition;
+import org.apache.ignite.ci.IAnalyticsEnabledTeamcity;
 import org.apache.ignite.ci.ITeamcity;
 import org.apache.ignite.ci.analysis.SuiteInBranch;
 import org.apache.ignite.ci.analysis.TestInBranch;
@@ -54,10 +55,12 @@ import org.apache.ignite.ci.tcmodel.result.tests.TestOccurrencesFull;
 import org.apache.ignite.ci.teamcity.ignited.buildtype.BuildTypeRefCompacted;
 import org.apache.ignite.ci.teamcity.ignited.fatbuild.FatBuildCompacted;
 import org.apache.ignite.ci.teamcity.ignited.fatbuild.FatBuildDao;
+import org.apache.ignite.ci.teamcity.ignited.fatbuild.ProactiveFatBuildSync;
 import org.apache.ignite.ci.teamcity.ignited.runhist.RunHistCompactedDao;
 import org.apache.ignite.ci.teamcity.ignited.runhist.RunHistSync;
 import org.apache.ignite.ci.teamcity.pure.BuildHistoryEmulator;
 import org.apache.ignite.ci.teamcity.pure.ITeamcityHttpConnection;
+import org.apache.ignite.ci.teamcity.restcached.ITcServerFactory;
 import org.apache.ignite.ci.user.ICredentialsProv;
 import org.apache.ignite.ci.util.XmlUtil;
 import org.apache.ignite.configuration.IgniteConfiguration;
@@ -69,6 +72,7 @@ import org.junit.Test;
 import org.mockito.Mockito;
 
 import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.assertFalse;
 import static junit.framework.TestCase.assertNotNull;
 import static junit.framework.TestCase.assertTrue;
 import static org.apache.ignite.ci.HelperConfig.ensureDirExist;
@@ -535,6 +539,47 @@ public class IgnitedTcInMemoryIntegrationTest {
         assertEquals(0.5, testRunHist.getFailRate(), 0.1);
     }
 
+    @Test
+    public void testQueuedBuildsRemoved() {
+        TeamcityIgnitedModule module = new TeamcityIgnitedModule();
+        module.overrideHttp(new ITeamcityHttpConnection() {
+            @Override public InputStream sendGet(String basicAuthTok, String url) throws
IOException {
+                throw new FileNotFoundException(url);
+            }
+        });
+        Injector injector = Guice.createInjector(module, new IgniteAndShedulerTestModule());
+        IStringCompactor c = injector.getInstance(IStringCompactor.class);
+        BuildRefDao buildRefDao = injector.getInstance(BuildRefDao.class);
+        buildRefDao.init();
+        injector.getInstance(FatBuildDao.class).init();
+
+        int buildId = 1000042;
+        BuildRef ref = new BuildRef();
+        ref.buildTypeId = "Testbuild";
+        ref.branchName = ITeamcity.REFS_HEADS_MASTER;
+        ref.state = BuildRef.STATE_QUEUED;
+        ref.setId(buildId);
+        String srvId = APACHE;
+        int srvIdInt = ITeamcityIgnited.serverIdToInt(srvId);
+        buildRefDao.saveChunk(srvIdInt, Collections.singletonList(ref));
+
+        ITcServerFactory srvFactory = injector.getInstance(ITcServerFactory.class);
+        IAnalyticsEnabledTeamcity srv = srvFactory.createServer(srvId);
+
+        List<BuildRefCompacted> running = buildRefDao.getQueuedAndRunning(srvIdInt);
+        assertNotNull(running);
+        assertFalse(running.isEmpty());
+
+        System.out.println("Running builds: " + running);
+
+        ProactiveFatBuildSync buildSync = injector.getInstance(ProactiveFatBuildSync.class);
+        buildSync.invokeLaterFindMissingByBuildRef(srvId, srv);
+
+        List<BuildRefCompacted> running2 = buildRefDao.getQueuedAndRunning(srvIdInt);
+        assertNotNull(running2);
+        assertTrue(running2.isEmpty());
+    }
+
     /**
      *
      */


Mime
View raw message