Show test results after gradle build or test


Environment and Prerequisite

  • Gradle
  • Assume that test environment is set


Method

Add below testLogging part to test in build.gradle

test {
    useJUnitPlatform()
    testLogging {
        afterSuite { testDescriptor, testResult ->
            if (testDescriptor.parent == null) {
                println "Results: ${testResult.resultType} (${testResult.testCount} tests, ${testResult.successfulTestCount} successes, ${testResult.failedTestCount} failures, ${testResult.skippedTestCount} skipped)"
            }
        }
    }
}
  • afterSuite: Run after test suite is done
  • testDescriptor: Describes a test
  • testResult: Describes a test result
  • testDescriptor.parent == null: Run when TestDescriptor’s parent is null which means end of the tests

Result Example

Taewoo-Macbook-Air-M1-2020:SpringBatchTestExample taewoo$ ./gradlew build
...
> Task :test
...
Results: SUCCESS (6 tests, 6 successes, 0 failures, 0 skipped)
...
BUILD SUCCESSFUL in 10s
6 actionable tasks: 3 executed, 3 up-to-date


Reference

<none>으로 표시된 도커 이미지들을 삭제하자


환경

  • Docker


삭제 명령어

명령어

docker rmi $(docker images --filter "dangling=true" --quiet --no-trunc)

옵션들 설명

  • --filter: 필터를 적용하는 옵션("dangling=true"는 태그가 없는 도커 이미지들을 의미)
  • --quiet: 도커 이미지들 id만 보여주는 옵션
  • --no-trunc: 도커 이미지 id 전체를 보여주는 옵션


참고자료

Remove docker images marked as <none>


Environment and Prerequisite

  • Docker


Remove Command

Command

docker rmi $(docker images --filter "dangling=true" --quiet --no-trunc)

Options

  • --filter: Filter out docker images("dangling=true" represents untagged docker images)
  • --quiet: Show only id of docker images
  • --no-trunc: Show full id of docker image


Reference

MySQL에서 테이블의 행(Row) 개수와 테이블 크기(Size) 구해보자


환경

  • MySQL


행(Row) 개수

  • 쿼리에서 COUNT(*)를 이용
select count(*) from '{table_name}';
  • information_schema.TABLES를 통해 어림잡은 값 가져오기
select TABLE_SCHEMA, TABLE_NAME, TABLE_ROWS from information_schema.TABLES where TABLE_SCHEMA='{database_name}' and TABLE_NAME='{table_name}';


크기(Size)

  • information_schema.TABLES를 사용
select TABLE_SCHEMA, TABLE_NAME, ((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) as 'Size in MB' from information_schema.TABLES where TABLE_SCHEMA='{database_name}' and TABLE_NAME='{table_name}';


하나의 쿼리로 행(Row) 개수와 크기(Size) 구하기

  • information_schema.TABLES를 사용
select TABLE_SCHEMA, TABLE_NAME, TABLE_ROWS, ((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) as 'Size in MB' from information_schema.TABLES where TABLE_SCHEMA='{database_name}' and TABLE_NAME='{table_name}';


참고자료

Get table’s row count and size in MySQL


Environment and Prerequisite

  • MySQL


Row Count

  • Use COUNT(*) in query
select count(*) from '{table_name}';
  • Get estimated value using information_schema.TABLES
select TABLE_SCHEMA, TABLE_NAME, TABLE_ROWS from information_schema.TABLES where TABLE_SCHEMA='{database_name}' and TABLE_NAME='{table_name}';


Size

  • Use information_schema.TABLES
select TABLE_SCHEMA, TABLE_NAME, ((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) as 'Size in MB' from information_schema.TABLES where TABLE_SCHEMA='{database_name}' and TABLE_NAME='{table_name}';


Get row count and size using one query

  • Use information_schema.TABLES
select TABLE_SCHEMA, TABLE_NAME, TABLE_ROWS, ((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) as 'Size in MB' from information_schema.TABLES where TABLE_SCHEMA='{database_name}' and TABLE_NAME='{table_name}';


Reference