forked from ontoportal/goo
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Add paginated all function for resources and logging config …
…and tests (#67) * handle the case were we don't use the indexation feature * change ask to select for better compatibility with virtuoso * update append triples function to catch errors and log them * put the number of appended chunks to 50 000 line by chunck * update chunks insert for virtuoso to be 50k lines instead of 500k to prevent crashing * implement mode paginated_all that will get all the resources using pagination * add query logging configuration and remove cube * add logging test
- Loading branch information
1 parent
8d108c2
commit b8eb3d0
Showing
7 changed files
with
125 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -26,4 +26,7 @@ doc/ | |
.idea/* | ||
projectFilesBackup/* | ||
|
||
config/config.rb | ||
config/config.rb | ||
queries.txt | ||
|
||
*.iml |
This file contains 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 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 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 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 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 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,54 @@ | ||
require_relative 'test_case' | ||
require_relative 'models' | ||
|
||
class TestLogging < MiniTest::Unit::TestCase | ||
|
||
def self.before_suite | ||
GooTestData.create_test_case_data | ||
Goo.use_cache = true | ||
Goo.redis_client.flushdb | ||
Goo.add_query_logger(enabled: true, file: "test.log") | ||
end | ||
|
||
def self.after_suite | ||
GooTestData.delete_test_case_data | ||
Goo.add_query_logger(enabled: false, file: nil) | ||
File.delete("test.log") if File.exist?("test.log") | ||
Goo.redis_client.flushdb | ||
Goo.use_cache = false | ||
end | ||
|
||
def setup | ||
Goo.redis_client.flushdb | ||
end | ||
|
||
def test_logging | ||
Goo.logger.info("Test logging") | ||
University.all | ||
recent_logs = Goo.logger.get_logs | ||
assert_equal 3, recent_logs.length | ||
assert recent_logs.any? { |x| x['query'].include?("Test logging") } | ||
assert File.read("test.log").include?("Test logging") | ||
end | ||
|
||
def test_last_10s_logs | ||
Goo.logger.info("Test logging 2") | ||
University.all | ||
recent_logs = Goo.logger.queries_last_n_seconds(1) | ||
assert_equal 3, recent_logs.length | ||
assert recent_logs.any? { |x| x['query'].include?("Test logging 2") } | ||
assert File.read("test.log").include?("Test logging 2") | ||
sleep 1 | ||
recent_logs = Goo.logger.queries_last_n_seconds(1) | ||
assert_equal 0, recent_logs.length | ||
end | ||
|
||
def test_auto_clean_logs | ||
Goo.logger.info("Test logging 3") | ||
(1..3000).each do |_i| | ||
University.all | ||
end | ||
recent_logs = Goo.logger.get_logs | ||
assert recent_logs.length < 2000 | ||
end | ||
end |