Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

Commit

Permalink
Always use adm node as ntp server
Browse files Browse the repository at this point in the history
The integration tests currently use the ntp server on the host when
running docker and the adm vm when running with RPMs.

Now that docker runs within the adm vm, we should always be able to use
adm to run the ntp server.

Signed-off-by: Joe Grund <jgrund@whamcloud.io>
  • Loading branch information
jgrund committed Dec 4, 2020
1 parent 57a1716 commit a69ee8a
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 84 deletions.
1 change: 0 additions & 1 deletion iml-system-docker-tests/tests/ldiskfs_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ async fn test_docker_ldiskfs_setup() -> Result<(), TestError> {
("base_client".into(), config.client_servers()),
],
test_type: TestType::Docker,
ntp_server: NtpServer::HostOnly,
..config
};

Expand Down
1 change: 0 additions & 1 deletion iml-system-docker-tests/tests/stratagem_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ async fn test_docker_stratagem_setup() -> Result<(), TestError> {
use_stratagem: true,
branding: iml_wire_types::Branding::DDN(iml_wire_types::DdnBranding::Exascaler),
test_type: TestType::Docker,
ntp_server: NtpServer::HostOnly,
..config
};

Expand Down
1 change: 0 additions & 1 deletion iml-system-docker-tests/tests/zfs_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ async fn test_docker_zfs_setup() -> Result<(), TestError> {
("base_client".into(), config.client_servers()),
],
test_type: TestType::Docker,
ntp_server: NtpServer::HostOnly,
fs_type: FsType::Zfs,
..config
};
Expand Down
51 changes: 13 additions & 38 deletions iml-system-test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,12 @@ impl From<std::io::Error> for TestError {
}
}

#[derive(PartialEq, Clone)]
#[derive(PartialEq, Clone, Copy)]
pub enum TestType {
Rpm,
Docker,
}

#[derive(Clone)]
pub enum NtpServer {
HostOnly,
Adm,
}

pub enum TestState {
Bare,
LustreRpmsInstalled,
Expand Down Expand Up @@ -180,7 +174,6 @@ pub struct Config {
pub use_stratagem: bool,
pub branding: Branding,
pub test_type: TestType,
pub ntp_server: NtpServer,
pub fs_type: FsType,
}

Expand Down Expand Up @@ -213,7 +206,6 @@ impl Default for Config {
use_stratagem: false,
branding: Branding::default(),
test_type: TestType::Rpm,
ntp_server: NtpServer::Adm,
fs_type: FsType::Ldiskfs,
}
}
Expand Down Expand Up @@ -280,38 +272,21 @@ impl Config {
.collect()
}
pub fn get_setup_config(&self) -> String {
match &self.test_type {
TestType::Rpm => format!(
r#"USE_STRATAGEM={}
format!(
r#"USE_STRATAGEM={}
BRANDING={}
LOG_LEVEL=10
RUST_LOG=debug
NTP_SERVER_HOSTNAME=adm.local
"#,
if self.use_stratagem { "True" } else { "False" },
self.branding.to_string()
),
TestType::Docker => format!(
r#"USE_STRATAGEM={}
BRANDING={}
LOG_LEVEL=10
RUST_LOG=debug
NTP_SERVER_HOSTNAME=10.73.10.1
"#,
self.use_stratagem,
self.branding.to_string()
),
}
if self.use_stratagem { "True" } else { "False" },
self.branding.to_string()
)
}
}

pub async fn wait_for_ntp(config: &Config) -> Result<(), TestError> {
match config.test_type {
TestType::Rpm => ssh::wait_for_ntp_for_adm(&config.storage_server_ips()).await?,
TestType::Docker => {
ssh::wait_for_ntp_for_host_only_if(&config.storage_server_ips()).await?
}
};
ssh::wait_for_ntp(&config.storage_server_ips()).await?;

Ok(())
}
Expand Down Expand Up @@ -393,12 +368,12 @@ pub async fn setup_bare(config: Config) -> Result<Config, TestError> {
.checked_status()
.await?;

match config.ntp_server {
NtpServer::HostOnly => {
ssh::configure_ntp_for_host_only_if(&config.storage_server_ips()).await?
}
NtpServer::Adm => ssh::configure_ntp_for_adm(&config.storage_server_ips()).await?,
};
ssh::configure_ntp(
config.test_type,
&config.manager_ip,
&config.storage_server_ips(),
)
.await?;

vagrant::halt()
.await?
Expand Down
22 changes: 8 additions & 14 deletions iml-system-test-utils/src/ssh.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2020 DDN. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
use crate::{Config, TestError};
use crate::{Config, TestError, TestType};
use futures::future::{try_join_all, TryFutureExt};
use iml_cmd::{CheckedChildExt, CheckedCommandExt};
use iml_graphql_queries::Query;
Expand Down Expand Up @@ -198,25 +198,19 @@ pub async fn yum_update<'a, 'b>(hosts: &'b [&'a str]) -> Result<Vec<(&'a str, Ou
ssh_exec_parallel(hosts, "yum clean metadata; yum update -y").await
}

pub async fn configure_ntp_for_host_only_if<'a, 'b>(
pub async fn configure_ntp<'a, 'b>(
test_type: TestType,
manager: &str,
hosts: &'b [&'a str],
) -> Result<Vec<(&'a str, Output)>, TestError> {
ssh_script_parallel(hosts, "scripts/configure_ntp.sh", &["10.73.10.1"]).await
}
if test_type == TestType::Docker {
ssh_script(manager, "scripts/install_ntp.sh", &[]).await?;
}

pub async fn configure_ntp_for_adm<'a, 'b>(
hosts: &'b [&'a str],
) -> Result<Vec<(&'a str, Output)>, TestError> {
ssh_script_parallel(hosts, "scripts/configure_ntp.sh", &["adm.local"]).await
}

pub async fn wait_for_ntp_for_host_only_if<'a, 'b>(
hosts: &'b [&'a str],
) -> Result<Vec<(&'a str, Output)>, TestError> {
ssh_script_parallel(hosts, "scripts/wait_for_ntp.sh", &["10.73.10.1"]).await
}

pub async fn wait_for_ntp_for_adm<'a, 'b>(
pub async fn wait_for_ntp<'a, 'b>(
hosts: &'b [&'a str],
) -> Result<Vec<(&'a str, Output)>, TestError> {
ssh_script_parallel(hosts, "scripts/wait_for_ntp.sh", &["adm.local"]).await
Expand Down
28 changes: 1 addition & 27 deletions vagrant/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,8 @@ Vagrant.configure('2') do |config|

configure_ntp mds

configure_ntp_docker mds

wait_for_ntp mds

wait_for_ntp_docker mds

if i == 1
mds.vm.provision 'create-pools',
type: 'shell',
Expand Down Expand Up @@ -564,12 +560,8 @@ Vagrant.configure('2') do |config|

configure_ntp oss

configure_ntp_docker oss

wait_for_ntp oss

wait_for_ntp_docker oss

if i == 1
oss.vm.provision 'create-pools',
type: 'shell',
Expand Down Expand Up @@ -865,8 +857,6 @@ Vagrant.configure('2') do |config|

configure_ntp c

configure_ntp_docker c

provision_clush c

c.vm.provision 'install-iml-local',
Expand Down Expand Up @@ -1162,7 +1152,7 @@ end

def configure_docker_network(config)
config.vm.provision 'configure-docker-network', type: 'shell', run: 'never', inline: <<-SHELL
echo "10.73.10.1 nginx" >> /etc/hosts
echo "10.73.10.10 nginx" >> /etc/hosts
SHELL
end

Expand All @@ -1174,14 +1164,6 @@ def configure_ntp(config)
args: ["adm.local"]
end

def configure_ntp_docker(config)
config.vm.provision 'configure-ntp-docker',
type: 'shell',
run: 'never',
path: 'scripts/configure_ntp.sh',
args: ["10.73.10.1"]
end

def wait_for_ntp(config)
config.vm.provision 'wait-for-ntp',
type: 'shell',
Expand All @@ -1190,14 +1172,6 @@ def wait_for_ntp(config)
args: ["adm.local"]
end

def wait_for_ntp_docker(config)
config.vm.provision 'wait-for-ntp-docker',
type: 'shell',
run: 'never',
path: 'scripts/wait_for_ntp.sh',
args: ["10.73.10.1"]
end

def create_iml_diagnostics(config)
config.vm.provision 'create-iml-diagnostics',
type: 'shell',
Expand Down
3 changes: 2 additions & 1 deletion vagrant/scripts/install_iml_docker_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ version: "3.7"
services:
job-scheduler:
extra_hosts:
- "adm.local:10.73.10.10"
- "mds1.local:10.73.10.11"
- "mds2.local:10.73.10.12"
- "oss1.local:10.73.10.21"
- "oss2.local:10.73.10.22"
- "client1.local:10.73.10.31"
environment:
- "NTP_SERVER_HOSTNAME=10.73.10.1"
- "NTP_SERVER_HOSTNAME=adm.local"
iml-warp-drive:
environment:
- RUST_LOG=debug
Expand Down
3 changes: 2 additions & 1 deletion vagrant/scripts/install_iml_docker_repouri.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ version: "3.7"
services:
job-scheduler:
extra_hosts:
- "adm.local:10.73.10.10"
- "mds1.local:10.73.10.11"
- "mds2.local:10.73.10.12"
- "oss1.local:10.73.10.21"
- "oss2.local:10.73.10.22"
- "client1.local:10.73.10.31"
environment:
- "NTP_SERVER_HOSTNAME=10.73.10.1"
- "NTP_SERVER_HOSTNAME=adm.local"
iml-warp-drive:
environment:
- RUST_LOG=debug
Expand Down
11 changes: 11 additions & 0 deletions vagrant/scripts/install_ntp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

systemctl disable --now chronyd
yum install -y ntp
# delete all server entries
sed -i -e "/^server /d" /etc/ntp.conf
# Append ntp server address
sed -i -e "$ a server 127.127.1.0" /etc/ntp.conf
sed -i -e "$ a fudge 127.127.1.0 stratum 10" /etc/ntp.conf

systemctl enable --now ntpd.service

0 comments on commit a69ee8a

Please sign in to comment.