Skip to content

Commit b793cd0

Browse files
committed
Add ssh command to ping the plugin
Fixes: QTBI-1544 Change-Id: Ie9ad33b5873a133665dda21ece3f80d0e552b5da Reviewed-by: Frederik Gladhorn <[email protected]>
1 parent 5a99d43 commit b793cd0

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// Copyright (C) 2018 The Qt Company
3+
//
4+
5+
package com.googlesource.gerrit.plugins.qtcodereview;
6+
7+
import com.google.gerrit.sshd.SshCommand;
8+
import com.google.gerrit.sshd.CommandMetaData;
9+
10+
@CommandMetaData(name="ping", description="Ping the SSH Command interface")
11+
class QtCommandPing extends SshCommand {
12+
@Override
13+
protected void run() {
14+
stdout.print(String.format("Pong\n username=%s\n name=%s\n email=%s\n",
15+
user.asIdentifiedUser().getUserName(),
16+
user.asIdentifiedUser().getName(),
17+
user.asIdentifiedUser().getNameEmail()));
18+
}
19+
}
20+

src/main/java/com/googlesource/gerrit/plugins/qtcodereview/QtSshModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ class QtSshModule extends PluginCommandModule {
1010

1111
@Override
1212
protected void configureCommands() {
13-
13+
command(QtCommandPing.class);
1414
}
1515
}

src/test/java/com/googlesource/gerrit/plugins/qtcodereview/QtCodeReviewIT.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import com.google.gerrit.acceptance.PushOneCommit;
99
import com.google.gerrit.acceptance.RestResponse;
1010
import com.google.gerrit.acceptance.TestPlugin;
11-
11+
import com.google.gerrit.acceptance.UseSsh;
1212
import com.google.gerrit.reviewdb.client.Change;
1313

1414
import org.eclipse.jgit.revwalk.RevCommit;
@@ -22,15 +22,17 @@
2222
sshModule = "com.googlesource.gerrit.plugins.qtcodereview.QtSshModule"
2323
)
2424

25+
@UseSsh
2526
public class QtCodeReviewIT extends LightweightPluginDaemonTest {
2627

2728
protected static final String R_HEADS = "refs/heads/";
2829
protected static final String R_STAGING = "refs/staging/";
2930
protected static final String R_PUSH = "refs/for/";
3031

3132
@Test
32-
public void dummyTest() {
33-
33+
public void pingSSHTest() throws Exception {
34+
assertThat(adminSshSession.exec("gerrit-plugin-qt-workflow ping")).contains("Pong");
35+
assertThat(adminSshSession.getError()).isNull();
3436
}
3537

3638

0 commit comments

Comments
 (0)