-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increase default test heap from 512m to 2g (#1813)
Increase default test heap from 512m to 2g unless otherwise specified
- Loading branch information
1 parent
487ba99
commit 0e72722
Showing
5 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
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,5 @@ | ||
type: improvement | ||
improvement: | ||
description: Increase default test heap from 512m to 2g unless otherwise specified | ||
links: | ||
- https://github.com/palantir/gradle-baseline/pull/1813 |
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
39 changes: 39 additions & 0 deletions
39
gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineTestHeap.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,39 @@ | ||
/* | ||
* (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.palantir.baseline.plugins; | ||
|
||
import org.gradle.api.Plugin; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.tasks.testing.Test; | ||
|
||
/** | ||
* Increases the default {@code test} task heap from {@code 512m} to {@code 2g}. | ||
*/ | ||
public final class BaselineTestHeap implements Plugin<Project> { | ||
|
||
private static final String TEST_HEAP = "2g"; | ||
|
||
@Override | ||
public void apply(Project project) { | ||
project.getTasks().withType(Test.class).configureEach(testTask -> { | ||
String currentValue = testTask.getMaxHeapSize(); | ||
if (currentValue == null) { | ||
testTask.setMaxHeapSize(TEST_HEAP); | ||
} | ||
}); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ava/src/main/resources/META-INF/gradle-plugins/com.palantir.baseline-test-heap.properties
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 @@ | ||
implementation-class=com.palantir.baseline.plugins.BaselineTestHeap |
63 changes: 63 additions & 0 deletions
63
gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineTestHeapTest.groovy
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 @@ | ||
/* | ||
* (c) Copyright 2018 Palantir Technologies Inc. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.palantir.baseline | ||
|
||
|
||
import org.gradle.api.tasks.testing.Test | ||
import com.palantir.baseline.plugins.BaselineTestHeap; | ||
import org.gradle.testfixtures.ProjectBuilder | ||
import spock.lang.Specification | ||
|
||
class BaselineTestHeapTest extends Specification { | ||
|
||
def testDefaultHeapIsIncreased() { | ||
when: | ||
def project = ProjectBuilder.builder().build() | ||
project.buildscript { | ||
repositories { | ||
mavenCentral() | ||
} | ||
} | ||
project.plugins.apply 'java' | ||
project.plugins.apply BaselineTestHeap | ||
project.evaluate() | ||
|
||
then: | ||
Test testTask = project.tasks.getByName('test') | ||
testTask.getMaxHeapSize() == '2g' | ||
} | ||
|
||
def testOverridesAreNotImpacted() { | ||
when: | ||
def project = ProjectBuilder.builder().build() | ||
project.buildscript { | ||
repositories { | ||
mavenCentral() | ||
} | ||
} | ||
project.plugins.apply 'java' | ||
project.test { | ||
maxHeapSize = '1024m' | ||
} | ||
project.plugins.apply BaselineTestHeap | ||
project.evaluate() | ||
|
||
then: | ||
Test testTask = project.tasks.getByName('test') | ||
testTask.getMaxHeapSize() == '1024m' | ||
} | ||
} |