-
Notifications
You must be signed in to change notification settings - Fork 8
Add very basic unit tests for S3 and HTTP #27
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9670a99
Add very basic unit tests for S3 and HTTP
jhiemstrawisc 98cb22e
Add missing newlines at EOF
jhiemstrawisc b9d7827
Remove unused import
jhiemstrawisc c0939f4
Run clang-format on new files
jhiemstrawisc 739dce5
Unlink XrdHTTPServer from s3-gtest
jhiemstrawisc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
add_executable( s3-gtest s3_tests.cc | ||
../src/AWSv4-impl.cc | ||
../src/logging.cc | ||
../src/S3AccessInfo.cc | ||
../src/S3File.cc | ||
../src/S3FileSystem.cc | ||
../src/shortfile.cc | ||
../src/stl_string_utils.cc | ||
../src/HTTPCommands.cc | ||
../src/S3Commands.cc | ||
) | ||
|
||
add_executable( http-gtest http_tests.cc | ||
../src/HTTPFile.cc | ||
../src/HTTPFileSystem.cc | ||
../src/HTTPCommands.cc | ||
../src/stl_string_utils.cc | ||
../src/shortfile.cc | ||
../src/logging.cc | ||
) | ||
|
||
|
||
if( NOT XROOTD_PLUGINS_EXTERNAL_GTEST ) | ||
add_dependencies(s3-gtest gtest) | ||
add_dependencies(http-gtest gtest) | ||
include_directories("${PROJECT_SOURCE_DIR}/vendor/gtest/googletest/include") | ||
endif() | ||
|
||
if(XROOTD_PLUGINS_EXTERNAL_GTEST) | ||
set(LIBGTEST "gtest") | ||
else() | ||
set(LIBGTEST "${CMAKE_BINARY_DIR}/external/gtest/src/gtest-build/lib/libgtest.a") | ||
endif() | ||
|
||
target_link_libraries(s3-gtest XrdS3 "${LIBGTEST}" pthread) | ||
target_link_libraries(http-gtest XrdHTTPServer "${LIBGTEST}" pthread) | ||
|
||
|
||
add_test( | ||
NAME | ||
s3-unit | ||
COMMAND | ||
${CMAKE_CURRENT_BINARY_DIR}/s3-gtest | ||
) | ||
|
||
add_test( | ||
NAME | ||
http-unit | ||
COMMAND | ||
${CMAKE_CURRENT_BINARY_DIR}/http-gtest | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/*************************************************************** | ||
* | ||
* Copyright (C) 2024, Pelican Project, Morgridge Institute for Research | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you | ||
* may not use this file except in compliance with the License. You may | ||
* obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
***************************************************************/ | ||
|
||
#include "../src/HTTPCommands.hh" | ||
|
||
#include <XrdSys/XrdSysError.hh> | ||
#include <XrdSys/XrdSysLogger.hh> | ||
#include <gtest/gtest.h> | ||
|
||
jhiemstrawisc marked this conversation as resolved.
Show resolved
Hide resolved
jhiemstrawisc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
class TestHTTPRequest : public HTTPRequest { | ||
public: | ||
XrdSysLogger log{}; | ||
XrdSysError err{&log, "TestS3CommandsLog"}; | ||
|
||
TestHTTPRequest(const std::string &url) : HTTPRequest(url, err) {} | ||
}; | ||
|
||
TEST(TestHTTPParseProtocol, Test1) { | ||
const std::string httpURL = "https://my-test-url.com:443"; | ||
TestHTTPRequest req{httpURL}; | ||
|
||
// Test parsing of https | ||
std::string protocol; | ||
req.parseProtocol("https://my-test-url.com:443", protocol); | ||
ASSERT_EQ(protocol, "https"); | ||
|
||
// Test parsing for http | ||
req.parseProtocol("http://my-test-url.com:443", protocol); | ||
ASSERT_EQ(protocol, "http"); | ||
} | ||
|
||
int main(int argc, char **argv) { | ||
::testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.