Added Jenkins file
This commit is contained in:
		
							
								
								
									
										27
									
								
								Jenkinsfile
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								Jenkinsfile
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
pipeline {
 | 
			
		||||
    agent any
 | 
			
		||||
 | 
			
		||||
    stages {
 | 
			
		||||
        stage('Rust Testing') {
 | 
			
		||||
            steps {
 | 
			
		||||
                sh "cargo test"
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        stage('Linux Build') {
 | 
			
		||||
            steps {
 | 
			
		||||
                sh "cargo build --release"
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
	stage('Integration Testing') {
 | 
			
		||||
	    steps {
 | 
			
		||||
                sh "pipenv install"
 | 
			
		||||
                sh "pipenv run pytest"
 | 
			
		||||
            }
 | 
			
		||||
	}
 | 
			
		||||
        stage('Archiving') {
 | 
			
		||||
            steps {
 | 
			
		||||
                archiveArtifacts artifacts: 'target/release/morethantext_web', fingerprint: true
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										19
									
								
								src/lib.rs
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								src/lib.rs
									
									
									
									
									
								
							@@ -14,6 +14,7 @@ use uuid::Uuid;
 | 
			
		||||
pub struct MoreThanText {
 | 
			
		||||
    id: Option<Uuid>,
 | 
			
		||||
    tx: Sender<SendMsg>,
 | 
			
		||||
    nodes: Vec<String>
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl MoreThanText {
 | 
			
		||||
@@ -24,15 +25,15 @@ impl MoreThanText {
 | 
			
		||||
    ///  ```
 | 
			
		||||
    ///  use morethantext::MoreThanText;
 | 
			
		||||
    ///
 | 
			
		||||
    ///  MoreThanText::new();
 | 
			
		||||
    ///  MoreThanText::new(Vec::new());
 | 
			
		||||
    ///  ```
 | 
			
		||||
    pub fn new() -> Self {
 | 
			
		||||
    pub fn new(_nodes: Vec<String>) -> Self {
 | 
			
		||||
        let (tx, rx) = channel();
 | 
			
		||||
        spawn(move || {
 | 
			
		||||
            let mut cache = Cache::new(rx);
 | 
			
		||||
            cache.listen();
 | 
			
		||||
        });
 | 
			
		||||
        Self { id: None, tx: tx }
 | 
			
		||||
        Self { id: None, tx: tx, nodes: Vec::new() }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// Opens an existing or new session with the database.
 | 
			
		||||
@@ -45,7 +46,7 @@ impl MoreThanText {
 | 
			
		||||
    ///  ```
 | 
			
		||||
    ///  use morethantext::MoreThanText;
 | 
			
		||||
    ///
 | 
			
		||||
    ///  let mut mtt = MoreThanText::new();
 | 
			
		||||
    ///  let mut mtt = MoreThanText::new(Vec::new());
 | 
			
		||||
    ///  mtt.open_session(None);
 | 
			
		||||
    ///  mtt.open_session(Some("7b1ff340-7dfa-4f29-b144-601384e54423".to_string()));
 | 
			
		||||
    ///  ```
 | 
			
		||||
@@ -65,7 +66,7 @@ impl MoreThanText {
 | 
			
		||||
    /// ```
 | 
			
		||||
    ///  use morethantext::MoreThanText;
 | 
			
		||||
    ///
 | 
			
		||||
    ///  let mut mtt = MoreThanText::new();
 | 
			
		||||
    ///  let mut mtt = MoreThanText::new(Vec::new());
 | 
			
		||||
    ///  mtt.get_id();
 | 
			
		||||
    /// ```
 | 
			
		||||
    pub fn get_id(&self) -> String {
 | 
			
		||||
@@ -82,7 +83,7 @@ mod mtt_client {
 | 
			
		||||
 | 
			
		||||
    #[test]
 | 
			
		||||
    fn uniques_ids() {
 | 
			
		||||
        let mut mtt = MoreThanText::new();
 | 
			
		||||
        let mut mtt = MoreThanText::new(Vec::new());
 | 
			
		||||
        let mut ids: Vec<Uuid> = Vec::new();
 | 
			
		||||
        for _ in 1..10 {
 | 
			
		||||
            mtt.open_session(None);
 | 
			
		||||
@@ -96,7 +97,7 @@ mod mtt_client {
 | 
			
		||||
 | 
			
		||||
    #[test]
 | 
			
		||||
    fn existing_ids_are_reused() {
 | 
			
		||||
        let mut mtt = MoreThanText::new();
 | 
			
		||||
        let mut mtt = MoreThanText::new(Vec::new());
 | 
			
		||||
        mtt.open_session(None);
 | 
			
		||||
        let holder = mtt.id.clone().unwrap().to_string();
 | 
			
		||||
        mtt.open_session(Some(holder.clone()));
 | 
			
		||||
@@ -105,14 +106,14 @@ mod mtt_client {
 | 
			
		||||
 | 
			
		||||
    #[test]
 | 
			
		||||
    fn bad_ids_generate_new_ones() {
 | 
			
		||||
        let mut mtt = MoreThanText::new();
 | 
			
		||||
        let mut mtt = MoreThanText::new(Vec::new());
 | 
			
		||||
        mtt.open_session(Some("bad test string".to_string()));
 | 
			
		||||
        assert!(mtt.id.is_some());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #[test]
 | 
			
		||||
    fn incorrect_ids_generate_new_ones() {
 | 
			
		||||
        let mut mtt = MoreThanText::new();
 | 
			
		||||
        let mut mtt = MoreThanText::new(Vec::new());
 | 
			
		||||
        let holder = Uuid::new_v4();
 | 
			
		||||
        mtt.open_session(Some(holder.clone().to_string()));
 | 
			
		||||
        assert_ne!(mtt.id, Some(holder));
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,7 @@ struct Args {
 | 
			
		||||
    address: String,
 | 
			
		||||
    /// cluster host
 | 
			
		||||
    #[arg(short, long, num_args(0..))]
 | 
			
		||||
    cluster: Option<String>,
 | 
			
		||||
    node: Vec<String>,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[cfg(test)]
 | 
			
		||||
@@ -33,7 +33,8 @@ mod http_session {
 | 
			
		||||
async fn main() {
 | 
			
		||||
    let args = Args::parse();
 | 
			
		||||
    let addr = format!("{}:{}", args.address, args.port);
 | 
			
		||||
    let state = MoreThanText::new();
 | 
			
		||||
    let nodes = args.node;
 | 
			
		||||
    let state = MoreThanText::new(nodes);
 | 
			
		||||
    let app = Router::new().route("/", get(handler)).with_state(state);
 | 
			
		||||
    let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
 | 
			
		||||
    axum::serve(listener, app.into_make_service())
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user