-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added XvncSlaveContainer for a more controlled test environment.
- Loading branch information
Showing
3 changed files
with
89 additions
and
5 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
src/main/java/org/jenkinsci/test/acceptance/docker/fixtures/XvncSlaveContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright 2015 Jesse Glick. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
package org.jenkinsci.test.acceptance.docker.fixtures; | ||
|
||
import org.jenkinsci.test.acceptance.docker.DockerContainer; | ||
import org.jenkinsci.test.acceptance.docker.DockerFixture; | ||
import org.jenkinsci.test.acceptance.plugins.credentials.UserPwdCredential; | ||
import org.jenkinsci.test.acceptance.plugins.ssh_credentials.SshCredentialDialog; | ||
import org.jenkinsci.test.acceptance.plugins.ssh_slaves.SshSlaveLauncher; | ||
import org.jenkinsci.test.acceptance.po.DumbSlave; | ||
import org.jenkinsci.test.acceptance.po.Jenkins; | ||
import org.jenkinsci.test.acceptance.po.Slave; | ||
|
||
/** | ||
* A fixture consisting of a Jenkins slave which can run XVNC. | ||
*/ | ||
@DockerFixture(id="xvnc-slave", ports=22) | ||
public class XvncSlaveContainer extends DockerContainer { | ||
|
||
/** | ||
* Attaches the slave to Jenkins. | ||
* @param j the server | ||
* @return return a configured slave; call {@link Slave#save} after any other customizations to complete; use {@link Slave#waitUntilOnline} if desired | ||
*/ | ||
public Slave connect(Jenkins j) { | ||
// Some code from SshSlaveController could be applicable here, but looks too tricky to reuse. | ||
DumbSlave s = j.slaves.create(DumbSlave.class); | ||
SshSlaveLauncher launcher = s.setLauncher(SshSlaveLauncher.class); | ||
launcher.host.set(ipBound(22)); | ||
launcher.port(port(22)); | ||
SshCredentialDialog dialog = launcher.addCredential(); | ||
UserPwdCredential sc = dialog.select(UserPwdCredential.class); | ||
sc.username.set("jenkins"); | ||
sc.password.set("jenkins"); | ||
dialog.add(); | ||
s.remoteFS.set("/home/jenkins"); | ||
s.setExecutors(1); | ||
return s; | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
...ain/resources/org/jenkinsci/test/acceptance/docker/fixtures/XvncSlaveContainer/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM evarga/jenkins-slave | ||
RUN apt-get install -y vnc4server imagemagick | ||
|
||
# So it is owned by root and has the permissions vncserver seems to require: | ||
RUN mkdir /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix/ | ||
|
||
# TODO seems this can be picked up from the host, which is unwanted: | ||
ENV XAUTHORITY /home/jenkins/.Xauthority | ||
|
||
USER jenkins | ||
RUN mkdir /home/jenkins/.vnc && (echo jenkins; echo jenkins) | vncpasswd /home/jenkins/.vnc/passwd | ||
# Default content includes x-window-manager, which is not installed, plus other stuff we do not need (vncconfig, x-terminal-emulator, etc.): | ||
RUN touch /home/jenkins/.vnc/xstartup && chmod a+x /home/jenkins/.vnc/xstartup | ||
USER root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters