Giter Club home page Giter Club logo

Comments (11)

SamuelMarks avatar SamuelMarks commented on August 15, 2024 2

Agreed. Unit tests should be independent, and finish rapidly.

The distinction is made clearly by Martin Fowler, between Sociable Tests and Solitary Tests.
https://martinfowler.com/bliki/UnitTest.html
(referencing Jay Fields, who originated these terms in https://leanpub.com/wewut)

We want only Solitary Tests to run from go test.

from go-lachesis.

s4kibs4mi avatar s4kibs4mi commented on August 15, 2024 1

@rishflab I have tested on my machine (macOS Mojave) and it worked. To test client its mandatory to run server first. So what we can do is running server within client test other than depending on server test, in same way in server test have to add client test stuffs.

from go-lachesis.

rishflab avatar rishflab commented on August 15, 2024 1

Yeh we should make this sort of test an integration test.

I don't think the websocket server is currently being used anywhere in the codebase. I removed it along with many other unused transports and everything seems to be running. I don't think it should be in master unless it is being used in master. It is unneccesary cognitive overhead and maintenance burden.

If it is part of an incomplete feature it should probably sit in that feature branch until it is complete, imo.

from go-lachesis.

rishflab avatar rishflab commented on August 15, 2024

client_websocket_test.go hangs when trying to connect
if err := c.Connect(addr, path); err != nil { t.Error(err) return }
If I have the server_websocket_test.go running before running the client test, both tests are able to establish a connection and send messages to each other but both test processes gets stuck in CLOSE_WAIT after completing the test.

@s4kibs4mi could you shed some light on how these tests are meant to run?

from go-lachesis.

s4kibs4mi avatar s4kibs4mi commented on August 15, 2024

@rishflab to test client addr parameter you are passing is the address of websocket server and the server must be up and running to test client. In test case 10 messages exchange happens between server and client and both go off.

from go-lachesis.

rishflab avatar rishflab commented on August 15, 2024

Hey thanks for you response.
The tests pass when i run the server test and the client tests sequentially but the processes still hang. Gracefulshutdown doesn’t seem to work on my machine, does it work on yours? (I’m running Ubuntu 18.04)
Also we are setting up CI/CD and these tests won’t work there as must run in a specific order which cannot be guaranteed.

from go-lachesis.

AgustinCB avatar AgustinCB commented on August 15, 2024

Uh, if the client needs the server to be or if some order is required, then this is not a unit test any more (which is what go test assumes).

Is there a way we can mock the server? If not, maybe we can move this test out of the unit test chain and make some kind of integration test?

from go-lachesis.

s4kibs4mi avatar s4kibs4mi commented on August 15, 2024

@rishflab the purpose of test was to clarify the usage. And so far I can remember @andrecronje told me that it will be used to send events within nodes. Not sure if we are still on the track or decided something else to use.

from go-lachesis.

rishflab avatar rishflab commented on August 15, 2024

Yeh im curious myself, because i think gRPC is being used now for internode communication, not 100% sure.

from go-lachesis.

quan8 avatar quan8 commented on August 15, 2024

Hi, plz leave comments to help understand or resolve the issue.
@s4kibs4mi which issue does those new files belong to?
Agree with @AgustinCB. The tests need to be rewritten. In general, every test should not depend on any other tests.

from go-lachesis.

s4kibs4mi avatar s4kibs4mi commented on August 15, 2024

I will rewrite the tests.
@quan8 @andrecronje can clarify.

from go-lachesis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.