Skip to content
This repository has been archived by the owner on Jan 20, 2025. It is now read-only.

fix flaky behavior in top30_검증 when asserting json list #290

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bjchris32
Copy link

@bjchris32 bjchris32 commented Nov 16, 2023

해결하려는 문제가 무엇인가요?(What is the problem to solve?)

  • There is a nondeterministic behavior in the test com.moment.the.controller.release.UncomfortableControllerTest.top30_검증 detected by NonDexengine. The nondeterministic behavior happened when assigning the json object in the method objectToJson.

https://github.com/themoment-team/K2-server/blob/c93e1ad31d4619f4b972e9d8d6fdc15c99fa2c55/src/test/java/com/moment/the/controller/release/UncomfortableControllerTest.java#L68C22-L68C22

The error log is shown as below, where keys of json objects in the list is not in particular order

Expected: a string containing "[{\"goods\":40,\"isAnswer\":false,\"uncomfortableIdx\":40,\"content\":\"ydMYXywvFzymkho\"},{\"goods\":39,\"isAnswer\":false,\"uncomfortableIdx\":39,\"content\":\"oSOPwjtfeOCgtCj\"},{\"goods\":38,\"isAnswer\":false,\"uncomfortableIdx\":38,\"content\":\"MPttssNhgAcAZyi\"},{\"goods\":37,\"isAnswer\":false,\"uncomfortableIdx\":37,\"content\":\"FPlLylQHMgDmXmj\"},{\"goods\":36,\"isAnswer\":false,\"uncomfortableIdx\":36,\"content\":\"UHYGdDECMiCwuUw\"},{\"goods\":35,\"isAnswer\":false,\"uncomfortableIdx\":35,\"content\":\"AqIFLPhguqxiaiZ\"},{\"goods\":34,\"isAnswer\":false,\"uncomfortableIdx\":34,\"content\":\"aBFFNBPlXsrcdER\"},{\"goods\":33,\"isAnswer\":false,\"uncomfortableIdx\":33,\"content\":\"ToayCoHCmbVXjYz\"},{\"goods\":32,\"isAnswer\":false,\"uncomfortableIdx\":32,\"content\":\"JQPDGMMmuokwlHN\"},{\"goods\":31,\"isAnswer\":false,\"uncomfortableIdx\":31,\"content\":\"GZSbBzEvxkGizfn\"},{\"goods\":30,\"isAnswer\":false,\"uncomfortableIdx\":30,\"content\":\"HjhLGJVlwwEPTuJ\"},{\"goods\":29,\"isAnswer\":false,\"uncomfortableIdx\":29,\"content\":\"QKQDIUfocYtCMRw\"},{\"goods\":28,\"isAnswer\":false,\"uncomfortableIdx\":28,\"content\":\"EHEIHkyrdHdIbpU\"},{\"goods\":27,\"isAnswer\":false,\"uncomfortableIdx\":27,\"content\":\"NeglviAyljoTPxH\"},{\"goods\":26,\"isAnswer\":false,\"uncomfortableIdx\":26,\"content\":\"bwttqLIugkXiAex\"},{\"goods\":25,\"isAnswer\":false,\"uncomfortableIdx\":25,\"content\":\"mpftuondcUhQKlp\"},{\"goods\":24,\"isAnswer\":false,\"uncomfortableIdx\":24,\"content\":\"OcDsgYgsnritloX\"},{\"goods\":23,\"isAnswer\":false,\"uncomfortableIdx\":23,\"content\":\"xYagUSzuJrAHRtK\"},{\"goods\":22,\"isAnswer\":false,\"uncomfortableIdx\":22,\"content\":\"kgoVyVDqWfKPYzC\"},{\"goods\":21,\"isAnswer\":false,\"uncomfortableIdx\":21,\"content\":\"zfdMaomrgedPGMI\"},{\"goods\":20,\"isAnswer\":false,\"uncomfortableIdx\":20,\"content\":\"ajbCzrfMyGFFBex\"},{\"goods\":19,\"isAnswer\":false,\"uncomfortableIdx\":19,\"content\":\"hotcnwhNtaZumfl\"},{\"goods\":18,\"isAnswer\":false,\"uncomfortableIdx\":18,\"content\":\"cFHXsFxpxeXuOco\"},{\"goods\":17,\"isAnswer\":false,\"uncomfortableIdx\":17,\"content\":\"EKGYrUSujhaZnzE\"},{\"goods\":16,\"isAnswer\":false,\"uncomfortableIdx\":16,\"content\":\"IdtAwxILiQZuhsM\"},{\"goods\":15,\"isAnswer\":false,\"uncomfortableIdx\":15,\"content\":\"cKfGKCVjQsrGGFi\"},{\"goods\":14,\"isAnswer\":false,\"uncomfortableIdx\":14,\"content\":\"jXWLxTkaOCICRCA\"},{\"goods\":13,\"isAnswer\":false,\"uncomfortableIdx\":13,\"content\":\"bwtTICuurtFurwm\"},{\"goods\":12,\"isAnswer\":false,\"uncomfortableIdx\":12,\"content\":\"QqYsIjxEvoNWOAK\"},{\"goods\":11,\"isAnswer\":false,\"uncomfortableIdx\":11,\"content\":\"FSoFGZogFetKEfy\"}]"
but: was "{"msg":"SUCCESS-200","list":[{"uncomfortableIdx":40,"isAnswer":false,"content":"ydMYXywvFzymkho","goods":40},{"uncomfortableIdx":39,"isAnswer":false,"content":"oSOPwjtfeOCgtCj","goods":39},{"uncomfortableIdx":38,"isAnswer":false,"content":"MPttssNhgAcAZyi","goods":38},{"uncomfortableIdx":37,"isAnswer":false,"content":"FPlLylQHMgDmXmj","goods":37},{"uncomfortableIdx":36,"isAnswer":false,"content":"UHYGdDECMiCwuUw","goods":36},{"uncomfortableIdx":35,"isAnswer":false,"content":"AqIFLPhguqxiaiZ","goods":35},{"uncomfortableIdx":34,"isAnswer":false,"content":"aBFFNBPlXsrcdER","goods":34},{"uncomfortableIdx":33,"isAnswer":false,"content":"ToayCoHCmbVXjYz","goods":33},{"uncomfortableIdx":32,"isAnswer":false,"content":"JQPDGMMmuokwlHN","goods":32},{"uncomfortableIdx":31,"isAnswer":false,"content":"GZSbBzEvxkGizfn","goods":31},{"uncomfortableIdx":30,"isAnswer":false,"content":"HjhLGJVlwwEPTuJ","goods":30},{"uncomfortableIdx":29,"isAnswer":false,"content":"QKQDIUfocYtCMRw","goods":29},{"uncomfortableIdx":28,"isAnswer":false,"content":"EHEIHkyrdHdIbpU","goods":28},{"uncomfortableIdx":27,"isAnswer":false,"content":"NeglviAyljoTPxH","goods":27},{"uncomfortableIdx":26,"isAnswer":false,"content":"bwttqLIugkXiAex","goods":26},{"uncomfortableIdx":25,"isAnswer":false,"content":"mpftuondcUhQKlp","goods":25},{"uncomfortableIdx":24,"isAnswer":false,"content":"OcDsgYgsnritloX","goods":24},{"uncomfortableIdx":23,"isAnswer":false,"content":"xYagUSzuJrAHRtK","goods":23},{"uncomfortableIdx":22,"isAnswer":false,"content":"kgoVyVDqWfKPYzC","goods":22},{"uncomfortableIdx":21,"isAnswer":false,"content":"zfdMaomrgedPGMI","goods":21},{"uncomfortableIdx":20,"isAnswer":false,"content":"ajbCzrfMyGFFBex","goods":20},{"uncomfortableIdx":19,"isAnswer":false,"content":"hotcnwhNtaZumfl","goods":19},{"uncomfortableIdx":18,"isAnswer":false,"content":"cFHXsFxpxeXuOco","goods":18},{"uncomfortableIdx":17,"isAnswer":false,"content":"EKGYrUSujhaZnzE","goods":17},{"uncomfortableIdx":16,"isAnswer":false,"content":"IdtAwxILiQZuhsM","goods":16},{"uncomfortableIdx":15,"isAnswer":false,"content":"cKfGKCVjQsrGGFi","goods":15},{"uncomfortableIdx":14,"isAnswer":false,"content":"jXWLxTkaOCICRCA","goods":14},{"uncomfortableIdx":13,"isAnswer":false,"content":"bwtTICuurtFurwm","goods":13},{"uncomfortableIdx":12,"isAnswer":false,"content":"QqYsIjxEvoNWOAK","goods":12},{"uncomfortableIdx":11,"isAnswer":false,"content":"FSoFGZogFetKEfy","goods":11}]}"

어떻게 해결했나요?(How do we solve the problem?)

Before making assertions, we could sort the keys of expected json objects and the actual json objects.

Attachment

  • 이번 MR의 동작의 이해를 돕는 PNG, JPG 파일 첨부!
  • 리뷰어의 이해를 돕기 위한 모듈/클래스 설계에 대한 Diagram 포함!
    NA

리뷰해주세요 🙇🏻‍♂️

NA

How to test?

Test Environment:

openjdk version "11.0.20.1"
Apache Maven 3.6.3
Ubuntu 20.04.6 LTS
Linux version: 5.4.0-163-generic

Run the unit test using NonDex with the following procedure.

  • Add the following lines to the top of the file build.gradle.
buildscript {
    repositories {
      maven {
        url = uri('https://plugins.gradle.org/m2/')
      }
    }
    dependencies {
      classpath('edu.illinois:plugin:2.1.1')
    }
}
  • Add the following line in the end of the file
apply plugin: 'edu.illinois.nondex'
  • Comment out useJUnitPlatform() and add the following lines and it would look like:
test {
    jacoco {
        enabled = true
        destinationFile = file("$buildDir/jacoco/${name}.exec")
        includes = []
        excludes = []
        excludeClassLoaders = []
        includeNoLocationClasses = false
        sessionId = "<auto-generated value>"
        dumpOnExit = true
        classDumpDir = null
        output = JacocoTaskExtension.Output.FILE
        address = "localhost"
        port = 6300
        jmx = false
    }
    // useJUnitPlatform()
    finalizedBy 'jacocoTestReport'
}

tasks.withType(Test) {
  useJUnitPlatform()
}
  • Run the NonDex for 5 times
./gradlew --info nondexTest --tests=com.moment.the.controller.release.UncomfortableControllerTest.top30_검증 --nondexRuns=5

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant