Skip to content

Commit 2bfb76f

Browse files
authored
Merge pull request #86 from qiaoyuang/main
Update the concurrency test
2 parents 5c8fd07 + 0c25eef commit 2bfb76f

File tree

2 files changed

+24
-173
lines changed

2 files changed

+24
-173
lines changed

.github/workflows/publish.yml

Lines changed: 0 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -43,72 +43,12 @@ jobs:
4343
- name: Build sqllin-driver
4444
run: ./gradlew :sqllin-driver:assemble -PonCICD
4545

46-
- name: Run sqllin-driver macOS X64 Tests
47-
run: ./test_driver_macos.sh
48-
49-
- name: Run sqllin-driver JVM Unit Tests on macOS X64
50-
run: ./test_driver_jvm.sh
51-
5246
- name: Build sqllin-dsl
5347
run: ./gradlew :sqllin-dsl:assemble -PonCICD
5448

55-
- name: Run sqllin-dsl macOS X64 Tests
56-
run: ./test_dsl_macos.sh
57-
58-
- name: Run sqllin-dsl JVM Unit Tests on macOS X64
59-
run: ./test_dsl_jvm.sh
60-
6149
- name: Gradle Cache
6250
uses: gradle/gradle-build-action@v2
6351

64-
- name: AVD Cache
65-
uses: actions/cache@v3
66-
id: avd-cache
67-
with:
68-
path: |
69-
~/.android/avd/*
70-
~/.android/adb*
71-
key: avd-34
72-
73-
- name: Create AVD and Generate Snapshot for Caching
74-
if: steps.avd-cache.outputs.cache-hit != 'true'
75-
uses: reactivecircus/android-emulator-runner@v2
76-
with:
77-
api-level: 34
78-
target: google_apis
79-
arch: x86_64
80-
profile: pixel_6
81-
force-avd-creation: false
82-
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
83-
disable-animations: false
84-
script: echo "Generated AVD snapshot for caching."
85-
86-
- name: Run Android 14 Instrumented Tests
87-
uses: reactivecircus/android-emulator-runner@v2
88-
with:
89-
api-level: 34
90-
target: google_apis
91-
arch: x86_64
92-
profile: pixel_6
93-
force-avd-creation: false
94-
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
95-
disable-animations: true
96-
script: ./test_android.sh
97-
98-
- name: Upload sqllin-driver Reports
99-
uses: actions/upload-artifact@v2
100-
with:
101-
name: Test-Reports
102-
path: sqllin-driver/build/reports
103-
if: failure()
104-
105-
- name: Upload sqllin-dsl Reports
106-
uses: actions/upload-artifact@v2
107-
with:
108-
name: Test-Reports
109-
path: sqllin-dsl/build/reports
110-
if: failure()
111-
11252
- name: Publish to MavenCentral
11353
run: ./publish_apple_android_jvm.sh
11454

@@ -143,35 +83,9 @@ jobs:
14383
- name: Build sqllin-driver
14484
run: ./gradlew :sqllin-driver:mingwX64MainKlibrary
14585

146-
- name: Run sqllin-driver MinGW X64 Tests
147-
run: ./gradlew :sqllin-driver:cleanMingwX64Test && ./gradlew :sqllin-driver:mingwX64Test --stacktrace
148-
149-
- name: Run sqllin-driver JVM Unit Tests on MinGW X64
150-
run: ./gradlew :sqllin-driver:cleanJvmTest && ./gradlew :sqllin-driver:jvmTest --stacktrace
151-
15286
- name: Build sqllin-dsl
15387
run: ./gradlew :sqllin-dsl:mingwX64MainKlibrary
15488

155-
- name: Run sqllin-dsl MinGW X64 Tests
156-
run: ./gradlew :sqllin-dsl:cleanMingwX64Test && ./gradlew :sqllin-dsl:mingwX64Test --stacktrace
157-
158-
- name: Run sqllin-dsl JVM Unit Tests on MinGW X64
159-
run: ./gradlew :sqllin-dsl:cleanJvmTest && ./gradlew :sqllin-dsl:jvmTest --stacktrace
160-
161-
- name: Upload sqllin-driver Reports
162-
uses: actions/upload-artifact@v2
163-
with:
164-
name: Test-Reports
165-
path: sqllin-driver/build/reports
166-
if: failure()
167-
168-
- name: Upload sqllin-dsl Reports
169-
uses: actions/upload-artifact@v2
170-
with:
171-
name: Test-Reports
172-
path: sqllin-dsl/build/reports
173-
if: failure()
174-
17589
- name: Publish to MavenCentral
17690
run: ./gradlew :sqllin-driver:publishMingwX64PublicationToMavenRepository && ./gradlew :sqllin-dsl:publishMingwX64PublicationToMavenRepository
17791

@@ -206,74 +120,14 @@ jobs:
206120
- name: Build sqllin-driver
207121
run: ./gradlew :sqllin-driver:assemble -PonCICD
208122

209-
- name: Run sqllin-driver Linux X64 Tests
210-
run: ./test_driver_linux.sh
211-
212-
- name: Run sqllin-driver JVM Unit Tests on Linux X64
213-
run: ./test_driver_jvm.sh
214-
215123
- name: Build sqllin-processor
216124
run: ./gradlew :sqllin-processor:assemble
217125

218126
- name: Build sqllin-dsl
219127
run: ./gradlew :sqllin-dsl:assemble -PonCICD
220128

221-
- name: Run sqllin-dsl Linux X64 Tests
222-
run: ./test_dsl_linux.sh
223-
224-
- name: Run sqllin-dsl JVM Unit Tests on Linux X64
225-
run: ./test_dsl_jvm.sh
226-
227129
- name: Gradle Cache
228130
uses: gradle/gradle-build-action@v2
229131

230-
- name: AVD Cache
231-
uses: actions/cache@v3
232-
id: avd-cache
233-
with:
234-
path: |
235-
~/.android/avd/*
236-
~/.android/adb*
237-
key: avd-26
238-
239-
- name: Create AVD and Generate Snapshot for Caching
240-
if: steps.avd-cache.outputs.cache-hit != 'true'
241-
uses: reactivecircus/android-emulator-runner@v2
242-
with:
243-
api-level: 26
244-
target: default
245-
arch: x86_64
246-
profile: pixel_2
247-
force-avd-creation: false
248-
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
249-
disable-animations: false
250-
script: echo "Generated AVD snapshot for caching."
251-
252-
- name: Run Android 8 Instrumented Tests
253-
uses: reactivecircus/android-emulator-runner@v2
254-
with:
255-
api-level: 26
256-
target: default
257-
arch: x86_64
258-
profile: pixel_2
259-
force-avd-creation: false
260-
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
261-
disable-animations: true
262-
script: ./test_android.sh
263-
264-
- name: Upload sqllin-driver Reports
265-
uses: actions/upload-artifact@v2
266-
with:
267-
name: Test-Reports
268-
path: sqllin-driver/build/reports
269-
if: failure()
270-
271-
- name: Upload sqllin-dsl Reports
272-
uses: actions/upload-artifact@v2
273-
with:
274-
name: Test-Reports
275-
path: sqllin-dsl/build/reports
276-
if: failure()
277-
278132
- name: Publish to MavenCentral
279133
run: ./publish_linux_processor.sh

sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/CommonBasicTest.kt

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import com.ctrip.sqllin.dsl.sql.clause.OrderByWay.ASC
2424
import com.ctrip.sqllin.dsl.sql.clause.OrderByWay.DESC
2525
import com.ctrip.sqllin.dsl.sql.statement.SelectStatement
2626
import kotlinx.coroutines.Dispatchers
27+
import kotlinx.coroutines.delay
2728
import kotlinx.coroutines.launch
2829
import kotlinx.coroutines.runBlocking
2930
import kotlin.test.assertEquals
@@ -374,36 +375,32 @@ class CommonBasicTest(private val path: DatabasePath) {
374375
val book1 = Book(name = "The Da Vinci Code", author = "Dan Brown", pages = 454, price = 16.96)
375376
val book2 = Book(name = "The Lost Symbol", author = "Dan Brown", pages = 510, price = 19.95)
376377
launch {
377-
var statement: SelectStatement<Book>? = null
378+
lateinit var statement: SelectStatement<Book>
378379
database suspendedScope {
379380
statement = BookTable { table ->
380381
table INSERT listOf(book1, book2)
381382
table SELECT X
382383
}
383384
}
384-
385-
launch {
386-
val book1NewPrice = 18.96
387-
val book2NewPrice = 21.95
388-
val newBook1 = Book(name = "The Da Vinci Code", author = "Dan Brown", pages = 454, price = book1NewPrice)
389-
val newBook2 = Book(name = "The Lost Symbol", author = "Dan Brown", pages = 510, price = book2NewPrice)
390-
var newResult: SelectStatement<Book>? = null
391-
database suspendedScope {
392-
newResult = transaction {
393-
BookTable { table ->
394-
table UPDATE SET { price = book1NewPrice } WHERE (name EQ book1.name AND (price EQ book1.price))
395-
table UPDATE SET { price = book2NewPrice } WHERE (name EQ book2.name AND (price EQ book2.price))
396-
table SELECT X
397-
}
385+
assertEquals(true, statement.getResults().any { it == book1 })
386+
assertEquals(true, statement.getResults().any { it == book2 })
387+
}
388+
launch {
389+
val book1NewPrice = 18.96
390+
val book2NewPrice = 21.95
391+
val newBook1 = Book(name = "The Da Vinci Code", author = "Dan Brown", pages = 454, price = book1NewPrice)
392+
val newBook2 = Book(name = "The Lost Symbol", author = "Dan Brown", pages = 510, price = book2NewPrice)
393+
lateinit var statement: SelectStatement<Book>
394+
database suspendedScope {
395+
statement = transaction {
396+
BookTable { table ->
397+
table INSERT listOf(newBook1, newBook2)
398+
table SELECT X
398399
}
399400
}
400-
401-
assertEquals(true, newResult!!.getResults().any { it == newBook1 })
402-
assertEquals(true, newResult!!.getResults().any { it == newBook2 })
403401
}
404-
405-
assertEquals(true, statement!!.getResults().any { it == book1 })
406-
assertEquals(true, statement!!.getResults().any { it == book2 })
402+
assertEquals(true, statement.getResults().any { it == newBook1 })
403+
assertEquals(true, statement.getResults().any { it == newBook2 })
407404
}
408405
}
409406
}
@@ -441,12 +438,12 @@ class CommonBasicTest(private val path: DatabasePath) {
441438
lateinit var selectStatement: SelectStatement<NullTester>
442439
// INSERT & SELECT
443440
database {
444-
NullTesterTable { table ->
441+
selectStatement = NullTesterTable { table ->
445442
table INSERT listOf(
446443
NullTester(null, null, null),
447444
NullTester(8, "888", 8.8),
448445
)
449-
selectStatement = table SELECT X
446+
table SELECT X
450447
}
451448
}
452449

@@ -467,9 +464,9 @@ class CommonBasicTest(private val path: DatabasePath) {
467464

468465
// UPDATE & SELECT
469466
database {
470-
NullTesterTable { table ->
467+
selectStatement = NullTesterTable { table ->
471468
table UPDATE SET { paramString = null } WHERE (paramDouble EQ 8.8)
472-
selectStatement = table SELECT WHERE (paramInt NEQ null)
469+
table SELECT WHERE (paramInt NEQ null)
473470
}
474471
}
475472
val result1 = selectStatement.getResults().first()
@@ -480,9 +477,9 @@ class CommonBasicTest(private val path: DatabasePath) {
480477

481478
// DELETE & SELECT
482479
database {
483-
NullTesterTable { table ->
480+
selectStatement = NullTesterTable { table ->
484481
table DELETE WHERE (paramInt EQ null OR (paramDouble EQ null))
485-
selectStatement = table SELECT X
482+
table SELECT X
486483
}
487484
}
488485
val result2 = selectStatement.getResults().first()

0 commit comments

Comments
 (0)