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

Transaction synchronization #212

Merged
merged 72 commits into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
5c9d2f4
Fix #175 - Queue per-transaction changes for write on afterCommit()
longwa Feb 28, 2019
844d535
Fix compatibility with Gradle 4/5
longwa Feb 28, 2019
eb53bee
backport #184 into pr 183
robertoschwald May 27, 2019
46a11a4
Made modification to have plugin create an AuditListener instance for…
Jun 27, 2019
c455ee1
Cleanup
robertoschwald Oct 4, 2019
d9e7c28
added issue template
robertoschwald Mar 1, 2019
094beb2
Update README.md
robertoschwald Jun 28, 2019
fb9bfb5
Update README.md
robertoschwald Jun 28, 2019
d6b742a
add configurable option to use getOriginalValue() instead of getPersi…
jnunderwood Aug 5, 2019
8005f55
update gitignore
jnunderwood Aug 21, 2019
5d89fc5
add debug statements to createAuditLogDomainInstance(), renamed metho…
robertoschwald Oct 4, 2019
27c0e1c
add debugging statements
robertoschwald Oct 4, 2019
e844cf8
Update configuration.adoc
robertoschwald Sep 2, 2019
78cc9fa
Update changelog.adoc
robertoschwald Oct 4, 2019
a4afddd
Use correct (old) plugin syntax in build.gradle
felixscheinost Sep 18, 2019
7c1adc9
Use project.file instead of $rootDir in build.gradle
felixscheinost Sep 18, 2019
fa1c0a0
Handle composite ID values (closes #194) Backport
felixscheinost Sep 19, 2019
a4ff432
Specify travis distro explicitly for JDK 8
felixscheinost Sep 19, 2019
2f101e6
Update changelog.adoc
robertoschwald Oct 4, 2019
8227848
show logs during testing
robertoschwald Oct 4, 2019
c542d3a
update docs
robertoschwald Oct 4, 2019
ff1c7dd
start rework AuditDeleteSpec with isolated Transactions
robertoschwald Oct 4, 2019
5408617
cleanup loggers
robertoschwald Oct 6, 2019
5fe7923
gitignore
robertoschwald Oct 6, 2019
599b88d
fixed TedtUtils as PersistentCollections are not logged anymore
robertoschwald Oct 6, 2019
84673ad
gitignore
robertoschwald Oct 6, 2019
5739ade
info log
robertoschwald Oct 6, 2019
9d0fdfa
started rework of AuditDeleteSpec. 2nd test fails for unknown reason.
robertoschwald Oct 6, 2019
8d6277f
Merge branch 'grails4-upgrade' into feature/4.0.0_wip
longwa May 14, 2020
246bee1
Fix issue with Audit Log Transaction Synchronization
longwa May 14, 2020
76f6e37
Start fixing issues with tests (mostly transactional boundaries)
longwa May 14, 2020
8b4e809
Support allow_update_outside_transaction
felixscheinost Dec 17, 2020
29160d7
Revert "Start fixing issues with tests (mostly transactional boundari…
felixscheinost Dec 17, 2020
3e0fa87
Change auditDomainClassName using withConfig
felixscheinost Dec 17, 2020
2013c26
Clear ThreadLocal when transaction finishes
felixscheinost Dec 17, 2020
2dff9b7
Fix No Transaction + Second Datasource
felixscheinost Dec 17, 2020
3100ed7
Fixes AuditDeleteSpec
felixscheinost Dec 18, 2020
b6d3b0d
Propagation.NESTED has no effect for withNew
felixscheinost Dec 18, 2020
c399cdb
Fixes AuditTruncateSpec
felixscheinost Dec 18, 2020
6ad5261
Prefer setup/cleanup
felixscheinost Dec 18, 2020
230cf43
Fixes AuditUpdateCollectionSpec
felixscheinost Dec 18, 2020
a86c230
Fixes AuditUpdateSpec
felixscheinost Dec 18, 2020
021636f
Sets up Github Actions
felixscheinost Dec 18, 2020
f54652a
Merge branch 'master' into feature/4.0.0_wip
felixscheinost Dec 18, 2020
7bef59d
Update Github Actions
felixscheinost Dec 18, 2020
de9427c
Fix after merging master
felixscheinost Dec 18, 2020
5983596
Github Actions upload-artifact
felixscheinost Dec 18, 2020
f043bfc
CI Always include test reports
felixscheinost Dec 18, 2020
d2c9085
Cleanup before
felixscheinost Jan 11, 2021
b40e5f3
Remove @Rollback
felixscheinost Jan 18, 2021
c78b806
Failing test wontfix
felixscheinost Jan 18, 2021
a7e3f25
Improve AuditLogQueueManager
felixscheinost Jan 18, 2021
52e3622
Fix old development import
felixscheinost Jan 19, 2021
76eabbd
Pass through event to addToQueue
felixscheinost Jan 19, 2021
4d8b084
Additional specs
felixscheinost Jan 19, 2021
02d64c2
Transaction Synchronization using Hibernate API
felixscheinost Jan 19, 2021
8724437
Github Actions test using Java 8 and 11
felixscheinost Jan 19, 2021
466813c
Fix spec sporadic failure
felixscheinost Jan 19, 2021
a892884
Version 5.0.0-SNAPSHOT
felixscheinost Jan 19, 2021
c67a150
Merge branch 'master' into feature/4.0.0_wip
felixscheinost Jan 19, 2021
e0cc793
Move cleanup to setup
felixscheinost Jan 19, 2021
221d76d
Move transactional tests into own file
felixscheinost Jan 19, 2021
f2a138c
Fix grammar
felixscheinost Jan 19, 2021
535177f
Fix merge
felixscheinost Jan 19, 2021
c18415e
Refactor: if (!…) return
felixscheinost Jan 19, 2021
7436ca7
Fix after merge
felixscheinost Jan 19, 2021
6442211
Begin removing Travis
felixscheinost Jan 19, 2021
9e58091
Update plugin/src/main/groovy/grails/plugins/orm/auditable/AuditLogQu…
robertoschwald Jan 23, 2021
be08f3f
Update plugin/src/main/groovy/grails/plugins/orm/auditable/AuditLogQu…
robertoschwald Jan 23, 2021
1180240
Update plugin/src/main/groovy/grails/plugins/orm/auditable/AuditLogQu…
robertoschwald Jan 23, 2021
9a3f206
Update plugin/src/main/groovy/grails/plugins/orm/auditable/AuditLogQu…
robertoschwald Jan 23, 2021
77ec735
Merge branch 'master' into feature/4.0.0_wip
robertoschwald May 22, 2021
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
37 changes: 37 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "CI"
on:
pull_request:
jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
java: [8, 11]
steps:
- uses: actions/checkout@v2
- run: cd $GITHUB_WORKSPACE

- uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
java-package: jdk
architecture: x64

- run: ./gradlew check
- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: testreport-audit-test-${{ matrix.java }}
path: examples/audit-test/build/reports/tests
- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: testreport-audit-test-allow-update-outside-transaction-${{ matrix.java }}
path: examples/audit-test-allow-update-outside-transaction/build/reports/tests

- run: ./gradlew :examples:audit-test:check -Daudit-test.AuditTrail.datasource=DEFAULT
- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: testreport-audit-test-single-datasource-${{ matrix.java }}
path: examples/audit-test/build/reports/tests
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ classes
/.asscache
/audit-test/.asscache
.vscode/settings.json
/plugin/out
/examples/audit-test/out
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Special thanks to all the contributors (in alphabetical order):


## Continuous Integration Server
[![Build Status](https://travis-ci.org/robertoschwald/grails-audit-logging-plugin.svg?branch=master)](https://travis-ci.org/robertoschwald/grails-audit-logging-plugin)
[![Build Status](https://github.com/robertoschwald/grails-audit-logging-plugin/workflows/CI/badge.svg)](https://github.com/robertoschwald/grails-audit-logging-plugin/actions)

## Bintray Repository
<a href='https://bintray.com/robertoschwald/plugins/audit-logging/view?source=watch' alt='Get automatic notifications about new "audit-logging" versions'><img src='https://www.bintray.com/docs/images/bintray_badge_color.png'></a>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This is a sample test project for audit-logging.

You can run the tests by

./gradlew check

In comparison to `examples/audit-test` this application tests support for applications that are using `hibernate.allow_update_outside_transaction = true` and are not using a second datasource for `AuditTrail`.

103 changes: 103 additions & 0 deletions examples/audit-test-allow-update-outside-transaction/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
buildscript {
ext {
grailsVersion = project.grailsVersion
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:3.0.7"
}
}

version file("$rootDir/version.txt").text.trim()
group "audit.test"

apply plugin: "war"
apply plugin: "asset-pipeline"
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: "org.grails.grails-web"
apply plugin: "org.grails.grails-gsp"

ext {
grailsVersion = project.grailsVersion
gradleWrapperVersion = project.gradleWrapperVersion
}

assets {
minifyJs = true
minifyCss = true
}

repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}

grails {
plugins {
compile project(":audit-logging")
}
}

configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}

dependencies {
developmentOnly("org.springframework.boot:spring-boot-devtools")
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-web-boot"
compile "org.grails:grails-logging"
compile "org.grails:grails-plugin-rest"
compile "org.grails:grails-plugin-databinding"
compile "org.grails:grails-plugin-i18n"
compile "org.grails:grails-plugin-services"
compile "org.grails:grails-plugin-url-mappings"
compile "org.grails:grails-plugin-interceptors"
compile "org.grails.plugins:cache"
compile "org.grails.plugins:async"
compile "org.grails.plugins:scaffolding"
compile "org.grails.plugins:events"
compile "org.grails.plugins:hibernate5"
compile "org.hibernate:hibernate-core:5.4.0.Final"
compile "org.hibernate:hibernate-ehcache:5.4.0.Final"
compile "org.grails.plugins:gsp"
console "org.grails:grails-console"
profile "org.grails.profiles:web"
runtime "org.glassfish.web:el-impl:2.1.2-b03"
runtime "com.h2database:h2"
runtime "org.apache.tomcat:tomcat-jdbc"
runtime "javax.xml.bind:jaxb-api:2.3.0"
runtime "com.bertramlabs.plugins:asset-pipeline-grails:3.0.7"
testCompile "org.grails:grails-gorm-testing-support"
testCompile "org.mockito:mockito-core"
testCompile "org.grails:grails-web-testing-support"
testCompile "org.grails.plugins:geb"
testCompile "org.seleniumhq.selenium:selenium-remote-driver:3.14.0"
testCompile "org.seleniumhq.selenium:selenium-api:3.14.0"
testCompile "org.seleniumhq.selenium:selenium-support:3.14.0"
testRuntime "org.seleniumhq.selenium:selenium-chrome-driver:3.14.0"
testRuntime "org.seleniumhq.selenium:selenium-firefox-driver:3.14.0"
}

task wrapper(type: Wrapper) {
gradleVersion = gradleWrapperVersion
}

test {
testLogging {
showStandardStreams = true
exceptionFormat = 'full'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
grails {
plugin {
auditLog {
verbose = true
excluded = ['version', 'lastUpdated', 'lastUpdatedBy']
logFullClassName = true
failOnError = true
mask = ['ssn']
logIds = true
defaultActor = 'SYS'
replacementPatterns = ["a.b": ""]
truncateLength = 1000000
}
}
}

// Added by the Audit-Logging plugin:
grails.plugin.auditLog.auditDomainClassName = 'test.AuditTrail'

hibernate_second {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---
grails:
profile: web
codegen:
defaultPackage: audit.test
info:
app:
name: '@info.app.name@'
version: '@info.app.version@'
grailsVersion: '@info.app.grailsVersion@'
spring:
groovy:
template:
check-template-location: false

---
grails:
mime:
disable:
accept:
header:
userAgents:
- Gecko
- WebKit
- Presto
- Trident
types:
all: '*/*'
atom: application/atom+xml
css: text/css
csv: text/csv
form: application/x-www-form-urlencoded
html:
- text/html
- application/xhtml+xml
js: text/javascript
json:
- application/json
- text/json
multipartForm: multipart/form-data
pdf: application/pdf
rss: application/rss+xml
text: text/plain
hal:
- application/hal+json
- application/hal+xml
xml:
- text/xml
- application/xml
urlmapping:
cache:
maxsize: 1000
controllers:
defaultScope: singleton
converters:
encoding: UTF-8
views:
default:
codec: html
gsp:
encoding: UTF-8
htmlcodec: xml
codecs:
expression: html
scriptlets: html
taglib: none
staticparts: none
dataSource:
pooled: true
driverClassName: "org.h2.Driver"
username: "sa"
password: ""
hibernate:
allow_update_outside_transaction: true
cache:
queries: false
use_second_level_cache: true
use_query_cache: false
region:
factory_class: 'org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory'

environments:
development:
dataSource:
dbCreate: "create-drop"
url: "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
test:
dataSource:
dbCreate: "update"
url: "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
dataSources:
second:
dbCreate: "update"
url: "jdbc:h2:mem:testDb2;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
production:
dataSource:
dbCreate: "update"
url: "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
properties:
maxActive: -1
minEvictableIdleTimeMillis: 1800000
timeBetweenEvictionRunsMillis: 1800000
numTestsPerEvictionRun: 3
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
validationQuery: "SELECT 1"
jdbcInterceptors: "ConnectionState"
dataSources:
second:
dbCreate: "update"
url: "jdbc:h2:mem:testDb2;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import ch.qos.logback.classic.encoder.PatternLayoutEncoder
import grails.util.BuildSettings
import grails.util.Environment


// See http://logback.qos.ch/manual/groovy.html for details on configuration
appender('STDOUT', ConsoleAppender) {
encoder(PatternLayoutEncoder) {
pattern = "%level %logger - %msg%n"
}
}

logger("grails.plugins.orm.auditable", DEBUG)
logger("test", DEBUG)

root(ERROR, ['STDOUT'])

if(Environment.current == Environment.DEVELOPMENT) {
def targetDir = BuildSettings.TARGET_DIR
if(targetDir) {

appender("FULL_STACKTRACE", FileAppender) {

file = "${targetDir}/stacktrace.log"
append = true
encoder(PatternLayoutEncoder) {
pattern = "%level %logger - %msg%n"
}
}
logger("StackTrace", ERROR, ['FULL_STACKTRACE'], false )
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place your Spring DSL code here
beans = {
}
Loading