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

[Th2-5165] Use cache in BookInfo #3

Merged
merged 15 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
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
26 changes: 26 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Run integration tests for cradle admin tool"

on:
push:
branches:
- '*'

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 'zulu' '11'
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Build with Gradle
run: ./gradlew --info clean integrationTest
- uses: actions/upload-artifact@v3
if: failure()
with:
name: integration-test-results
path: build/reports/tests/integrationTest/
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ allprojects {

implementation "org.slf4j:slf4j-api"

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2'
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

testImplementation 'org.mockito:mockito-inline:5.2.0'
testImplementation 'org.mockito:mockito-junit-jupiter:5.10.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ public class BookCliTest extends AbstractCliTest {
public void addBookTest(@Th2AppFactory CommonFactory appFactory,
@Th2TestFactory CommonFactory testFactory) throws Exception {
CradleStorage cradleStorage = testFactory.getCradleManager().getStorage();
int initNumberOfBooks = cradleStorage.listBooks().size();

String bookName = "addBookTest";

Application.run(new String[]{"-c=stub/", "--book", "-bookName", bookName}, args -> appFactory);

assertEquals(0, cradleStorage.getBooks().size());
BookInfo bookInfo = cradleStorage.getBook(new BookId(bookName));
assertEquals(1, cradleStorage.getBooks().size());
assertEquals(initNumberOfBooks + 1, cradleStorage.listBooks().size());
assertEquals(0, bookInfo.getPages().size());

checkOutput(true, null);
Expand All @@ -56,14 +56,14 @@ public void addBookTest(@Th2AppFactory CommonFactory appFactory,
public void addBookWithoutTimeTest(@Th2AppFactory CommonFactory appFactory,
@Th2TestFactory CommonFactory testFactory) throws Exception {
Nikita-Smirnov-Exactpro marked this conversation as resolved.
Show resolved Hide resolved
CradleStorage cradleStorage = testFactory.getCradleManager().getStorage();
int initNumberOfBooks = cradleStorage.listBooks().size();

Instant i1 = Instant.now();
String bookName = "addBookWithoutTimeTest";
Application.run(new String[]{"-c=stub/", "--book", "-bookName", bookName}, args -> appFactory);

assertEquals(0, cradleStorage.getBooks().size());
BookInfo bookInfo = cradleStorage.getBook(new BookId(bookName));
assertEquals(1, cradleStorage.getBooks().size());
assertEquals(initNumberOfBooks + 1, cradleStorage.listBooks().size());
assertNotNull(bookInfo);
assertNotNull(bookInfo.getCreated());
assertTrue(bookInfo.getCreated().isAfter(i1));
Expand All @@ -76,6 +76,7 @@ public void addBookWithoutTimeTest(@Th2AppFactory CommonFactory appFactory,
public void addBookWithParamsTest(@Th2AppFactory CommonFactory appFactory,
@Th2TestFactory CommonFactory testFactory) throws Exception {
CradleStorage cradleStorage = testFactory.getCradleManager().getStorage();
int initNumberOfBooks = cradleStorage.listBooks().size();

Instant created = Instant.now().minus(20, ChronoUnit.MINUTES);
String bookName = "addBookWithParamsTest";
Expand All @@ -89,9 +90,8 @@ public void addBookWithParamsTest(@Th2AppFactory CommonFactory appFactory,
args -> appFactory);


assertEquals(0, cradleStorage.getBooks().size());
BookInfo bookInfo = cradleStorage.getBook(bookId);
assertEquals(1, cradleStorage.getBooks().size());
assertEquals(initNumberOfBooks + 1, cradleStorage.listBooks().size());
assertNotNull(bookInfo);
assertEquals(bookFullName, bookInfo.getFullName());
assertEquals(bookDesc, bookInfo.getDesc());
Expand All @@ -105,12 +105,13 @@ public void addBookWithParamsTest(@Th2AppFactory CommonFactory appFactory,
public void addExistedBookTest(@Th2AppFactory CommonFactory appFactory,
@Th2TestFactory CommonFactory testFactory) throws Exception {
CradleStorage cradleStorage = testFactory.getCradleManager().getStorage();
int initNumberOfBooks = cradleStorage.listBooks().size();

String bookName = "addExistedBookTest";
BookId bookId = new BookId(bookName);
assertEquals(0, cradleStorage.getBooks().size());
testBookPageBuilder.addBookIds(bookName, Instant.now())
.exec(cradleStorage);
assertEquals(1, cradleStorage.getBooks().size());
assertEquals(initNumberOfBooks + 1, cradleStorage.listBooks().size());

Application.run(new String[]{"-c=stub/", "--book", "-bookName", bookName}, args -> appFactory);

Expand Down
4 changes: 0 additions & 4 deletions cradle-admin-tool-http/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ application {
mainClassName = "com.exactpro.th2.cradle.adm.http.Application"
}

test {
useJUnitPlatform()
}
OptimumCode marked this conversation as resolved.
Show resolved Hide resolved

applicationName = 'service'

distTar {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
release_version = 1.9.0
release_version = 1.9.0
Loading