Add integration test to check for thread leaks in sandboxed Daemon tests
Change-Id: Iaebf022608a56618f06550568ac283f0c0ab7f0e
This commit is contained in:
committed by
David Pursehouse
parent
b5584d18f6
commit
5b42a126ef
@@ -500,7 +500,7 @@ public abstract class AbstractDaemonTest {
|
|||||||
return GitUtil.cloneProject(p, inProcessProtocol.register(ctx, repo).toString());
|
return GitUtil.cloneProject(p, inProcessProtocol.register(ctx, repo).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void afterTest() throws Exception {
|
protected void afterTest() throws Exception {
|
||||||
Transport.unregister(inProcessProtocol);
|
Transport.unregister(inProcessProtocol);
|
||||||
for (Repository repo : toClose) {
|
for (Repository repo : toClose) {
|
||||||
repo.close();
|
repo.close();
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
// Copyright (C) 2017 The Android Open Source Project
|
||||||
|
//
|
||||||
|
// 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.google.gerrit.acceptance.pgm;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||||
|
import com.google.gerrit.acceptance.Sandboxed;
|
||||||
|
import java.lang.management.ManagementFactory;
|
||||||
|
import java.lang.management.ThreadMXBean;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.Description;
|
||||||
|
|
||||||
|
@Sandboxed
|
||||||
|
public class StartStopDeamonIT extends AbstractDaemonTest {
|
||||||
|
Description suiteDescription = Description.createSuiteDescription(StartStopDeamonIT.class);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void sandboxedDaemonDoesNotLeakThreads() throws Exception {
|
||||||
|
ThreadMXBean thbean = ManagementFactory.getThreadMXBean();
|
||||||
|
int startThreads = thbean.getThreadCount();
|
||||||
|
beforeTest(suiteDescription);
|
||||||
|
afterTest();
|
||||||
|
assertThat(Thread.activeCount()).isLessThan(startThreads);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user