Skip to content
Permalink
Browse files
TC Bot modules refactoring: GitHub module extracted
  • Loading branch information
dspavlov committed Jun 13, 2019
1 parent f9c4113 commit 6a5572fa8bfb910f6e670103664882bb7c85e61c
Show file tree
Hide file tree
Showing 41 changed files with 197 additions and 159 deletions.
@@ -58,13 +58,19 @@ allprojects {
slf4jVer = '1.7.25'

gsonVer = '2.8.2'

junitVer = '4.12'
mockitoVer = '2.22.0'
}

repositories {
//uncomment for RC testing
// maven {
// url "https://repository.apache.org/content/repositories/orgapacheignite-1463/"
// }
// maven {
// url "https://repository.apache.org/content/repositories/orgapacheignite-1463/"
// }

mavenCentral()
mavenLocal()
}
}

@@ -20,11 +20,7 @@ apply plugin: 'war'

sourceCompatibility = '1.8'
targetCompatibility = '1.8'

repositories {
mavenCentral()
mavenLocal()
}


// https://www.apache.org/legal/resolved.html#category-a
dependencies {
@@ -111,15 +111,6 @@ public static <K, V> CacheConfiguration<K, V> getCacheV2TxConfig(String name) {

}

@NotNull
public static <K, V> CacheConfiguration<K, V> getCache8PartsConfig(String name) {
CacheConfiguration<K, V> ccfg = new CacheConfiguration<>(name);

ccfg.setAffinity(new RendezvousAffinityFunction(false, 8));

return ccfg;
}

public static class LocalOnlyTcpDiscoveryIpFinder implements TcpDiscoveryIpFinder {
/** Port. */
private int port;
@@ -29,7 +29,7 @@
import org.apache.ignite.ci.db.Ignite1Init;
import org.apache.ignite.ci.di.cache.GuavaCachedModule;
import org.apache.ignite.ci.di.scheduler.SchedulerModule;
import org.apache.ignite.ci.github.ignited.GitHubIgnitedModule;
import org.apache.ignite.githubignited.GitHubIgnitedModule;
import org.apache.ignite.ci.jira.ignited.JiraIgnitedModule;
import org.apache.ignite.ci.observer.BuildObserver;
import org.apache.ignite.ci.observer.ObserverTask;
@@ -32,6 +32,7 @@
import org.apache.ignite.tcbot.common.interceptor.AutoProfiling;
import org.apache.ignite.tcbot.common.interceptor.GuavaCached;
import org.apache.ignite.ci.jira.pure.Ticket;
import org.apache.ignite.tcbot.persistence.CacheConfigs;
import org.apache.ignite.tcbot.persistence.IStringCompactor;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -56,7 +57,7 @@ public class JiraTicketDao {
*
*/
public void init() {
jiraCache = igniteProvider.get().getOrCreateCache(TcHelperDb.getCache8PartsConfig(TEAMCITY_JIRA_TICKET_CACHE_NAME));
jiraCache = igniteProvider.get().getOrCreateCache(CacheConfigs.getCache8PartsConfig(TEAMCITY_JIRA_TICKET_CACHE_NAME));
}

/**
@@ -20,7 +20,7 @@
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.ci.db.TcHelperDb;
import org.apache.ignite.ci.github.ignited.IGitHubConnIgnited;
import org.apache.ignite.githubignited.IGitHubConnIgnited;
import org.apache.ignite.ci.issue.Issue;
import org.apache.ignite.ci.issue.IssuesStorage;
import org.apache.ignite.ci.jira.ignited.JiraTicketDao;
@@ -24,10 +24,10 @@
import javax.inject.Inject;

import org.apache.ignite.ci.github.PullRequest;
import org.apache.ignite.ci.github.pure.IGitHubConnection;
import org.apache.ignite.githubservice.IGitHubConnection;
import org.apache.ignite.tcbot.engine.chain.*;
import org.apache.ignite.ci.github.ignited.IGitHubConnIgnited;
import org.apache.ignite.ci.github.ignited.IGitHubConnIgnitedProvider;
import org.apache.ignite.githubignited.IGitHubConnIgnited;
import org.apache.ignite.githubignited.IGitHubConnIgnitedProvider;
import org.apache.ignite.ci.jira.ignited.IJiraIgnited;
import org.apache.ignite.ci.jira.ignited.IJiraIgnitedProvider;
import org.apache.ignite.ci.tcbot.visa.BranchTicketMatcher;
@@ -18,10 +18,10 @@
package org.apache.ignite.ci.tcbot.visa;

import com.google.common.base.Strings;
import org.apache.ignite.githubservice.IGitHubConnection;
import org.apache.ignite.tcbot.common.interceptor.GuavaCached;
import org.apache.ignite.ci.github.PullRequest;
import org.apache.ignite.ci.github.ignited.IGitHubConnIgnitedProvider;
import org.apache.ignite.ci.github.pure.IGitHubConnection;
import org.apache.ignite.githubignited.IGitHubConnIgnitedProvider;
import org.apache.ignite.ci.jira.ignited.IJiraIgnitedProvider;
import org.apache.ignite.ci.jira.ignited.TicketCompacted;
import org.apache.ignite.ci.jira.pure.Ticket;
@@ -41,8 +41,8 @@
import org.apache.ignite.ci.github.GitHubBranch;
import org.apache.ignite.ci.github.GitHubUser;
import org.apache.ignite.ci.github.PullRequest;
import org.apache.ignite.ci.github.ignited.IGitHubConnIgnited;
import org.apache.ignite.ci.github.ignited.IGitHubConnIgnitedProvider;
import org.apache.ignite.githubignited.IGitHubConnIgnited;
import org.apache.ignite.githubignited.IGitHubConnIgnitedProvider;
import org.apache.ignite.ci.jira.ignited.IJiraIgnited;
import org.apache.ignite.ci.jira.ignited.IJiraIgnitedProvider;
import org.apache.ignite.ci.jira.pure.Ticket;
@@ -31,8 +31,9 @@
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import org.apache.ignite.ci.github.pure.IGitHubConnection;
import org.apache.ignite.ci.github.pure.IGitHubConnectionProvider;

import org.apache.ignite.githubservice.IGitHubConnection;
import org.apache.ignite.githubservice.IGitHubConnectionProvider;
import org.apache.ignite.tcbot.common.conf.IJiraServerConfig;
import org.apache.ignite.tcbot.engine.conf.ITcBotConfig;
import org.apache.ignite.ci.tcbot.trigger.TriggerResult;
@@ -30,10 +30,10 @@
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import org.apache.ignite.ci.github.PullRequest;
import org.apache.ignite.ci.github.ignited.IGitHubConnIgnited;
import org.apache.ignite.ci.github.ignited.IGitHubConnIgnitedProvider;
import org.apache.ignite.ci.github.pure.IGitHubConnection;
import org.apache.ignite.githubignited.IGitHubConnIgnited;
import org.apache.ignite.githubignited.IGitHubConnIgnitedProvider;
import org.apache.ignite.ci.tcbot.chain.PrChainsProcessor;
import org.apache.ignite.githubservice.IGitHubConnection;
import org.apache.ignite.tcignited.SyncMode;
import org.apache.ignite.ci.user.ITcBotUserCreds;
import org.apache.ignite.ci.web.CtxListener;
@@ -1,54 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.ignite.ci.github.pure;

import com.google.common.base.Preconditions;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import org.apache.ignite.ci.github.PullRequest;
import org.junit.Test;

import static junit.framework.TestCase.assertEquals;

public class GitHubPrsParseTest {

@Test
public void parse() {
InputStream stream = this.getClass().getResourceAsStream("/prsList.json");
Preconditions.checkNotNull(stream, "Can't find resource");
Type listType = new TypeToken<ArrayList<PullRequest>>() {
}.getType();
List<PullRequest> list = new Gson().fromJson(new InputStreamReader(stream), listType);

System.out.println(list.size());
System.out.println(list);
}

@Test
public void parseLinkRspHeader() {
String s = "<https://api.github.com/repositories/31006158/pulls?sort=updated&direction=desc&page=2>; rel=\"next\", <https://api.github.com/repositories/31006158/pulls?sort=updated&direction=desc&page=45>; rel=\"last\"\n";
String nextLink = GitHubConnectionImpl.parseNextLinkFromLinkRspHeader(s);

assertEquals("https://api.github.com/repositories/31006158/pulls?sort=updated&direction=desc&page=2", nextLink);
}

}
@@ -23,15 +23,15 @@
import java.util.Properties;
import org.apache.ignite.ci.HelperConfig;
import org.apache.ignite.ci.github.PullRequest;
import org.apache.ignite.ci.github.ignited.IGitHubConnIgnited;
import org.apache.ignite.ci.github.ignited.IGitHubConnIgnitedProvider;
import org.apache.ignite.ci.github.pure.IGitHubConnection;
import org.apache.ignite.ci.github.pure.IGitHubConnectionProvider;
import org.apache.ignite.githubignited.IGitHubConnIgnited;
import org.apache.ignite.githubignited.IGitHubConnIgnitedProvider;
import org.apache.ignite.ci.jira.ignited.IJiraIgnited;
import org.apache.ignite.ci.jira.ignited.IJiraIgnitedProvider;
import org.apache.ignite.ci.jira.pure.IJiraIntegration;
import org.apache.ignite.ci.jira.pure.IJiraIntegrationProvider;
import org.apache.ignite.ci.tcbot.conf.TcBotJsonConfig;
import org.apache.ignite.githubservice.IGitHubConnection;
import org.apache.ignite.githubservice.IGitHubConnectionProvider;
import org.apache.ignite.tcbot.common.conf.IGitHubConfig;
import org.apache.ignite.tcbot.common.conf.IJiraServerConfig;
import org.apache.ignite.tcbot.engine.conf.ITcBotConfig;
@@ -20,11 +20,7 @@ apply plugin: 'application'

sourceCompatibility = '1.8'
targetCompatibility = '1.8'

repositories {
mavenCentral()
mavenLocal()
}


mainClassName = 'org.apache.ignite.ci.TcHelperJettyLauncher'
applicationDefaultJvmArgs = ["-Dteamcity.helper.home=../work",
@@ -5,5 +5,7 @@ include 'tcbot-common'
include 'tcbot-persistence'
include 'tcbot-teamcity'
include 'tcbot-teamcity-ignited'
include 'tcbot-github'
include 'tcbot-github-ignited'
include 'tcbot-engine'

@@ -17,28 +17,21 @@

apply plugin: 'java'

repositories {
mavenCentral()
mavenLocal()
}

dependencies {
compile group: 'com.google.guava', name: 'guava', version: guavaVer

compile group: 'org.slf4j', name: 'slf4j-api', version: slf4jVer
//Apache License Version 2.0
compile group: 'com.google.code.gson', name: 'gson', version: gsonVer

testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.22.0'

compile group: 'javax.inject', name: 'javax.inject', version: '1'
compile group: 'com.google.inject', name: 'guice', version: '4.2.0'

compile group: 'org.xerial.snappy', name: 'snappy-java', version: '1.1.7.2'

/// JAXB replacement for Java 11
//impl is used by TC module, only converters needed here
compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
compile group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.3.0'
compile group: 'com.sun.xml.bind', name: 'jaxb-core', version: '2.3.0'

testCompile group: 'junit', name: 'junit', version: junitVer
testCompile group: 'org.mockito', name: 'mockito-core', version: mockitoVer
}
@@ -22,4 +22,6 @@
*/
public interface IDataSourcesConfigSupplier {
public ITcServerConfig getTeamcityConfig(String srvCode);

public IGitHubConfig getGitConfig(String srvCode);
}
@@ -17,13 +17,9 @@

apply plugin: 'java'

repositories {
mavenCentral()
mavenLocal()
}

dependencies {
compile (project(":tcbot-persistence"));
compile (project(":tcbot-teamcity-ignited"));
compile (project(":tcbot-teamcity-ignited"));
compile (project(":tcbot-github-ignited"));
}

@@ -0,0 +1,3 @@
TC Bot GitHub Ignited module
--------------------------------
Module for requests to Ingnite caches containing GitHub data
@@ -0,0 +1,24 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/

apply plugin: 'java'

dependencies {
compile (project(":tcbot-github"));
compile (project(":tcbot-persistence"));
}

@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.ignite.ci.github.ignited;
package org.apache.ignite.githubignited;

import java.util.HashSet;
import java.util.List;
@@ -25,21 +25,21 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Provider;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.ci.db.TcHelperDb;
import org.apache.ignite.githubservice.IGitHubConnection;
import org.apache.ignite.tcbot.common.interceptor.AutoProfiling;
import org.apache.ignite.tcbot.common.interceptor.MonitoredTask;
import org.apache.ignite.tcbot.persistence.CacheConfigs;
import org.apache.ignite.tcbot.persistence.scheduler.IScheduler;
import org.apache.ignite.ci.github.GitHubBranchKey;
import org.apache.ignite.ci.github.GitHubBranchShort;
import org.apache.ignite.ci.github.PullRequest;
import org.apache.ignite.ci.github.pure.IGitHubConnection;
import org.apache.ignite.tcbot.common.conf.IGitHubConfig;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@@ -86,8 +86,8 @@ public void init(IGitHubConnection conn) {
srvIdMaskHigh = Math.abs(srvCode.hashCode());

Ignite ignite = igniteProvider.get();
prCache = ignite.getOrCreateCache(TcHelperDb.getCache8PartsConfig(GIT_HUB_PR));
branchCache = ignite.getOrCreateCache(TcHelperDb.getCache8PartsConfig(GIT_HUB_BRANCHES));
prCache = ignite.getOrCreateCache(CacheConfigs.getCache8PartsConfig(GIT_HUB_PR));
branchCache = ignite.getOrCreateCache(CacheConfigs.getCache8PartsConfig(GIT_HUB_BRANCHES));
}

/** {@inheritDoc} */
@@ -148,7 +148,7 @@ private void actualizeBranches() {
* @param taskName Task name.
* @return Task name concatenated with server name.
*/
@NotNull
@Nonnull
private String taskName(String taskName) {
return IGitHubConnIgnited.class.getSimpleName() + "." + taskName + "." + srvCode;
}

0 comments on commit 6a5572f

Please sign in to comment.