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

Fix env_verifier + protobuf gitlab build issues #148

Merged
merged 3 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 46 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions trace-mini-agent/src/env_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,24 @@ mod tests {
ensure_gcp_function_environment, get_region_from_gcp_region_string, GoogleMetadataClient,
};

use super::{EnvVerifier, GoogleMetadataClientWrapper, ServerlessEnvVerifier};
use super::{EnvVerifier, ServerlessEnvVerifier};

#[tokio::test]
async fn test_verify_env_false_if_metadata_server_unreachable() {
// unit tests will always run in an environment where http://metadata.google.internal is unreachable
let res = ensure_gcp_function_environment(Box::new(GoogleMetadataClientWrapper {})).await;
struct MockGoogleMetadataClient {}
#[async_trait]
impl GoogleMetadataClient for MockGoogleMetadataClient {
async fn get_metadata(&self) -> anyhow::Result<Response<Body>> {
anyhow::bail!("Random Error")
}
}
let res = ensure_gcp_function_environment(Box::new(MockGoogleMetadataClient {})).await;
assert!(res.is_err());
assert!(res
.unwrap_err()
.to_string()
.contains("Can't communicate with Google Metadata Server. error trying to connect:"));
.contains("Can't communicate with Google Metadata Server"));
}

#[tokio::test]
Expand Down
4 changes: 2 additions & 2 deletions trace-protobuf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ serde_bytes = "0.11.9"

[build-dependencies]
prost-build = { version = "0.11.9", optional = true }
protobuf-src = { version = "1.1.0", optional = true }
protoc-bin-vendored = { version = "3.0.0", optional = true }

[features]
generate-protobuf = ["dep:prost-build", "dep:protobuf-src"]
generate-protobuf = ["dep:prost-build", "dep:protoc-bin-vendored"]
2 changes: 1 addition & 1 deletion trace-protobuf/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn main() -> Result<()> {
{
// protoc is required to compile proto files. This uses protobuf_src to compile protoc
// from the source, setting the env var to tell prost_build where to find it.
std::env::set_var("PROTOC", protobuf_src::protoc());
std::env::set_var("PROTOC", protoc_bin_vendored::protoc_bin_path().unwrap());

// compiles the .proto files into rust structs
generate_protobuf();
Expand Down