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

Use http:// in GCS integration test instead of insecure TLS #2632

Merged
merged 1 commit into from Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
75 changes: 27 additions & 48 deletions .github/workflows/object_store.yml
Expand Up @@ -60,74 +60,53 @@ jobs:
run: cargo clippy -p object_store --all-features --all-targets -- -D warnings

# test the crate
# This runs outside a container to workaround lack of support for passing arguments
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really tried to avoid this, but I could not find a way around this. We use non-docker runners in other workflows, e.g. miri, integration, coverage, so I think this is probably fine

# to service containers - https://github.com/orgs/community/discussions/26688
linux-test:
name: Emulator Tests
runs-on: ubuntu-latest
services:
fake-gcs:
image: fsouza/fake-gcs-server
ports:
- 4443:4443
localstack:
image: localstack/localstack:0.14.4
ports:
- 4566:4566
ec2-metadata:
image: amazon/amazon-ec2-metadata-mock:v1.9.2
ports:
- 1338:1338
env:
# Only allow IMDSv2
AEMM_IMDSV2: "1"
azurite:
image: mcr.microsoft.com/azure-storage/azurite
ports:
- 10000:10002
container:
image: amd64/rust
env:
# Disable full debug symbol generation to speed up CI build and keep memory down
# "1" means line tables only, which is useful for panic tracebacks.
RUSTFLAGS: "-C debuginfo=1"
# https://github.com/rust-lang/cargo/issues/10280
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
RUST_BACKTRACE: "1"
# Run integration tests
TEST_INTEGRATION: 1
EC2_METADATA_ENDPOINT: http://ec2-metadata:1338
AZURE_USE_EMULATOR: "1"
AZURITE_BLOB_STORAGE_URL: "http://azurite:10000"
AZURITE_QUEUE_STORAGE_URL: "http://azurite:10001"
GOOGLE_SERVICE_ACCOUNT: "/tmp/gcs.json"
OBJECT_STORE_BUCKET: test-bucket
env:
# Disable full debug symbol generation to speed up CI build and keep memory down
# "1" means line tables only, which is useful for panic tracebacks.
RUSTFLAGS: "-C debuginfo=1"
# https://github.com/rust-lang/cargo/issues/10280
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
RUST_BACKTRACE: "1"
# Run integration tests
TEST_INTEGRATION: 1
EC2_METADATA_ENDPOINT: http://localhost:1338
AZURE_USE_EMULATOR: "1"
AZURITE_BLOB_STORAGE_URL: "http://localhost:10000"
AZURITE_QUEUE_STORAGE_URL: "http://localhost:10001"
GOOGLE_SERVICE_ACCOUNT: "/tmp/gcs.json"
OBJECT_STORE_BUCKET: test-bucket

steps:
- uses: actions/checkout@v3

- name: Configure Fake GCS Server (GCP emulation)
run: |
curl --insecure -v -X POST --data-binary '{"name":"test-bucket"}' -H "Content-Type: application/json" "https://fake-gcs:4443/storage/v1/b"
echo '{"gcs_base_url": "https://fake-gcs:4443", "disable_oauth": true, "client_email": "", "private_key": ""}' > "$GOOGLE_SERVICE_ACCOUNT"
docker run -d -p 4443:4443 fsouza/fake-gcs-server -scheme http
curl -v -X POST --data-binary '{"name":"test-bucket"}' -H "Content-Type: application/json" "http://localhost:4443/storage/v1/b"
echo '{"gcs_base_url": "http://localhost:4443", "disable_oauth": true, "client_email": "", "private_key": ""}' > "$GOOGLE_SERVICE_ACCOUNT"

- name: Setup LocalStack (AWS emulation)
env:
AWS_DEFAULT_REGION: "us-east-1"
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test
AWS_ENDPOINT: http://localstack:4566
AWS_ENDPOINT: http://localhost:4566
run: |
cd /tmp
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
Copy link
Contributor Author

@tustvold tustvold Sep 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A happy side-effect of switching to not using the docker runner is the AWS and Azure CLI's are automatically installed (along with Rust) - https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md#cli-tools

unzip awscliv2.zip
./aws/install
aws --endpoint-url=http://localstack:4566 s3 mb s3://test-bucket
docker run -d -p 4566:4566 localstack/localstack:0.14.4
docker run -d -p 1338:1338 amazon/amazon-ec2-metadata-mock:v1.9.2 --imdsv2
aws --endpoint-url=http://localhost:4566 s3 mb s3://test-bucket

- name: Configure Azurite (Azure emulation)
# the magical connection string is from
# https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azurite?tabs=visual-studio#http-connection-strings
run: |
curl -sL https://aka.ms/InstallAzureCLIDeb | bash
az storage container create -n test-bucket --connection-string 'DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://azurite:10000/devstoreaccount1;QueueEndpoint=http://azurite:10001/devstoreaccount1;'
docker run -d -p 10000:10000 -p 10001:10001 -p 10002:10002 mcr.microsoft.com/azure-storage/azurite
az storage container create -n test-bucket --connection-string 'DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://localhost:10000/devstoreaccount1;QueueEndpoint=http://localhost:10001/devstoreaccount1;'

- name: Setup Rust toolchain
run: |
Expand All @@ -139,7 +118,7 @@ jobs:
OBJECT_STORE_AWS_DEFAULT_REGION: "us-east-1"
OBJECT_STORE_AWS_ACCESS_KEY_ID: test
OBJECT_STORE_AWS_SECRET_ACCESS_KEY: test
OBJECT_STORE_AWS_ENDPOINT: http://localstack:4566
OBJECT_STORE_AWS_ENDPOINT: http://localhost:4566
run: |
# run tests
cargo test -p object_store --features=aws,azure,gcp
21 changes: 0 additions & 21 deletions object_store/src/gcp/mod.rs
Expand Up @@ -782,20 +782,6 @@ impl GoogleCloudStorageBuilder {
self
}

/// Use the specified http [`Client`] (defaults to [`Client::new`])
///
/// This allows you to set custom client options such as allowing
/// non secure connections or custom headers.
///
/// NOTE: Currently only available in `test`s to facilitate
/// testing, to avoid leaking details and preserve our ability to
/// make changes to the implementation.
#[cfg(test)]
pub fn with_client(mut self, client: Client) -> Self {
self.client = Some(client);
self
}

/// Configure a connection to Google Cloud Storage, returning a
/// new [`GoogleCloudStorage`] and consuming `self`
pub fn build(self) -> Result<GoogleCloudStorage> {
Expand Down Expand Up @@ -923,13 +909,6 @@ mod test {
env::var("GOOGLE_SERVICE_ACCOUNT")
.expect("already checked GOOGLE_SERVICE_ACCOUNT")
)
.with_client(
// ignore HTTPS errors in tests so we can use fake-gcs server
Client::builder()
.danger_accept_invalid_certs(true)
.build()
.expect("Error creating http client for testing")
)
}
}};
}
Expand Down