Skip to content
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

RFC: Proposal to replace fixtures with docker-compose #35651

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 3 additions & 2 deletions x-pack/qa/third-party/active-directory/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ apply plugin: 'elasticsearch.standalone-test'
dependencies {
testCompile project(xpackModule('security'))
testCompile project(path: xpackModule('security'), configuration: 'testArtifacts')
testRuntime project(":x-pack:test:smb-fixture")
}

// add test resources from security, so tests can use example certs
Expand Down Expand Up @@ -34,13 +35,13 @@ test {
thirdPartyAudit.enabled = false

task smbFixture {
dependsOn "vagrantCheckVersion", "virtualboxCheckVersion", smbFixtureProject.up
dependsOn "vagrantCheckVersion", "virtualboxCheckVersion" //smbFixtureProject.up
}

if (project.rootProject.vagrantSupported) {
if (project.hasProperty('useExternalAD') == false) {
test.dependsOn smbFixture
test.finalizedBy smbFixtureProject.halt
test.finalizedBy smbFixtureProject.composeDown
}
} else {
test.enabled = false
Expand Down
11 changes: 11 additions & 0 deletions x-pack/test/smb-fixture/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM ubuntu:16.04
ADD . /fixture
RUN chmod +x /fixture/src/main/resources/provision/installsmb.sh

EXPOSE 389
EXPOSE 636
EXPOSE 3268
EXPOSE 3269

CMD /fixture/src/main/resources/provision/installsmb.sh

20 changes: 0 additions & 20 deletions x-pack/test/smb-fixture/Vagrantfile

This file was deleted.

52 changes: 23 additions & 29 deletions x-pack/test/smb-fixture/build.gradle
Original file line number Diff line number Diff line change
@@ -1,40 +1,34 @@
apply plugin: 'elasticsearch.build'

Map<String, String> vagrantEnvVars = [
'VAGRANT_CWD' : "${project.projectDir.absolutePath}",
'VAGRANT_VAGRANTFILE' : 'Vagrantfile',
'VAGRANT_PROJECT_DIR' : "${project.projectDir.absolutePath}"
]

String box = "test.ad.elastic.local"

task update(type: org.elasticsearch.gradle.vagrant.VagrantCommandTask) {
command 'box'
subcommand 'update'
boxName box
environmentVars vagrantEnvVars
buildscript {
repositories {
jcenter()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think jcenter is already in our build script.

}
dependencies {
classpath "com.avast.gradle:docker-compose-gradle-plugin:0.4.5"
}
}

task up(type: org.elasticsearch.gradle.vagrant.VagrantCommandTask) {
command 'up'
args '--provision', '--provider', 'virtualbox'
boxName box
environmentVars vagrantEnvVars
dependsOn update
apply plugin: "base"
apply plugin: 'docker-compose'

dockerCompose {
useComposeFiles = ['docker-compose.yml']
removeContainers = true // no persistent data!
// MacOS does not allow writing to /usr/bin, but Linux installs it there on some distributions
executable = file('/usr/local/bin/docker-compose').exists() ? '/usr/local/bin/docker-compose' : '/usr/bin/docker-compose'
}

task halt(type: org.elasticsearch.gradle.vagrant.VagrantCommandTask) {
command 'halt'
boxName box
environmentVars vagrantEnvVars
/**
* Allows for other subprojects to depend on the project level and not care about the details
* of composeUp
*/
jar {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems funky. I think I'd prefer to depend on the task.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't fully convinced either, just wanted to bring it up. Let's do the task it's more straight forward.

dependsOn 'composeUp'
}

task destroy(type: org.elasticsearch.gradle.vagrant.VagrantCommandTask) {
command 'destroy'
args '-f'
boxName box
environmentVars vagrantEnvVars
dependsOn halt
clean {
dependsOn 'composeDown'
}

thirdPartyAudit.enabled = false
Expand Down
11 changes: 11 additions & 0 deletions x-pack/test/smb-fixture/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '3'
services:
fixture:
build:
context: .
dockerfile: Dockerfile
ports:
- "61389:389"
- "61636:636"
- "63268:3268"
- "63269:3269"
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if [ -f $MARKER_FILE ]; then
exit 0;
fi

VDIR=/vagrant
VDIR=/fixture
RESOURCES=$VDIR/src/main/resources
CERTS_DIR=$RESOURCES/certs
SSL_DIR=/var/lib/samba/private/tls
Expand All @@ -29,6 +29,7 @@ mkdir -p $SSL_DIR
cp $CERTS_DIR/*.pem $SSL_DIR
chmod 600 $SSL_DIR/key.pem

mkdir -p /etc/ssl/certs/
cat $SSL_DIR/ca.pem >> /etc/ssl/certs/ca-certificates.crt

mv /etc/samba/smb.conf /etc/samba/smb.conf.orig
Expand Down Expand Up @@ -93,3 +94,6 @@ EOL
ldapmodify -D [email protected] -w Passw0rd -H ldaps://127.0.0.1:636 -f /tmp/entrymods -v

touch $MARKER_FILE

# keep the container alive
while true ; do sleep 3600 ; done