Merge branch 'stable-3.0' into stable-3.1

* stable-3.0:
  Update web-component-tester to 6.5.1
  Add support for Elasticsearch version 7.6.*
  Error Prone: Enable and fix ClassCanBeStatic
  Write upload-pack metrics to sshd log

Change-Id: I533d5ca030b608399cc56e7905c9c5b6e6a994bc
This commit is contained in:
David Pursehouse
2020-02-12 18:31:22 +09:00
18 changed files with 78 additions and 16 deletions

View File

@@ -1164,8 +1164,8 @@ bower_archive(
bower_archive(
name = "web-component-tester",
package = "polymer/web-component-tester",
sha1 = "62739cb633fccfddc5eeed98e9e3f69cd0388b5b",
version = "6.5.0",
sha1 = "d84f6a13bde5f8fd39ee208d43f33925410530d7",
version = "6.5.1",
)
# Bower component transitive dependencies.

View File

@@ -31,7 +31,8 @@ public enum ElasticVersion {
V7_2("7.2.*"),
V7_3("7.3.*"),
V7_4("7.4.*"),
V7_5("7.5.*");
V7_5("7.5.*"),
V7_6("7.6.*");
private final String version;
private final Pattern pattern;

View File

@@ -80,7 +80,7 @@ public abstract class BaseCommand implements Command {
protected OutputStream out;
protected OutputStream err;
private ExitCallback exit;
protected ExitCallback exit;
@Inject protected CurrentUser user;
@@ -88,7 +88,7 @@ public abstract class BaseCommand implements Command {
@Inject private CmdLineParser.Factory cmdLineParserFactory;
@Inject private RequestCleanup cleanup;
@Inject protected RequestCleanup cleanup;
@Inject @CommandExecutor private ScheduledThreadPoolExecutor executor;

View File

@@ -187,7 +187,7 @@ class CommandFactoryProvider implements Provider<CommandFactory>, LifecycleListe
@Override
public void onExit(int rc, String exitMessage) {
exit.onExit(translateExit(rc), exitMessage);
log(rc);
log(rc, exitMessage);
}
@Override
@@ -225,6 +225,12 @@ class CommandFactoryProvider implements Provider<CommandFactory>, LifecycleListe
}
}
private void log(int rc, String message) {
if (logged.compareAndSet(false, true)) {
log.onExecute(cmd, rc, ctx.getSession(), message);
}
}
@Override
public void destroy(ChannelSession channel) {
Future<?> future = task.getAndSet(null);

View File

@@ -53,6 +53,7 @@ class SshLog implements LifecycleListener, GerritConfigListener {
private static final String P_EXEC = "executionTime";
private static final String P_STATUS = "status";
private static final String P_AGENT = "agent";
private static final String P_MESSAGE = "message";
private final Provider<SshSession> session;
private final Provider<Context> context;
@@ -147,6 +148,10 @@ class SshLog implements LifecycleListener, GerritConfigListener {
}
void onExecute(DispatchCommand dcmd, int exitValue, SshSession sshSession) {
onExecute(dcmd, exitValue, sshSession, null);
}
void onExecute(DispatchCommand dcmd, int exitValue, SshSession sshSession, String message) {
final Context ctx = context.get();
ctx.finished = TimeUtil.nowMs();
@@ -180,6 +185,10 @@ class SshLog implements LifecycleListener, GerritConfigListener {
event.setProperty(P_AGENT, peerAgent);
}
if (message != null) {
event.setProperty(P_MESSAGE, message);
}
if (async != null) {
async.append(event);
}

View File

@@ -30,6 +30,7 @@ public final class SshLogLayout extends Layout {
private static final String P_EXEC = "executionTime";
private static final String P_STATUS = "status";
private static final String P_AGENT = "agent";
private static final String P_MESSAGE = "message";
private final Calendar calendar;
private long lastTimeMillis;
@@ -68,6 +69,7 @@ public final class SshLogLayout extends Layout {
opt(P_WAIT, buf, event);
opt(P_EXEC, buf, event);
opt(P_MESSAGE, buf, event);
opt(P_STATUS, buf, event);
opt(P_AGENT, buf, event);

View File

@@ -37,6 +37,7 @@ import com.google.inject.Inject;
import java.io.IOException;
import java.util.List;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.storage.pack.PackStatistics;
import org.eclipse.jgit.transport.PostUploadHook;
import org.eclipse.jgit.transport.PostUploadHookChain;
import org.eclipse.jgit.transport.PreUploadHook;
@@ -54,6 +55,8 @@ final class Upload extends AbstractGitCommand {
@Inject private SshSession session;
@Inject private PermissionBackend permissionBackend;
private PackStatistics stats;
@Override
protected void runImpl() throws IOException, Failure {
PermissionBackend.ForProject perm =
@@ -94,6 +97,7 @@ final class Upload extends AbstractGitCommand {
up.setProtocolV2Hook(tracingHook);
up.upload(in, out, err);
session.setPeerAgent(up.getPeerUserAgent());
stats = up.getStatistics();
} catch (UploadValidationException e) {
// UploadValidationException is used by the UploadValidators to
// stop the uploadPack. We do not want this exception to go beyond this
@@ -104,4 +108,36 @@ final class Upload extends AbstractGitCommand {
}
}
}
@Override
protected void onExit(int rc) {
exit.onExit(
rc,
stats != null
? stats.getTimeNegotiating()
+ "ms "
+ stats.getTimeSearchingForReuse()
+ "ms "
+ stats.getTimeSearchingForSizes()
+ "ms "
+ stats.getTimeCounting()
+ "ms "
+ stats.getTimeCompressing()
+ "ms "
+ stats.getTimeWriting()
+ "ms "
+ stats.getTimeTotal()
+ "ms "
+ stats.getBitmapIndexMisses()
+ " "
+ stats.getTotalDeltas()
+ " "
+ stats.getTotalObjects()
+ " "
+ stats.getTotalBytes()
: "-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1");
if (cleanup != null) {
cleanup.run();
}
}
}

View File

@@ -37,7 +37,7 @@ public class ElasticReindexIT extends AbstractReindexTests {
@ConfigSuite.Config
public static Config elasticsearchV7() {
return getConfig(ElasticVersion.V7_5);
return getConfig(ElasticVersion.V7_6);
}
@Override

View File

@@ -38,7 +38,7 @@ public class ElasticIndexIT extends AbstractIndexTests {
@ConfigSuite.Config
public static Config elasticsearchV7() {
return getConfig(ElasticVersion.V7_5);
return getConfig(ElasticVersion.V7_6);
}
@Override

View File

@@ -64,6 +64,8 @@ public class ElasticContainer extends ElasticsearchContainer {
return "blacktop/elasticsearch:7.4.2";
case V7_5:
return "blacktop/elasticsearch:7.5.2";
case V7_6:
return "blacktop/elasticsearch:7.6.0";
}
throw new IllegalStateException("No tests for version: " + version.name());
}

View File

@@ -41,7 +41,7 @@ public class ElasticV7QueryAccountsTest extends AbstractQueryAccountsTest {
return;
}
container = ElasticContainer.createAndStart(ElasticVersion.V7_5);
container = ElasticContainer.createAndStart(ElasticVersion.V7_6);
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
}

View File

@@ -51,7 +51,7 @@ public class ElasticV7QueryChangesTest extends AbstractQueryChangesTest {
return;
}
container = ElasticContainer.createAndStart(ElasticVersion.V7_5);
container = ElasticContainer.createAndStart(ElasticVersion.V7_6);
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
client = HttpAsyncClients.createDefault();
client.start();

View File

@@ -41,7 +41,7 @@ public class ElasticV7QueryGroupsTest extends AbstractQueryGroupsTest {
return;
}
container = ElasticContainer.createAndStart(ElasticVersion.V7_5);
container = ElasticContainer.createAndStart(ElasticVersion.V7_6);
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
}

View File

@@ -41,7 +41,7 @@ public class ElasticV7QueryProjectsTest extends AbstractQueryProjectsTest {
return;
}
container = ElasticContainer.createAndStart(ElasticVersion.V7_5);
container = ElasticContainer.createAndStart(ElasticVersion.V7_6);
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
}

View File

@@ -63,6 +63,9 @@ public class ElasticVersionTest {
assertThat(ElasticVersion.forVersion("7.5.0")).isEqualTo(ElasticVersion.V7_5);
assertThat(ElasticVersion.forVersion("7.5.1")).isEqualTo(ElasticVersion.V7_5);
assertThat(ElasticVersion.forVersion("7.6.0")).isEqualTo(ElasticVersion.V7_6);
assertThat(ElasticVersion.forVersion("7.6.1")).isEqualTo(ElasticVersion.V7_6);
}
@Test
@@ -93,6 +96,7 @@ public class ElasticVersionTest {
assertThat(ElasticVersion.V7_3.isAtLeastMinorVersion(ElasticVersion.V6_7)).isFalse();
assertThat(ElasticVersion.V7_4.isAtLeastMinorVersion(ElasticVersion.V6_7)).isFalse();
assertThat(ElasticVersion.V7_5.isAtLeastMinorVersion(ElasticVersion.V6_7)).isFalse();
assertThat(ElasticVersion.V7_6.isAtLeastMinorVersion(ElasticVersion.V6_7)).isFalse();
}
@Test
@@ -111,6 +115,7 @@ public class ElasticVersionTest {
assertThat(ElasticVersion.V7_3.isV6OrLater()).isTrue();
assertThat(ElasticVersion.V7_4.isV6OrLater()).isTrue();
assertThat(ElasticVersion.V7_5.isV6OrLater()).isTrue();
assertThat(ElasticVersion.V7_6.isV6OrLater()).isTrue();
}
@Test
@@ -129,5 +134,6 @@ public class ElasticVersionTest {
assertThat(ElasticVersion.V7_3.isV7OrLater()).isTrue();
assertThat(ElasticVersion.V7_4.isV7OrLater()).isTrue();
assertThat(ElasticVersion.V7_5.isV7OrLater()).isTrue();
assertThat(ElasticVersion.V7_6.isV7OrLater()).isTrue();
}
}

View File

@@ -155,7 +155,7 @@ def load_bower_archives():
)
bower_archive(
name = "sinonjs",
package = "sinonjs",
package = "Polymer/sinon.js",
version = "1.17.1",
sha1 = "a26a6aab7358807de52ba738770f6ac709afd240",
)

View File

@@ -11,7 +11,7 @@
"fried-twinkie": "^0.2.2",
"polylint": "^2.10.4",
"typescript": "^2.x.x",
"web-component-tester": "^6.5.0"
"web-component-tester": "^6.5.1"
},
"scripts": {
"start": "polygerrit-ui/run-server.sh",

View File

@@ -102,8 +102,8 @@ def declare_nongoogle_deps():
# and httpasyncclient as necessary.
maven_jar(
name = "elasticsearch-rest-client",
artifact = "org.elasticsearch.client:elasticsearch-rest-client:7.5.2",
sha1 = "e11393f600a425b7f62e6f653e19a9e53556fd79",
artifact = "org.elasticsearch.client:elasticsearch-rest-client:7.6.0",
sha1 = "3d56c1fca22af1aab5a1b23698ae9ec6f71db1a2",
)
maven_jar(