Skip to content

Commit

Permalink
2.3.14 Release - Bugfixes and and test improvements (#35)
Browse files Browse the repository at this point in the history
* wip

* Update docs

* Do not add x86_64 archType to image tag

* update groovy

* Use correct groupid for new groovy version

* WIP

* Basic JSM and Bitbucket setup.groovy
 * Updated to use devstack 2.3.13 and latest SR

Basic JSM Setup.groovy
 * Updated to use devstack 2.3.13

JsmContainer.groovy
 * Added new parameter/field jvmSupportRecommendedArgs
 * Reworked some of enableJvmDebug to work with jvmSupportRecommendedArgs

JsmAndBitbucketH2Deployment.groovy
 * Now sets JSM to allow App upload using enableAppUpload()

ExamplesTest.groovy
 * WIP, needs to be tested once this version of DevStack has been built

pom.xml
 * Bumped docker-client 2024-02-10T12-30-00 -> 2024-03-16T11-35-00

* Various tweaks and bugfixes related to running the tests

---------

Co-authored-by: Joni Lahtinen <[email protected]>
  • Loading branch information
farthinder and jlahtinen authored Apr 3, 2024
1 parent 46bc95b commit c73f881
Show file tree
Hide file tree
Showing 14 changed files with 292 additions and 43 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,9 @@ mvn dependency:get -Dartifact=com.eficode:devstack-standalone:2.3.9-SNAPSHOT -Dr
# Breaking Changes

* 2.3.9
* From now on two artifacts will be generated, devstack and devstack-standalone and the classifier standalone is deprecated
* From now on two artifacts will be generated, devstack and devstack-standalone and the classifier standalone is deprecated

# Requirements
The devstack packages are mainly built for JAVA 17 but should work with java 8+ and should work with groovy
* 3.x >= 3.0.17
* 4.x >= 4.0.11
2 changes: 1 addition & 1 deletion examples/Basic JSM Setup.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@GrabResolver(name = 'github', root = 'https://github.com/eficode/DevStack/raw/packages/repository/')
@Grab(group = 'com.eficode', module = 'devstack', version = '2.2.0-SNAPSHOT-groovy-3.0.14', classifier = "standalone")
@Grab(group = 'com.eficode', module = 'devstack-standalone', version = '2.3.13')
@Grab(group='org.slf4j', module='slf4j-simple', version='1.7.36', scope='test')
@GrabConfig(systemClassLoader=true, initContextClassLoader=true)

Expand Down
4 changes: 2 additions & 2 deletions examples/Basic JSM and Bitbucket setup.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@GrabResolver(name = 'github', root = 'https://github.com/eficode/DevStack/raw/packages/repository/')
@Grab(group = 'com.eficode', module = 'devstack', version = '2.2.0-SNAPSHOT-groovy-3.0.14', classifier = "standalone")
@Grab(group = 'com.eficode', module = "devstack-standalone", version = '2.3.14')
@Grab(group='org.slf4j', module='slf4j-simple', version='1.7.36', scope='test')
@GrabConfig(systemClassLoader=true, initContextClassLoader=true)

Expand Down Expand Up @@ -37,7 +37,7 @@ jsmAndBb.jsmContainer.setJvmMaxRam(4096)

//Install JIRA App.
//ScriptRunner is needed for setting up application link between JIRA and Bitbucket
jsmAndBb.jiraAppsToInstall = ["https://marketplace.atlassian.com/download/apps/6820/version/1005740":scriptRunnerLicense]
jsmAndBb.jiraAppsToInstall = ["https://marketplace.atlassian.com/download/apps/6820/version/1007940":scriptRunnerLicense]

//Stop and remove if already existing
jsmAndBb.stopAndRemoveDeployment()
Expand Down
40 changes: 18 additions & 22 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,47 @@

<groupId>com.eficode</groupId>
<artifactId>devstack</artifactId>
<version>2.3.13</version>
<version>2.3.14</version>
<packaging>jar</packaging>

<name>DevStack</name>

<description>A series of scripts for setting up common developer application suites</description>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<groovy.major.version>3.0</groovy.major.version>
<groovy.version>[3.0,4.0)</groovy.version>
<spock-core.version>2.4-M1-groovy-${groovy.major.version}</spock-core.version>
<java.version>11</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<groovy.major.version>4.0</groovy.major.version>
<groovy.groupId>org.apache.groovy</groovy.groupId>
<groovy.version>4.0.18</groovy.version>
<spock-core.version>2.3-groovy-${groovy.major.version}</spock-core.version>
<jiraShortcuts.version>2.0.3-SNAPSHOT-groovy-3.0</jiraShortcuts.version>
<bitbucketinstancemanager.version>0.0.3-SNAPSHOT-groovy-3.0</bitbucketinstancemanager.version>
<jirainstancemanager.version>2.1.4</jirainstancemanager.version>
</properties>


<dependencies>



<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<groupId>${groovy.groupId}</groupId>
<artifactId>groovy</artifactId>
<version>${groovy.version}</version>
<scope>provided</scope>
<type>pom</type>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml -->
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>2.15.3</version>
</dependency>

<dependency>
<groupId>org.codehaus.groovy</groupId>
<groupId>${groovy.groupId}</groupId>
<artifactId>groovy-json</artifactId>
<version>${groovy.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-ant -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<groupId>${groovy.groupId}</groupId>
<artifactId>groovy-ant</artifactId>
<version>${groovy.version}</version>
</dependency>
Expand Down Expand Up @@ -84,7 +81,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-compress -->
<dependency>
Expand All @@ -102,15 +99,15 @@
<dependency>
<groupId>com.eficode.atlassian</groupId>
<artifactId>jirainstancemanager</artifactId>
<version>2.1.1</version>
<version>${jirainstancemanager.version}</version>
</dependency>


<!-- https://mvnrepository.com/artifact/de.gesellix/docker-client -->
<dependency>
<groupId>de.gesellix</groupId>
<artifactId>docker-client</artifactId>
<version>2023-12-01T19-40-00</version>
<version>2024-03-16T11-35-00</version>
</dependency>


Expand Down Expand Up @@ -207,10 +204,9 @@
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<groupId>${groovy.groupId}</groupId>
<artifactId>groovy</artifactId>
<version>${groovy.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<configuration>
Expand All @@ -222,4 +218,4 @@
</plugins>
</build>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ trait Container {
* @return
*/
String getShortId() {
return getContainerId().substring(0,12)
return getContainerId()?.substring(0,12)
}

String getId() {
Expand Down Expand Up @@ -838,8 +838,7 @@ trait Container {
*/
static ArrayList<String> runCmdAndRm(String cmd, long timeoutMs, ArrayList<Map> mounts = [], String dockerHost = "", String dockerCertPath = "") {


return runCmdAndRm(["/bin/sh", "-c", cmd], timeoutMs, mounts, dockerHost, dockerCertPath)
return this.runCmdAndRm(["/bin/sh", "-c", cmd], timeoutMs, mounts, dockerHost, dockerCertPath)
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class HarborManagerContainer extends DoodContainer {
yamlFile.write( objectMapper.writeValueAsString(modifiedYml))

assert copyFileToContainer(yamlFile.absolutePath, installPath + "/harbor/"): "Error copying updated YAML file to container"
tmpDir.deleteDir()
tmpDir.toFile().deleteDir()

log.info("\tFinished customizing docker-compose file")

Expand All @@ -190,8 +190,9 @@ class HarborManagerContainer extends DoodContainer {
boolean modifyInstallYml() {


Path tmpDir = Files.createTempDirectory("harbor-conf")
String tmpDirPath = tmpDir.toFile().absolutePath
File tmpDir = File.createTempDir("harbor-conf")

String tmpDirPath = tmpDir.absolutePath


ArrayList<File> files = copyFilesFromContainer("${installPath}/harbor/harbor.yml.tmpl", tmpDirPath + "/")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class JsmContainer implements Container {
long jvmMaxRam = 6000

private String debugPort //Contains the port used for JVM debug
ArrayList<String> jvmSupportRecommendedArgs = [] //Used for setting application properties: https://confluence.atlassian.com/adminjiraserver/setting-properties-and-options-on-startup-938847831.html

JsmContainer(String dockerHost = "", String dockerCertPath = "") {
if (dockerHost && dockerCertPath) {
Expand All @@ -36,8 +37,18 @@ class JsmContainer implements Container {
*/
void enableJvmDebug(String portNr = "5005") {

assert !created: "Error, cant enable JVM Debug for a container that has already been crated"
assert !created: "Error, cant enable JVM Debug for a container that has already been created"
debugPort = portNr
jvmSupportRecommendedArgs += ["-Xdebug", "-Xrunjdwp:transport=dt_socket,address=*:${debugPort},server=y,suspend=n"]
}

/**
* Enables upload of Apps so that not only Marketplace apps can be installed
* See: https://jira.atlassian.com/browse/JRASERVER-77129
*/
void enableAppUpload() {
assert !created: "Error, cant enable App Upload for a container that has already been created"
jvmSupportRecommendedArgs += ["-Dupm.plugin.upload.enabled=true"]
}

/**
Expand Down Expand Up @@ -84,7 +95,6 @@ class JsmContainer implements Container {

c.image = image
c.hostname = containerName
c.env = ["JVM_MAXIMUM_MEMORY=" + jvmMaxRam + "m", "JVM_MINIMUM_MEMORY=" + ((jvmMaxRam / 2) as String) + "m", "ATL_TOMCAT_PORT=" + containerMainPort] + customEnvVar


c.exposedPorts = [(containerMainPort + "/tcp"): [:]]
Expand All @@ -94,15 +104,19 @@ class JsmContainer implements Container {
if (debugPort) {
h.portBindings.put((debugPort + "/tcp"), [new PortBinding("0.0.0.0", (debugPort))])
c.exposedPorts.put((debugPort + "/tcp"), [:])
c.env.add("JVM_SUPPORT_RECOMMENDED_ARGS=-Xdebug -Xrunjdwp:transport=dt_socket,address=*:${debugPort},server=y,suspend=n".toString())
}


h.mounts = this.preparedMounts
}

c.env = ["JVM_MAXIMUM_MEMORY=" + jvmMaxRam + "m", "JVM_MINIMUM_MEMORY=" + ((jvmMaxRam / 2) as String) + "m", "ATL_TOMCAT_PORT=" + containerMainPort] + customEnvVar


}

if (jvmSupportRecommendedArgs) {
containerCreateRequest.env.add("JVM_SUPPORT_RECOMMENDED_ARGS=" + jvmSupportRecommendedArgs.join(" "))
}

return containerCreateRequest
Expand Down Expand Up @@ -136,11 +150,16 @@ class JsmContainer implements Container {
startContainer()
}


return success

}

Volume getSnapshotVolume(String snapshotName = "") {

if (!created) {
return null
}
snapshotName = snapshotName ?: shortId + "-clone"

ArrayList<Volume> volumes = dockerClient.getVolumesWithName(snapshotName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class JenkinsAndHarborDeployment implements Deployment {

if (jenkinsFuture.done) {
log.info("\tJenkins deployment finished successfully:" + jenkinsFuture.get())
log.info("\t\tJenkins URL:" + jenkinsDeployment.baseUrl)
log.info("\t\tJenkins URL:" + getJenkinsDeployment().baseUrl)
log.info("\t\tJenkins Admin PW:" + jenkinsContainer.initialAdminPassword)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class JsmAndBitbucketH2Deployment implements Deployment {
assert bitbucketLicense: "Error no Bitbucket License has been setup"

jsmH2Deployment.setJiraLicense(jiraLicense)
jsmH2Deployment.jsmContainer.enableAppUpload()
bitbucketH2Deployment.setBitbucketLicence(bitbucketLicense)

jsmH2Deployment.deploymentNetworkName = this.containerNetworkName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ class JsmH2Deployment implements Deployment{
if (useSnapshotIfAvailable && jsmContainer.created && jsmContainer.getSnapshotVolume()) {
log.info("\tSnapshot is available, will restore that instead of setting up new JSM")
assert jsmContainer.restoreJiraHomeSnapshot(): "Error resting snapshot for " + jsmContainer.shortId
log.info("\t\tSnapshot restored, waiting for jira to become responsive")
jiraRest.waitForJiraToBeResponsive(120)
log.info("\t" * 2 + "Finished restoring JSM snapshot")
return true
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.eficode.atlassian.JiraShortcuts.test.resources.jiraLocalScripts
package com.eficode.devstack.deployment.jira.scripts

/**
* A script executed in JIRA by Scriptrunner
Expand Down
Loading

0 comments on commit c73f881

Please sign in to comment.