Skip to content

Commit d722363

Browse files
authored
3.1.0 Testing Fixes (#224)
* Remove buttons to add images to tiling queue * Fix full screen image viewer * Fix missing darkGrey thumbnails * Update travis and tests for java 17 * Move embedded postgres to start with application context for Grails 6 integration tests
1 parent 4eab928 commit d722363

File tree

8 files changed

+64
-69
lines changed

8 files changed

+64
-69
lines changed

Diff for: .travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ dist: focal
22
arch: amd64
33
language: groovy
44
jdk:
5-
- openjdk11
5+
- openjdk17
66
sudo: false
77
branches:
88
only:

Diff for: build.gradle

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ plugins {
22
id "groovy"
33
id "org.grails.grails-gsp"
44
id "org.grails.grails-web"
5-
id "com.github.erdi.webdriver-binaries"
5+
id "com.github.erdi.webdriver-binaries" version "3.2"
66
id "war"
77
id "idea"
88
id "com.bertramlabs.asset-pipeline"
@@ -222,6 +222,15 @@ tasks.withType(Test) {
222222
systemProperty "geb.build.reportsDir", reporting.file("geb/integrationTest")
223223
systemProperty 'webdriver.chrome.driver', "${System.getenv('CHROMEWEBDRIVER')}/chromedriver"
224224
systemProperty 'webdriver.gecko.driver', "${System.getenv('GECKOWEBDRIVER')}/geckodriver"
225+
testLogging {
226+
showStandardStreams = true
227+
exceptionFormat = 'full'
228+
}
229+
doFirst {
230+
jvmArgs = [
231+
'--add-opens', 'java.base/java.lang=ALL-UNNAMED', '--add-opens', 'java.base/java.lang.reflect=ALL-UNNAMED'
232+
]
233+
}
225234
}
226235
tasks.withType(War).configureEach { War war ->
227236
war.dependsOn compileGroovyPages

Diff for: grails-app/conf/spring/resources.groovy

+26
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,36 @@
11
import org.flywaydb.core.Flyway
22
import org.flywaydb.core.api.configuration.ClassicConfiguration
3+
import org.grails.spring.beans.factory.InstanceFactoryBean
34
import org.postgresql.ds.PGSimpleDataSource
45
import org.springframework.beans.factory.config.BeanDefinition
56

67
// Place your Spring DSL code here
78
beans = {
9+
10+
// This is here to support integration testing - the embedded postgres JAR
11+
// does not exist in the built .war file.
12+
// This is a workaround to allow embedded postgres to be started
13+
// when running integration tests as Grails 6 seems to load the application
14+
// context once, no matter how many integration tests are being run.
15+
// Previously we started embedded postgres in the integration test itself but
16+
// this now causes test failures in the current version of Grails.
17+
// TODO could we move to using TestContainers for integration tests?
18+
if (application.config.getProperty('dataSource.embeddedPostgres', Boolean)) {
19+
log.info "Starting embedded postgres"
20+
def pgInstance = io.zonky.test.db.postgres.embedded.EmbeddedPostgres.builder()
21+
.setPort(application.config.getProperty('dataSource.embeddedPort', Integer, 6543))
22+
.setCleanDataDirectory(true)
23+
.start()
24+
embeddedPostgres(InstanceFactoryBean, pgInstance) { bean ->
25+
// bean.destroyMethod = 'close'
26+
}
27+
28+
BeanDefinition dataSourceBeanDef = getBeanDefinition('dataSource')
29+
if (dataSourceBeanDef) {
30+
addDependency(dataSourceBeanDef, 'embeddedPostgres')
31+
}
32+
}
33+
834
if (application.config.getProperty('flyway.enabled', Boolean)) {
935

1036
flywayDataSource(PGSimpleDataSource) { bean ->

Diff for: grails-app/services/au/org/ala/images/ImageStoreService.groovy

+3
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,9 @@ class ImageStoreService {
433433

434434
private String normaliseThumbnailType(String type) {
435435
def typeLowerCase = type.toLowerCase()
436+
if (type.contains('darkGrey')) {
437+
type = type.replace('darkGrey', 'darkGray')
438+
}
436439
if (typeLowerCase.startsWith('thumbnail_')) {
437440
return type.substring('thumbnail_'.length())
438441
} else if (typeLowerCase == 'thumbnail') {

Diff for: grails-app/views/admin/tools.gsp

-30
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,6 @@
2727
Imports image files from the designated incoming server directory ("${grailsApplication.config.getProperty('imageservice.imagestore.inbox')}")
2828
</td>
2929
</tr>
30-
<tr>
31-
<td>
32-
<button id="btnRegenArtifacts" class="btn btn-default">Regenerate Image Artifacts</button>
33-
</td>
34-
<td>
35-
Regenerate all tiles and thumbnails for all images in the repository. Progress can be tracked on the dashboard.
36-
</td>
37-
</tr>
38-
<tr>
39-
<td>
40-
<button id="btnRegenThumbnails" class="btn btn-default">Regenerate Image Thumbnails</button>
41-
</td>
42-
<td>
43-
Regenerate just thumbnails for all images in the repository. Progress can be tracked on the dashboard.
44-
</td>
45-
</tr>
4630
<tr>
4731
<td>
4832
<button id="btnRebuildKeywords" class="btn btn-default">Rebuild Keywords</button>
@@ -152,20 +136,6 @@
152136
window.location = "${createLink(action:'checkForMissingImages')}";
153137
});
154138
155-
$("#btnRegenArtifacts").on('click', function(e) {
156-
e.preventDefault();
157-
$.ajax("${createLink(controller:'webService', action:'scheduleArtifactGeneration')}").done(function() {
158-
window.location = "${createLink(action:'tools')}";
159-
});
160-
});
161-
162-
$("#btnRegenThumbnails").on('click', function(e) {
163-
e.preventDefault();
164-
$.ajax("${createLink(controller:'webService', action:'scheduleThumbnailGeneration')}").done(function() {
165-
window.location = "${createLink(action:'tools')}";
166-
});
167-
});
168-
169139
$("#btnRebuildKeywords").on('click', function(e) {
170140
e.preventDefault();
171141
$.ajax("${createLink(controller:'webService', action:'scheduleKeywordRegeneration')}").done(function() {

Diff for: grails-app/views/image/_coreImageMetadataFragment.gsp

-3
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,6 @@
160160
<button class="btn btn-default" id="btnViewImage" title="View zoomable image"><span class="glyphicon glyphicon-eye-open"> </span></button>
161161
</g:if>
162162
<a class="btn btn-default" href="${createLink(controller:'image', action:'getOriginalFile', id:imageInstance.id, params:[contentDisposition: 'true'])}" title="${g.message(code:'core.image.metadata.download', default: 'Download full image')}" target="imageWindow"><i class="glyphicon glyphicon-download-alt"></i></a>
163-
<g:if test="${isAdminView}">
164-
<button class="btn btn-default" id="btnRegen" title="Regenerate artifacts"><i class="glyphicon glyphicon-refresh"></i></button>
165-
</g:if>
166163
<g:if test="${isAdminView}">
167164
<button class="btn btn-danger" id="btnDeleteImage" title="Delete image (admin)">
168165
<i class="glyphicon glyphicon-remove glyphicon-white"></i>

Diff for: grails-app/views/image/viewer.gsp

+12-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,18 @@
2626
<div id="imageViewerContainer" class="container-fluid">
2727
<div id="imageViewer"> </div>
2828
</div>
29-
<asset:javascript src="head.js"/>
29+
%{-- <asset:javascript src="head.js"/>--}%
30+
<script type="text/javascript"
31+
src="${grailsApplication.config.getProperty('headerAndFooter.baseURL')}/js/jquery.min.js"></script>
32+
<script type="text/javascript"
33+
src="${grailsApplication.config.getProperty('headerAndFooter.baseURL')}/js/jquery-migration.min.js"></script>
34+
<script type="text/javascript"
35+
src="${grailsApplication.config.getProperty('headerAndFooter.baseURL')}/js/autocomplete.min.js"></script>
36+
37+
%{-- <script type="text/javascript" src="${grailsApplication.config.getProperty('headerAndFooter.baseURL')}/js/application.js"--}%
38+
%{-- defer></script>--}%
39+
<script type="text/javascript"
40+
src="${grailsApplication.config.getProperty('headerAndFooter.baseURL')}/js/bootstrap.min.js"></script>
3041
<asset:javascript src="ala/images-client.js"/>
3142
<script>
3243
$(document).ready(function() {

Diff for: src/integration-test/groovy/au/org/ala/images/utils/ImagesIntegrationSpec.groovy

+12-33
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import spock.lang.Shared
2727
import spock.lang.Specification
2828

2929
import java.lang.reflect.Field
30+
import java.lang.reflect.Method
3031
import java.lang.reflect.Modifier
3132

3233
abstract class ImagesIntegrationSpec extends Specification {
@@ -35,12 +36,6 @@ abstract class ImagesIntegrationSpec extends Specification {
3536
AlaAuthClient alaAuthClient
3637
ProfileCreator profileCreator
3738

38-
@Shared @AutoCleanup EmbeddedPostgres embeddedPostgres = EmbeddedPostgres.builder()
39-
.setPort(ImagesIntegrationSpec.config.getProperty('dataSource.embeddedPort', Integer.class, 6543))
40-
.setCleanDataDirectory(true)
41-
.start()
42-
@Shared Flyway flyway = null
43-
4439
static Config getConfig() { // CHANGED extracted from setupSpec so postgresRule can access
4540

4641
List<PropertySourceLoader> propertySourceLoaders = SpringFactoriesLoader.loadFactories(PropertySourceLoader.class, ImagesIntegrationSpec.class.getClassLoader())
@@ -96,7 +91,17 @@ abstract class ImagesIntegrationSpec extends Specification {
9691
*/
9792
static void setNewValue(Field field, Object newValue, obj) throws Exception {
9893
field.setAccessible(true)
99-
Field modifiersField = Field.class.getDeclaredField("modifiers")
94+
Method getDeclaredFields0 = Class.class.getDeclaredMethod("getDeclaredFields0", boolean.class)
95+
getDeclaredFields0.setAccessible(true)
96+
// Field modifiersField = Field.class.getDeclaredField("modifiers")
97+
Field[] fields = (Field[]) getDeclaredFields0.invoke(Field.class, false)
98+
Field modifiersField = null
99+
for (Field each : fields) {
100+
if ("modifiers".equals(each.getName())) {
101+
modifiersField = each;
102+
break;
103+
}
104+
}
100105
modifiersField.setAccessible(true)
101106
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL)
102107
field.set(obj, newValue)
@@ -115,30 +120,4 @@ abstract class ImagesIntegrationSpec extends Specification {
115120
setNewValue(BaseClient.class.getDeclaredField("profileCreator"), profileCreator, alaAuthClient)
116121
}
117122

118-
void setupSpec() {
119-
Config config = getConfig()
120-
// CHANGED added flyway migrate
121-
this.flyway = Flyway.configure()
122-
.cleanDisabled(false)
123-
.table(config.getProperty('flyway.table'))
124-
.baselineOnMigrate(config.getProperty('flyway.baselineOnMigrate', Boolean))
125-
.baselineVersion(config.getProperty('flyway.baselineVersion'))
126-
.outOfOrder(config.getProperty('flyway.outOfOrder', Boolean))
127-
.placeholders([
128-
'imageRoot': config.getProperty('imageservice.imagestore.root'),
129-
'exportRoot': config.getProperty('imageservice.imagestore.exportDir', '/data/image-service/exports'),
130-
'baseUrl': config.getProperty('grails.serverURL', 'https://devt.ala.org.au/image-service')
131-
])
132-
.locations('db/migration')
133-
.dataSource(embeddedPostgres.getPostgresDatabase())
134-
.load()
135-
flyway.clean()
136-
flyway.migrate()
137-
// END CHANGED
138-
}
139-
140-
void cleanupSpec() {
141-
//flyway.clean()
142-
}
143-
144123
}

0 commit comments

Comments
 (0)