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

[QT][C++]fixed integration test for Oauth #10921

Merged
merged 3 commits into from
Dec 14, 2021

Conversation

basyskom-dege
Copy link
Contributor

Fix for the PR that broke the integration test. #10183

I had to modify the CMakeLists.txt in the Petstore example project and add Qt5::Gui package.

@wing328

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master (5.3.0), 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@wing328
Copy link
Member

wing328 commented Nov 23, 2021

CI reports the following:

cd /home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/build/client && /usr/bin/g++-5  -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -I/home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/build/client -I/home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/client -I/home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/build/client/client_autogen/include -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -isystem /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -isystem /usr/include/x86_64-linux-gnu/qt5/QtNetwork -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui  -fPIC -Wall -Wno-unused-variable -fPIC -Wall -Wno-unused-variable   -fPIC -std=c++14 -o CMakeFiles/client.dir/PFXPetApi.cpp.o -c /home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp
In file included from /home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/client/PFXPetApi.h:18:0,
                 from /home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp:12:
/home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/client/PFXOauth.h: In constructor ‘test_namespace::oauthToken::oauthToken(QString, int, QString, QString)’:
/home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/client/PFXOauth.h:43:24: error: ‘fromSecsSinceEpoch’ is not a member of ‘QDateTime’
         m_validUntil = QDateTime::fromSecsSinceEpoch(QDateTime::currentSecsSinceEpoch() + expiresIn);
                        ^
/home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/client/PFXOauth.h:43:54: error: ‘currentSecsSinceEpoch’ is not a member of ‘QDateTime’
         m_validUntil = QDateTime::fromSecsSinceEpoch(QDateTime::currentSecsSinceEpoch() + expiresIn);
                                                      ^
/home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/client/PFXOauth.h: In constructor ‘test_namespace::oauthToken::oauthToken()’:
/home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/client/PFXOauth.h:46:24: error: ‘fromSecsSinceEpoch’ is not a member of ‘QDateTime’
         m_validUntil = QDateTime::fromSecsSinceEpoch(QDateTime::currentSecsSinceEpoch() -1);
                        ^
/home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/client/PFXOauth.h:46:54: error: ‘currentSecsSinceEpoch’ is not a member of ‘QDateTime’
         m_validUntil = QDateTime::fromSecsSinceEpoch(QDateTime::currentSecsSinceEpoch() -1);
                                                      ^
client/CMakeFiles/client.dir/build.make:143: recipe for target 'client/CMakeFiles/client.dir/PFXPetApi.cpp.o' failed
make[2]: Leaving directory '/home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/build'
make[2]: *** [client/CMakeFiles/client.dir/PFXPetApi.cpp.o] Error 1
CMakeFiles/Makefile2:164: recipe for target 'client/CMakeFiles/client.dir/all' failed
make[1]: *** [client/CMakeFiles/client.dir/all] Error 2
make[1]: Leaving directory '/home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/build'
Makefile:132: recipe for target 'all' failed
make: *** [all] Error 2
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (pet-test) on project CppQt5PetstoreClientTests: Command execution failed. Process exited with an error: 2 (Exit value: 2) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (pet-test) on project CppQt5PetstoreClientTests: Command execution failed.

Ref: https://app.travis-ci.com/github/OpenAPITools/openapi-generator/builds/242237594

Can you please take a look when you've time?

@basyskom-dege
Copy link
Contributor Author

basyskom-dege commented Nov 26, 2021

This function was introduced in Qt 5.8.

The function QDateTime::fromSecsSinceEpoch is causing the error. I will use another function that was introduced in Qt 4.7:

QDateTime::fromMSecsSinceEpoch

This function was introduced in Qt 4.7.

@wing328 wing328 added this to the 5.3.1 milestone Nov 27, 2021
@wing328
Copy link
Member

wing328 commented Nov 27, 2021

No luck :(

[ 34%] Building CXX object client/CMakeFiles/client.dir/PFXPetApi.cpp.o
cd /home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/build/client && /usr/bin/g++-5  -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -I/home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/build/client -I/home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/client -I/home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/build/client/client_autogen/include -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -isystem /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -isystem /usr/include/x86_64-linux-gnu/qt5/QtNetwork -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui  -fPIC -Wall -Wno-unused-variable -fPIC -Wall -Wno-unused-variable   -fPIC -std=c++14 -o CMakeFiles/client.dir/PFXPetApi.cpp.o -c /home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp
In file included from /home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/client/PFXPetApi.h:18:0,
                 from /home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/client/PFXPetApi.cpp:12:
/home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/client/PFXOauth.h: In constructor ‘test_namespace::oauthToken::oauthToken(QString, int, QString, QString)’:
/home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/client/PFXOauth.h:43:56: error: ‘currentSecsSinceEpoch’ is not a member of ‘QDateTime’
         m_validUntil = QDateTime::fromMSecsSinceEpoch((QDateTime::currentSecsSinceEpoch() + expiresIn) * 1000);
                                                        ^
/home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/client/PFXOauth.h: In constructor ‘test_namespace::oauthToken::oauthToken()’:
/home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/client/PFXOauth.h:46:56: error: ‘currentSecsSinceEpoch’ is not a member of ‘QDateTime’
         m_validUntil = QDateTime::fromMSecsSinceEpoch((QDateTime::currentSecsSinceEpoch() -1 )*1000);
                                                        ^
client/CMakeFiles/client.dir/build.make:143: recipe for target 'client/CMakeFiles/client.dir/PFXPetApi.cpp.o' failed
make[2]: Leaving directory '/home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/build'
make[2]: *** [client/CMakeFiles/client.dir/PFXPetApi.cpp.o] Error 1
make[1]: *** [client/CMakeFiles/client.dir/all] Error 2
CMakeFiles/Makefile2:164: recipe for target 'client/CMakeFiles/client.dir/all' failed
make[1]: Leaving directory '/home/travis/build/OpenAPITools/openapi-generator/samples/client/petstore/cpp-qt/build'
Makefile:132: recipe for target 'all' failed
make: *** [all] Error 2
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (pet-test) on project CppQt5PetstoreClientTests: Command execution failed. Process exited with an error: 2 (Exit value: 2) -> [Help 1]

https://app.travis-ci.com/github/OpenAPITools/openapi-generator/builds/242485637

@basyskom-dege
Copy link
Contributor Author

Hmm. Any idea whats the reason behind this? I will change the calulations and use ctime lib and remove QDatetime.

@wing328
Copy link
Member

wing328 commented Nov 30, 2021

No idea. Does it work for you locally?

cd samples/client/petstore/cpp-qt/ && ./build-and-test.bash

(you may need to run the petstore server locally: https://github.com/OpenAPITools/openapi-generator/wiki/Integration-Tests#how-to-add-integration-tests-for-new-petstore-samples)

Btw, we use QT5 in Travis CI: https://github.com/OpenAPITools/openapi-generator/blob/master/.travis.yml#L103

@basyskom-dege
Copy link
Contributor Author

It ran fine for me even with the other functions. The integration test ran aswell. I will try that again with the local server. If it does not work out I will use another library to calculate if the tokens are still valid. But I got no ETA. I will try later this week!

@basyskom-dege
Copy link
Contributor Author

No idea. Does it work for you locally?

I changed the calculations. It uses time.h library.
I tested it locally and it should work now

@wing328
Copy link
Member

wing328 commented Dec 14, 2021

@wing328 wing328 merged commit 8fbd110 into OpenAPITools:master Dec 14, 2021
@wing328
Copy link
Member

wing328 commented Dec 14, 2021

Thanks for the fix, which has been merged into master. Will re-enable the CI check in another commit.

@xconverge
Copy link
Contributor

xconverge commented Dec 18, 2021

@basyskom-dege if you find yourself in this area again I think <ctime> should be preferred to <time.h> for namespacing reasons but not enough for me to open a PR 👍

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

Successfully merging this pull request may close these issues.

3 participants