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

add HAB_FUNC_TEST end to end overrides for builder-worker #1735

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 31 additions & 23 deletions components/builder-worker/src/runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,26 +315,27 @@ impl Runner {
self.check_cancel(tx).await?;
let mut section = streamer.start_section(Section::PublishPackage)?;

match post_process(&mut archive,
&self.workspace,
&self.config,
&self.bldr_token,
&mut self.logger).await
{
Ok(_) => (),
Err(err) => {
let msg = format!("Failed post processing for {}, err={:?}",
self.workspace.job.get_project().get_name(),
err);
streamer.println_stderr(msg)?;
self.fail(net::err(ErrCode::POST_PROCESSOR, "wk:run:postprocess"));
tx.send(self.job().clone())
.await
.map_err(Error::MpscAsync)?;
return Err(err);
if env::var_os("HAB_FUNC_TEST").is_none() {
match post_process(&mut archive,
&self.workspace,
&self.config,
&self.bldr_token,
&mut self.logger).await
{
Ok(_) => (),
Err(err) => {
let msg = format!("Failed post processing for {}, err={:?}",
self.workspace.job.get_project().get_name(),
err);
streamer.println_stderr(msg)?;
self.fail(net::err(ErrCode::POST_PROCESSOR, "wk:run:postprocess"));
tx.send(self.job().clone())
.await
.map_err(Error::MpscAsync)?;
return Err(err);
}
}
}

section.end()?;
Ok(())
}
Expand Down Expand Up @@ -399,11 +400,18 @@ impl Runner {
async fn fetch_origin_secret_key(
&self)
-> std::result::Result<std::path::PathBuf, builder_core::Error> {
let res = self.depot_cli
.fetch_origin_secret_key(self.job().origin(),
&self.bldr_token,
self.workspace.key_path())
.await;
let bldr_token = if env::var_os("HAB_FUNC_TEST").is_some() {
"bobo".to_string()
} else {
self.bldr_token.to_string()
};

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can avoid all of this repetitive code by creating a token variable and populating it with either bobo or the bldr_token depending on HAB_FUNC_TEST

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

let res =
self.depot_cli
.fetch_origin_secret_key(self.job().origin(),
&bldr_token,
self.workspace.key_path())
.await;
if res.is_err() {
debug!("Failed to fetch origin secret key, err={:?}", res);
};
Expand Down