Skip to content

Commit

Permalink
Fixing failing tests
Browse files Browse the repository at this point in the history
Signed-off-by: Vacha Shah <vachshah@amazon.com>
  • Loading branch information
VachaShah committed Jun 23, 2022
1 parent 1d32ca5 commit 9bbb8a8
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 130 deletions.
2 changes: 1 addition & 1 deletion .ci/test-matrix.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---

STACK_VERSION:
- 1.x-SNAPSHOT
- 2.x-SNAPSHOT

RUST_TOOLCHAIN:
- latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
name: Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
entry:
- { cluster: 'opendistro', version: '1.13.3', secured: 'true' }
Expand Down
41 changes: 41 additions & 0 deletions yaml_test_runner/skip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,44 @@ tests:
# The use of an invalid window interval results in a 400 response which looks like
# it suppresses the sending of deprecation headers
- "Bad window deprecated interval"

free/indices.put_mapping/10_basic.yml:
# The type parameter is removed in 2.0
- "Put mappings with explicit _doc type"
- "Put mappings with explicit _doc type bwc"

free/cat.health/10_basic.yml:
# Should be fixed after inclusive naming changes - master -> cluster_manager
- "Help"

free/cat.nodes/10_basic.yml:
# Should be fixed after inclusive naming changes - master -> cluster_manager
- "Test cat nodes output"

free/cluster.health/10_basic.yml:
# Should be fixed after inclusive naming changes - master -> cluster_manager
- "Get cluster health has same value for discovered_master and discovered_cluster_manager"
- "cluster health with closed index (pre 7.2.0)"

free/cluster.reroute/10_basic.yml:
# Should be fixed after inclusive naming changes - master -> cluster_manager
- "Cluster reroute returns cluster_manager_node"

free/cluster.reroute/20_response_filtering.yml:
# Should be fixed after inclusive naming changes - master -> cluster_manager
- "Filter the cluster reroute by cluster_manager_node only should work"

free/cluster.state/10_basic.yml:
# Should be fixed after inclusive naming changes - master -> cluster_manager
- "Get cluster state returns cluster_manager_node"

free/cluster.state/20_filtering.yml:
# Should be fixed after inclusive naming changes - master -> cluster_manager
- "Filter the cluster state by cluster_manager_node only should work"

free/cluster.stats/10_basic.yml:
# Should be fixed after inclusive naming changes - master -> cluster_manager
- "get cluster stats nodes count with both master and cluster_manager"

free/search/230_interval_query.yml:
- "*"
4 changes: 2 additions & 2 deletions yaml_test_runner/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use std::{
fs,
fs::{File, OpenOptions},
io::Write,
path::{Component, Path, PathBuf},
path::{Path, PathBuf},
};
use yaml_rust::{Yaml, YamlLoader};

Expand Down Expand Up @@ -146,7 +146,7 @@ impl<'a> YamlTests<'a> {

quote! {
#![allow(unused_imports, unused_variables, dead_code)]
use crate::common::{client, macros, transform};
use crate::common::{client, macros};
use opensearch::*;
use opensearch::http::{
headers::{HeaderName, HeaderValue},
Expand Down
2 changes: 1 addition & 1 deletion yaml_test_runner/src/step/do.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl Do {
tokens.append(quote! {
let allowed_warnings = vec![#(#allowed),*];
let warnings: Vec<&str> = response.warning_headers()
.filter(!allowed_warnings.iter().any(|a| w.contains(a)))
.filter(|w| !allowed_warnings.iter().any(|a| w.contains(a)))
.collect();
assert_warnings_is_empty!(warnings);
});
Expand Down
128 changes: 2 additions & 126 deletions yaml_test_runner/tests/common/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,34 +31,22 @@
use once_cell::sync::Lazy;
use opensearch::{
auth::Credentials,
cat::CatTemplatesParts,
cert::CertificateValidation,
cluster::ClusterHealthParts,
http::{
response::Response,
transport::{SingleNodeConnectionPool, TransportBuilder},
Method, StatusCode,
},
ilm::IlmRemovePolicyParts,
indices::{
IndicesDeleteIndexTemplateParts, IndicesDeleteParts, IndicesDeleteTemplateParts,
IndicesRefreshParts,
IndicesDeleteParts,
},
params::{ExpandWildcards, WaitForStatus},
security::{
SecurityDeletePrivilegesParts, SecurityDeleteRoleParts, SecurityDeleteUserParts,
SecurityGetPrivilegesParts, SecurityGetRoleParts, SecurityGetUserParts,
SecurityPutUserParts,
},
snapshot::{SnapshotDeleteParts, SnapshotDeleteRepositoryParts},
tasks::TasksCancelParts,
transform::{
TransformDeleteTransformParts, TransformGetTransformParts, TransformStopTransformParts,
},
watcher::WatcherDeleteWatchParts,
Error, OpenSearch, DEFAULT_ADDRESS,
};
use serde_json::{json, Value};
use serde_json::{Value};
use std::ops::Deref;
use sysinfo::SystemExt;
use url::Url;
Expand Down Expand Up @@ -193,18 +181,6 @@ pub async fn delete_snapshots(client: &OpenSearch) -> Result<(), Error> {
Ok(())
}

async fn wait_for_yellow_status(client: &OpenSearch) -> Result<(), Error> {
let cluster_health = client
.cluster()
.health(ClusterHealthParts::None)
.wait_for_status(WaitForStatus::Yellow)
.send()
.await?;

assert_response_success!(cluster_health);
Ok(())
}

async fn delete_indices(client: &OpenSearch) -> Result<(), Error> {
let delete_response = client
.indices()
Expand All @@ -220,103 +196,3 @@ async fn delete_indices(client: &OpenSearch) -> Result<(), Error> {
assert_response_success!(delete_response);
Ok(())
}

async fn cancel_tasks(client: &OpenSearch) -> Result<(), Error> {
let rollup_response = client.tasks().list().send().await?.json::<Value>().await?;

for (_node_id, nodes) in rollup_response["nodes"].as_object().unwrap() {
for (task_id, task) in nodes["tasks"].as_object().unwrap() {
if let Some(b) = task["cancellable"].as_bool() {
if b {
let response = client
.tasks()
.cancel(TasksCancelParts::TaskId(task_id))
.send()
.await?;

assert_response_success!(response);
}
}
}
}

Ok(())
}

async fn delete_users(client: &OpenSearch) -> Result<(), Error> {
let users_response = client
.security()
.get_user(SecurityGetUserParts::None)
.send()
.await?
.json::<Value>()
.await?;

for (k, v) in users_response.as_object().unwrap() {
if let Some(b) = v["metadata"]["_reserved"].as_bool() {
if !b {
let response = client
.security()
.delete_user(SecurityDeleteUserParts::Username(k))
.send()
.await?;

assert_response_success!(response);
}
}
}

Ok(())
}

async fn delete_roles(client: &OpenSearch) -> Result<(), Error> {
let roles_response = client
.security()
.get_role(SecurityGetRoleParts::None)
.send()
.await?
.json::<Value>()
.await?;

for (k, v) in roles_response.as_object().unwrap() {
if let Some(b) = v["metadata"]["_reserved"].as_bool() {
if !b {
let response = client
.security()
.delete_role(SecurityDeleteRoleParts::Name(k))
.send()
.await?;

assert_response_success!(response);
}
}
}

Ok(())
}

async fn delete_privileges(client: &OpenSearch) -> Result<(), Error> {
let privileges_response = client
.security()
.get_privileges(SecurityGetPrivilegesParts::None)
.send()
.await?
.json::<Value>()
.await?;

for (k, v) in privileges_response.as_object().unwrap() {
if let Some(b) = v["metadata"]["_reserved"].as_bool() {
if !b {
let response = client
.security()
.delete_privileges(SecurityDeletePrivilegesParts::ApplicationName(k, "_all"))
.send()
.await?;

assert_response_success!(response);
}
}
}

Ok(())
}

0 comments on commit 9bbb8a8

Please sign in to comment.