-
Notifications
You must be signed in to change notification settings - Fork 15
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
Write Integration tests #5
Conversation
Warning Rate Limit Exceeded@apoorvsadana has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 40 minutes and 3 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. WalkthroughThe recent changes introduce extensive testing support and dependency enhancements across multiple crates in the project. Key updates include adding Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
Outside diff range and nitpick comments (1)
crates/orchestrator/src/config.rs (1)
30-45
: Initialization of the application configuration is robust, using environment variables effectively. Consider using a trait for the DA client as suggested in previous reviews for better modularity.
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
Cargo.lock
is excluded by!**/*.lock
Files selected for processing (20)
- Cargo.toml (1 hunks)
- crates/da_clients/da-client-interface/Cargo.toml (1 hunks)
- crates/da_clients/da-client-interface/src/lib.rs (2 hunks)
- crates/orchestrator/Cargo.toml (3 hunks)
- crates/orchestrator/src/config.rs (3 hunks)
- crates/orchestrator/src/database/mod.rs (2 hunks)
- crates/orchestrator/src/jobs/da_job/mod.rs (1 hunks)
- crates/orchestrator/src/jobs/mod.rs (1 hunks)
- crates/orchestrator/src/jobs/types.rs (2 hunks)
- crates/orchestrator/src/lib.rs (1 hunks)
- crates/orchestrator/src/main.rs (1 hunks)
- crates/orchestrator/src/queue/mod.rs (1 hunks)
- crates/orchestrator/src/tests/common/constants.rs (1 hunks)
- crates/orchestrator/src/tests/common/mod.rs (1 hunks)
- crates/orchestrator/src/tests/database/mod.rs (1 hunks)
- crates/orchestrator/src/tests/jobs/da_job/mod.rs (1 hunks)
- crates/orchestrator/src/tests/jobs/mod.rs (1 hunks)
- crates/orchestrator/src/tests/mod.rs (1 hunks)
- crates/orchestrator/src/tests/queue/mod.rs (1 hunks)
- crates/orchestrator/src/tests/server/mod.rs (1 hunks)
Files skipped from review due to trivial changes (7)
- Cargo.toml
- crates/da_clients/da-client-interface/Cargo.toml
- crates/orchestrator/src/main.rs
- crates/orchestrator/src/tests/common/constants.rs
- crates/orchestrator/src/tests/database/mod.rs
- crates/orchestrator/src/tests/mod.rs
- crates/orchestrator/src/tests/queue/mod.rs
Additional comments not posted (15)
crates/orchestrator/src/lib.rs (1)
1-19
: Module declarations are well-organized and correctly scoped.crates/orchestrator/src/queue/mod.rs (1)
8-14
: Introduction ofautomock
forQueueProvider
is a good practice for enabling easier testing.crates/da_clients/da-client-interface/src/lib.rs (1)
Line range hint
4-17
: Proper use ofautomock
onDaClient
trait enhances testability by allowing the creation of mock objects.crates/orchestrator/Cargo.toml (1)
23-29
: Dependencies are correctly added and versioned. The addition ofmockall
andstarknet-core
is crucial for mocking and blockchain interactions respectively.Also applies to: 43-46
crates/orchestrator/src/database/mod.rs (1)
Line range hint
4-20
: Introduction ofautomock
for theDatabase
trait is beneficial for testing, allowing the creation of mock objects.crates/orchestrator/src/tests/server/mod.rs (3)
13-32
: Setup function for the server looks robust and well-handled.
34-51
: Health endpoint test is comprehensive and correctly asserts both the status code and response body.
53-57
: Consumer initialization test is concise and effectively checks the operation's success.
[APROVED]crates/orchestrator/src/tests/common/mod.rs (2)
25-47
: Theinit_config
function is well-designed, providing flexible test setup with optional mock components.
49-68
: Job item fixtures are well-implemented, ensuring flexibility and uniqueness for test cases.crates/orchestrator/src/tests/jobs/da_job/mod.rs (3)
25-40
: Thetest_create_job
function correctly tests the creation of a DA job, ensuring all properties are set as expected.
42-50
: Thetest_verify_job
function effectively tests the job verification process using a mock DA client, ensuring the function behaves as expected under simulated conditions.
52-103
: Thetest_process_job
function is comprehensive, using a mock server and DA client to thoroughly test the job processing logic.crates/orchestrator/src/jobs/types.rs (1)
Line range hint
69-81
: The enhancements to theJobType
andJobStatus
enums, addingPartialEq
andPartialOrd
, improve their usability in logical comparisons and sorting operations.crates/orchestrator/src/jobs/da_job/mod.rs (1)
Line range hint
1-214
: TheDaJob
implementation is robust, with well-structured methods for creating, processing, and verifying jobs. The use of async patterns and structured error handling enhances the maintainability and reliability of the code.
let attempt = get_u64_from_metadata(metadata, key)?; | ||
let incremented_value = attempt.checked_add(1); | ||
if incremented_value.is_none() { | ||
return Err(eyre!("Incrementing key {} in metadata would exceed u64::MAX", key)); | ||
} | ||
new_metadata.insert(key.to_string(), incremented_value.unwrap().to_string()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider handling non-existent keys more idiomatically by using entry
API.
fn increment_key_in_metadata(metadata: &HashMap<String, String>, key: &str) -> Result<HashMap<String, String>> {
let mut new_metadata = metadata.clone();
let attempt = get_u64_from_metadata(metadata, key)?;
let incremented_value = attempt.checked_add(1).ok_or_else(|| eyre!("Incrementing key {} in metadata would exceed u64::MAX", key))?;
new_metadata.entry(key.to_string()).or_insert_with(|| "0".to_string()).replace(incremented_value.to_string());
Ok(new_metadata)
}
if incremented_value.is_none() { | ||
return Err(eyre!("Incrementing key {} in metadata would exceed u64::MAX", key)); | ||
} | ||
new_metadata.insert(key.to_string(), incremented_value.unwrap().to_string()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve error handling when parsing string to u64.
fn get_u64_from_metadata(metadata: &HashMap<String, String>, key: &str) -> Result<u64> {
metadata.get(key).unwrap_or(&"0".to_string()).parse::<u64>().map_err(|e| eyre!("Failed to parse metadata value for key {}: {}", key, e))
}
#[rstest] | ||
#[tokio::test] | ||
async fn create_job_fails_job_already_exists() { | ||
// TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incomplete test implementation.
Would you like me to help complete this test function or should we track this as a task in your project management tool?
#[rstest] | ||
#[tokio::test] | ||
async fn create_job_fails_works_new_job() { | ||
// TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incomplete test implementation.
Would you like me to help complete this test function or should we track this as a task in your project management tool?
In progress
Summary by CodeRabbit
New Features
Refactor
orchestrator
namespace.Enhancements
PartialEq
andPartialOrd
derivations to enums for improved comparability.Config
public for better accessibility.Testing