okapi-connector-google failing, needs mocking

Issue #762 invalid
Mihai Nita created an issue

okapi-connector-google does not get tested because there are no keys.

It fails with "Error 403 - User limit exceeded for query query"

And the error is in net.sf.okapi.connectors.google.GoogleMTv2Connector. So it is not detected in test, it is just left to go through.

I think what DeepL does better:

  • The "normal" tests detect the key is missing, log, and don't run
  • DeepLv1ConnectorMockitoTests mocks, very nice.

Comments (10)

  1. Mihai Nita reporter

    Running mvn install I get this:

    [main] ERROR net.sf.okapi.connectors.google.GoogleMTv2Connector - Error 403 - User limit exceeded for query query
    [main] INFO net.sf.okapi.connectors.google.GoogleMTv2Connector - _batchQuery - retry 1 (waiting 0 ms
    

    11 times, in net.sf.okapi.connectors.google.TestGoogleMTv2Connector

  2. Mihai Nita reporter

    Oh... Apologies.

    Maybe I should learn to read the code before complaining.

    Thanks a lot, have a nice week-end :-) Mihai

  3. Mihai Nita reporter

    Not sure how can you clean the logs though... I have 3 ideas. 1 & 2 easy, 3 not so easy, but maybe nicer.

    1. You can disable logging for the GoogleMTv2Connector class in okapi\deployment\logbind-logback\src\main\resources\logback.xml:

      <logger name="net.sf.okapi.connectors.google.GoogleMTv2Connector" level="OFF"/>
    

    But the logging is a good indication that the connector does what is supposed to do: detect the timeout and report it.

    2. An option would be to keep it enabled, and add logging in the unit test saying something like

    "Logging about timeout errors from GoogleMTv2Connector are expected, don't worry, be happy :-)"

    That prevent people like me from getting scared :-)

    3. But if the unit test checks that the connector detects timeouts, then it should do that automatically. So would need something like expect certain logging, and assert if it is not received. That might be tricky to setup. But once setup, it might be nice to use in other situations too...

    Not sure how to do that cleanly though... The way would be to write a log appender. But that should be for logback, which we use for development and testing. And we don't see it directly, because is "hidden behind slf4j" I'll think about it.

  4. Log in to comment