forked from googleapis/google-cloud-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor integration tests and add more tests
- Loading branch information
Showing
24 changed files
with
383 additions
and
259 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
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
53 changes: 53 additions & 0 deletions
53
google-cloud-error_reporting/integration/error_reporting_helper.rb
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,53 @@ | ||
# Copyright 2016 Google Inc. All rights reserved. | ||
# | ||
# 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. | ||
|
||
|
||
require "minitest/autorun" | ||
require "minitest/rg" | ||
require "minitest/focus" | ||
require "net/http" | ||
require "open3" | ||
require "json" | ||
require_relative "../../integration/helper" | ||
|
||
|
||
## | ||
# Helper method to send a HTTP request to test app hosted from GCP environments. | ||
# | ||
# If TEST_GKE_POD_NAME environment variable is set, then we assume we're testing | ||
# against an app hosted in GKE. Then the HTTP requestion will be made from | ||
# inside the GKE VM instance by using "kubectl exec". If TEST_GKE_POD_NAME is | ||
# not set, then we assume it's GAE environment, and we can make an HTTP request | ||
# the normal way. | ||
# | ||
# The base URL can be provided through TEST_GOOGLE_CLOUD_PROJECT_URI environment | ||
# variable. Otherwise default to "http://localhost:8080" | ||
# | ||
# return the response body | ||
# | ||
def send_request path, query_params = nil | ||
base_url = ENV["TEST_GOOGLE_CLOUD_PROJECT_URI"] || "http://localhost:8080" | ||
uri = URI.join(base_url, path) | ||
uri.query= query_params if query_params | ||
|
||
gke_pod_name = ENV["TEST_GKE_POD_NAME"] | ||
|
||
if gke_pod_name | ||
Open3.capture3("kubectl exec #{gke_pod_name} -- curl #{uri.to_s}").first | ||
else | ||
response = Net::HTTP.get_response uri | ||
response.body | ||
end | ||
end | ||
|
38 changes: 0 additions & 38 deletions
38
google-cloud-error_reporting/integration/gke/error_reporting_test.rb
This file was deleted.
Oops, something went wrong.
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,45 @@ | ||
# Copyright 2016 Google Inc. All rights reserved. | ||
# | ||
# 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. | ||
|
||
|
||
require "logging_helper" | ||
require "google/cloud/logging" | ||
|
||
describe Google::Cloud::Logging do | ||
it "correctly setups logger" do | ||
response = JSON.parse send_request("test_logger") | ||
|
||
response["logger_class"].must_equal "Google::Cloud::Logging::Logger" | ||
response["writer_class"].must_equal "Google::Cloud::Logging::AsyncWriter" | ||
end | ||
|
||
it "submits logs on GAE" do | ||
token = Time.now.to_i | ||
send_request "test_logging", "token=#{token}" | ||
|
||
logs = [] | ||
keep_trying_till_true 60 do | ||
stdout = Open3.capture3( | ||
"gcloud beta logging read \"logName=projects/#{gcloud_project_id}/logs/google-cloud-ruby_integration_test " \ | ||
"AND textPayload:#{token}\" --limit 1 --format json" | ||
).first | ||
logs = JSON.parse stdout | ||
logs.length == 1 | ||
end | ||
|
||
logs.length.must_equal 1 | ||
end | ||
end | ||
|
||
|
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
Oops, something went wrong.