Skip to content

Commit

Permalink
Update CI to run cargo make test fails out of the box (opensearch-pro…
Browse files Browse the repository at this point in the history
…ject#120)

Signed-off-by: Andriy Redko <[email protected]>
  • Loading branch information
reta authored Feb 3, 2023
1 parent a7db67b commit d968176
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 21 deletions.
1 change: 0 additions & 1 deletion .ci/functions/imports.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ if [[ -z $opensearch_node_name ]]; then
export ssl_ca="${script_path}/certs/ca.crt"
export ssl_cert_pem="${script_path}/certs/testnode.pem"
export ssl_key_pem="${script_path}/certs/testnode-key.pem"
export ssl_ca_pem="${script_path}/certs/ca.pem"

echo -e "\033[34;1mINFO:\033[0m Running $CLUSTER $STACK_VERSION\033[0m"
fi
Expand Down
10 changes: 6 additions & 4 deletions .ci/opensearch/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
ARG STACK_VERSION
FROM "opensearchproject/opensearch:$STACK_VERSION"

USER root
COPY root-ca.pem /usr/share/opensearch/config/root-ca.pem
RUN /usr/share/opensearch/opensearch-onetime-setup.sh
COPY esnode.pem /usr/share/opensearch/config/esnode.pem
COPY esnode-key.pem /usr/share/opensearch/config/esnode-key.pem
RUN chmod a+wr /usr/share/opensearch/config/*pem

USER opensearch
RUN echo "appender.header_warning.type = HeaderWarningAppender" >> /usr/share/opensearch/config/log4j2.properties
RUN echo "appender.header_warning.name = header_warning" >> /usr/share/opensearch/config/log4j2.properties
RUN echo "logger.deprecation.name = org.opensearch.deprecation" >> /usr/share/opensearch/config/log4j2.properties
RUN echo "logger.deprecation.level = deprecation" >> /usr/share/opensearch/config/log4j2.properties
RUN echo "logger.deprecation.appenderRef.header_warning.ref = header_warning" >> /usr/share/opensearch/config/log4j2.properties
5 changes: 4 additions & 1 deletion .ci/run-opensearch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ END
echo 'cluster is' $CLUSTER

# Copy certificates and keys
cp $ssl_ca_pem root-ca.pem
cp $ssl_cert_pem esnode.pem
cp $ssl_key_pem esnode-key.pem

Expand All @@ -82,6 +81,10 @@ END
--build-arg STACK_VERSION=$STACK_VERSION \
--tag=$CLUSTER_TAG \
.

# Cleanup certificates and keys
rm esnode.pem
rm esnode-key.pem
else
CLUSTER_TAG=$CLUSTER_TAG:test
fi
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,19 @@ jobs:
components: rustfmt, clippy, llvm-tools-preview
- name: Setup Tools
run: cargo install grcov cargo-make
- name: Run Tests
- name: Run Unit Tests
run: |
cargo make unittest
- name: Prepare for integration tests
run: |
CLEANUP="false" DETACH="true" ./.ci/run-opensearch.sh
- name: Run Integration Tests
run: |
cargo make test
- name: Cleanup after integration tests
if: always()
run: |
CLEANUP="true" DETACH="false" ./.ci/run-opensearch.sh
- name: Upload Coverage Data
uses: codecov/codecov-action@v3
with:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

### Fixed
- [BUG] cargo make test fails out of the box ([#117](https://github.com/opensearch-project/opensearch-rs/pull/117))
- Update CI to run cargo make test fails out of the box ([#120](https://github.com/opensearch-project/opensearch-rs/pull/120))

### Security

Expand Down
8 changes: 4 additions & 4 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ STACK_VERSION = { value = "latest", condition = { env_not_set = ["STACK_VERSION"
CARGO_MAKE_CARGO_PUBLISH_FLAGS = "--dry-run"
# RUST_BACKTRACE is set to "full" in cargo make's builtin makefiles/stable.toml
RUST_BACKTRACE = { value = "0", condition = { env_not_set = ["RUST_BACKTRACE"]}}
OPENSEARCH_PROTOCOL_SUFFIX = { value = "s", condition = { env_true = ["SECURE_INTEGRATION"] }}
OPENSEARCH_URL = { value = "http${OPENSEARCH_PROTOCOL_SUFFIX}://localhost:9200", condition = { env_not_set = ["OPENSEARCH_URL"] }}
OPENSEARCH_PROTOCOL = { source = "${SECURE_INTEGRATION}", default_value = "https", mapping = { "false" = "http", "true" = "https" }}
OPENSEARCH_URL = { value = "${OPENSEARCH_PROTOCOL}://localhost:9200", condition = { env_not_set = ["OPENSEARCH_URL"] }}

[tasks.run-yaml-test-runner]
category = "OpenSearch"
Expand Down Expand Up @@ -55,7 +55,7 @@ category = "OpenSearch"
private = true
condition = { env_set = [ "OPENSEARCH_URL" ]}
command = "cargo"
args = ["test", "--features", "_integration", "-p", "opensearch"]
args = ["test", "-p", "opensearch"]
dependencies = ["start-opensearch"]

[tasks.run-api-generator]
Expand Down Expand Up @@ -158,7 +158,7 @@ run_task = "stop-opensearch"
[tasks.run-unittest]
private = true
command = "cargo"
args = ["test"]
args = ["test", "--lib", "--bins"]

[tasks.unittest]
category = "OpenSearch"
Expand Down
3 changes: 0 additions & 3 deletions opensearch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ rustls-tls = ["reqwest/rustls-tls"]
# AWS SigV4 Auth support
aws-auth = ["aws-credential-types", "aws-sigv4", "aws-types"]

# Integration tests against an actual instance of OpenSearch
_integration = []

[dependencies]
base64 = "^0.21"
bytes = "^1.0"
Expand Down
5 changes: 1 addition & 4 deletions opensearch/tests/cert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
//!
//!
//! DETACH=true .ci/run-opensearch.sh
#![cfg(all(
feature = "_integration",
any(feature = "native-tls", feature = "rustls-tls")
))]
#![cfg(any(feature = "native-tls", feature = "rustls-tls"))]

pub mod common;
use common::*;
Expand Down
1 change: 0 additions & 1 deletion opensearch/tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
#![cfg(feature = "_integration")]

pub mod common;
use common::*;
Expand Down
2 changes: 0 additions & 2 deletions opensearch/tests/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
* GitHub history for details.
*/

#![cfg(feature = "_integration")]

pub mod common;
use common::*;

Expand Down

0 comments on commit d968176

Please sign in to comment.