Skip to content

Commit b658d7f

Browse files
committed
Update ci shell scripts
This commit updates the ci shell scripts in line with the changes that have been made to the PowerShell scripts regarding - RUST_BACKTRACE - SSL certs used - defaulting to default distribution in tests - testing all features with cargo test It also fixes an issue where there a differences between macOS and linux (specifically, the centOS docker image used in ci tests) regarding - expected error messages for failed tests - expected outcome when configuring the client with full and certificate validation (cherry picked from commit 877719e)
1 parent 6303075 commit b658d7f

File tree

4 files changed

+72
-37
lines changed

4 files changed

+72
-37
lines changed

.ci/run-elasticsearch.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ CLUSTER_NAME=${CLUSTER_NAME-${moniker}${suffix}}
2323
HTTP_PORT=${HTTP_PORT-9200}
2424

2525
ELASTIC_PASSWORD=${ELASTIC_PASSWORD-changeme}
26-
SSL_CERT=${SSL_CERT-"${SCRIPT_PATH}/certs/testnode.crt"}
27-
SSL_KEY=${SSL_KEY-"${SCRIPT_PATH}/certs/testnode.key"}
26+
SSL_CERT=${SSL_CERT-"${SCRIPT_PATH}/certs/testnode_san.crt"}
27+
SSL_KEY=${SSL_KEY-"${SCRIPT_PATH}/certs/testnode_san.key"}
2828
SSL_CA=${SSL_CA-"${SCRIPT_PATH}/certs/ca.crt"}
2929
SSL_CA_PEM=${SSL_CA-"${SCRIPT_PATH}/certs/ca.pem"}
3030

.ci/run-tests

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ if [[ -z $ELASTICSEARCH_VERSION ]]; then
66
fi
77
set -euxo pipefail
88

9-
TEST_SUITE=${TEST_SUITE-oss}
10-
NODE_NAME=instance
9+
TEST_SUITE=${TEST_SUITE-xpack}
10+
CARGO_TEST_FLAGS=${CARGO_TEST_FLAGS---all-features}
11+
NODE_NAME=es1
1112

1213
elasticsearch_image=elasticsearch
1314
elasticsearch_url=https://elastic:changeme@${NODE_NAME}:9200
@@ -45,8 +46,12 @@ ELASTICSEARCH_VERSION=${elasticsearch_image}:${ELASTICSEARCH_VERSION} \
4546

4647
echo -e "\033[1m>>>>> Build [elastic/elasticsearch-rs container] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"
4748

48-
# TODO: move to stable once elasticsearch-rs compiles on stable
4949
RUST_VERSION=${RUST_VERSION-nightly}
50+
RUST_BACKTRACE=${RUST_BACKTRACE-}
51+
toolchain=""
52+
if [[ "${RUST_VERSION}" == "nightly" ]]; then
53+
toolchain="+nightly"
54+
fi
5055

5156
docker build --file .ci/DockerFile --tag elastic/elasticsearch-rs .
5257

@@ -60,4 +65,4 @@ docker run \
6065
--name elasticsearch-rs \
6166
--rm \
6267
elastic/elasticsearch-rs \
63-
cargo test
68+
cargo ${toolchain} test "${CARGO_TEST_FLAGS}"

elasticsearch/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ failure = "0.1.5"
3636
futures = "0.3.1"
3737
http = "0.2"
3838
hyper = { version = "0.13", default-features = false, features = ["tcp", "stream"] }
39+
os_type = "2.2"
3940
sysinfo = "0.12.0"
4041
tokio = { version = "0.2.0", default-features = false, features = ["macros", "tcp", "time"] }
4142

elasticsearch/tests/cert.rs

Lines changed: 60 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
extern crate os_type;
2+
13
pub mod common;
24
use common::*;
35

46
use elasticsearch::cert::{Certificate, CertificateValidation};
7+
use os_type::OSType;
58

69
// TODO: These tests require a cluster configured with Security. Figure out best way to surface this e.g. test category, naming convention, etc.
710

@@ -13,7 +16,11 @@ fn expected_error_message() -> String {
1316
if cfg!(windows) {
1417
"terminated in a root certificate which is not trusted by the trust provider".to_string()
1518
} else {
16-
"unable to get local issuer certificate".to_string()
19+
let os = os_type::current_platform();
20+
match os.os_type {
21+
OSType::OSX => "The certificate was not trusted".to_string(),
22+
_ => "unable to get local issuer certificate".to_string()
23+
}
1724
}
1825
}
1926

@@ -87,21 +94,32 @@ async fn full_certificate_validation() -> Result<(), failure::Error> {
8794
client::create_default_builder().cert_validation(CertificateValidation::Full(cert));
8895
let client = client::create(builder);
8996
let result = client.ping().send().await;
90-
match result {
91-
Ok(response) => Err(failure::err_msg(format!(
92-
"Expected error but response was {}",
93-
response.status_code()
94-
))),
95-
Err(e) => {
96-
let expected = "unable to get local issuer certificate";
97-
let actual = e.to_string();
98-
assert!(
99-
actual.contains(expected),
100-
"Expected error message to contain '{}' but was '{}'",
101-
expected,
102-
actual
103-
);
104-
Ok(())
97+
let os_type = os_type::current_platform();
98+
match os_type.os_type {
99+
OSType::OSX => {
100+
match result {
101+
Ok(_) => Ok(()),
102+
Err(e) => Err(failure::err_msg(e.to_string())),
103+
}
104+
},
105+
_ => {
106+
match result {
107+
Ok(response) => Err(failure::err_msg(format!(
108+
"Expected error but response was {}",
109+
response.status_code()
110+
))),
111+
Err(e) => {
112+
let expected = expected_error_message();
113+
let actual = e.to_string();
114+
assert!(
115+
actual.contains(&expected),
116+
"Expected error message to contain '{}' but was '{}'",
117+
expected,
118+
actual
119+
);
120+
Ok(())
121+
}
122+
}
105123
}
106124
}
107125
}
@@ -128,21 +146,32 @@ async fn certificate_certificate_validation() -> Result<(), failure::Error> {
128146
client::create_default_builder().cert_validation(CertificateValidation::Certificate(cert));
129147
let client = client::create(builder);
130148
let result = client.ping().send().await;
131-
match result {
132-
Ok(response) => Err(failure::err_msg(format!(
133-
"Expected error but response was {}",
134-
response.status_code()
135-
))),
136-
Err(e) => {
137-
let expected = "unable to get local issuer certificate";
138-
let actual = e.to_string();
139-
assert!(
140-
actual.contains(expected),
141-
"Expected error message to contain '{}' but was '{}'",
142-
expected,
143-
actual
144-
);
145-
Ok(())
149+
let os_type = os_type::current_platform();
150+
match os_type.os_type {
151+
OSType::OSX => {
152+
match result {
153+
Ok(_) => Ok(()),
154+
Err(e) => Err(failure::err_msg(e.to_string())),
155+
}
156+
},
157+
_ => {
158+
match result {
159+
Ok(response) => Err(failure::err_msg(format!(
160+
"Expected error but response was {}",
161+
response.status_code()
162+
))),
163+
Err(e) => {
164+
let expected = expected_error_message();
165+
let actual = e.to_string();
166+
assert!(
167+
actual.contains(&expected),
168+
"Expected error message to contain '{}' but was '{}'",
169+
expected,
170+
actual
171+
);
172+
Ok(())
173+
}
174+
}
146175
}
147176
}
148177
}

0 commit comments

Comments
 (0)