Skip to content

Bump com.google.gerrit:gerrit-plugin-api from 2.14.16 to 2.15.21 #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions eiffel-gerrit-plugin-script
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function do_stop {
echo "########################################"

source target/env.bash
docker-compose -f target/docker-compose.yml down
docker compose -f target/docker-compose.yml down
if [ $? -eq 1 ]; then
echo "Failed to stop docker containers!"
exit 1
Expand Down Expand Up @@ -62,12 +62,13 @@ function do_start {
echo "########################################"

source target/env.bash
docker-compose -f target/docker-compose.yml up -d
docker compose -f target/docker-compose.yml up -d

wait_for_service "RABBITMQ" "target_rabbitmq" "15672"
wait_for_service "GERRIT" "target_gerrit" "8080"
wait_for_service "REMREM_PUBLISH" "target_publish" "8080"
wait_for_service "REMREM_GENERATE" "target_generate" "8080"
wait_for_service "RABBITMQ" "target-rabbitmq" "15672"
wait_for_service "GERRIT" "target-gerrit" "8080"
sleep 60
wait_for_service "REMREM_PUBLISH" "target-publish" "8080"
wait_for_service "REMREM_GENERATE" "target-generate" "8080"
}

function do_test {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<properties>
<Gerrit-ApiType>plugin</Gerrit-ApiType>
<Gerrit-ApiVersion>2.14.16</Gerrit-ApiVersion>
<Gerrit-ApiVersion>2.15.21</Gerrit-ApiVersion>
<Gerrit-PluginName>Eiffel-Integration</Gerrit-PluginName>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<skipTests>false</skipTests>
Expand Down
7 changes: 6 additions & 1 deletion src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ LABEL maintainer="Eiffel-Community"

ARG JAR_LOCATION

# Update repository URLs to point to the CentOS Vault
RUN sed -i 's/mirror.centos.org/vault.centos.org/g' /etc/yum.repos.d/*.repo && \
sed -i 's/^#.*baseurl=http/baseurl=http/g' /etc/yum.repos.d/*.repo && \
sed -i 's/^mirrorlist=http/#mirrorlist=http/g' /etc/yum.repos.d/*.repo

RUN yum -y install openssh-client initscripts sudo

# Add Gerrit packages repository
Expand All @@ -12,7 +17,7 @@ RUN rpm -i https://gerritforge.com/gerritforge-repo-1-2.noarch.rpm
# Install OpenJDK and Gerrit in two subsequent transactions
# (pre-trans Gerrit script needs to have access to the Java command)
RUN yum -y install java-1.8.0-openjdk
RUN yum -y install gerrit-2.14.16-1
RUN yum -y install gerrit-2.15.21-1
RUN yum -y install bash

USER gerrit
Expand Down
2 changes: 1 addition & 1 deletion src/main/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '2'
#version: '2'

services:
gerrit:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.google.gerrit.extensions.restapi.IdString;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.server.project.CommitResource;
import com.google.gerrit.server.project.CommitsCollection;
import com.google.gerrit.server.project.ProjectResource;
Expand Down Expand Up @@ -80,7 +81,7 @@ private List<RevCommit> getParents(final String commitId, final String projectNa

try {
parents = getParentsFromCommit(commitId, projectName);
} catch (final UnprocessableEntityException e) {
} catch (final UnprocessableEntityException | PermissionBackendException e) {
final String message = String.format("Cannot find or load the project %s", projectName);
LOGGER.error(message, e);
} catch (final ResourceNotFoundException e) {
Expand All @@ -95,15 +96,21 @@ private List<RevCommit> getParents(final String commitId, final String projectNa
}

private List<RevCommit> getParentsFromCommit(final String commitId, final String projectName)
throws UnprocessableEntityException, IOException, ResourceNotFoundException {

throws UnprocessableEntityException, IOException, ResourceNotFoundException, PermissionBackendException {
RevCommit[] parents = null;
try{
final ProjectResource projectResource = projectsCollection.parse(projectName, true);
final CommitResource commitResource = commitsCollection.parse(projectResource,
IdString.fromDecoded(commitId));
final RevCommit commit = commitResource.getCommit();
final RevCommit[] parents = commit.getParents();

return Arrays.asList(parents);
parents = commit.getParents();
}
catch (PermissionBackendException e) {
System.out.println("PermissionBackendException is occured");
}
return Arrays.asList(parents);


}

private List<String> getSHAs(final List<RevCommit> parents) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package com.ericsson.gerrit.plugins.eiffel.handlers;

import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ScheduledExecutorService;

import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.extensions.events.LifecycleListener;
Expand All @@ -32,7 +32,7 @@ public class MessageQueueHandler implements LifecycleListener {

private final WorkQueue workQueue;
private final int poolSize;
private ScheduledThreadPoolExecutor pool;
private ScheduledExecutorService pool;

@Inject
public MessageQueueHandler(final WorkQueue workQueue, final PluginConfigFactory config,
Expand All @@ -54,7 +54,7 @@ public void stop() {
}
}

public ScheduledThreadPoolExecutor getPool() {
public ScheduledExecutorService getPool() {
return this.pool;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,24 @@ public void testFetchingParentsShas() throws Exception {

@Test
public void testFetchingCommitNotFound() throws Exception {
logHelper.removeStdoutAppenders();

logHelper.removeStdoutAppenders();
final CommitsCollection commitsCollection = mock(CommitsCollection.class);
final ProjectsCollection projectsCollection = mock(ProjectsCollection.class);
final ProjectResource projectResource = mock(ProjectResource.class);

when(commitsCollection.parse(any(ProjectResource.class), any(IdString.class))).thenThrow(
ResourceNotFoundException.class);
when(projectsCollection.parse(any(String.class), anyBoolean())).thenReturn(projectResource);

final CommitInformation commitInformation = new CommitInformation(commitsCollection,
projectsCollection);
final List<String> expectedParentsSha = Arrays.asList();
final String commitId = "not found hash";
final String projectName = "projectName";

final List<String> actualParentSha = commitInformation.getParentsSHAs(commitId, projectName);

assertEquals(expectedParentsSha, actualParentSha);
logHelper.verifyLoggerCalledTimes(1);

Expand Down