1 // Copyright 2023 The ChromiumOS Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 use std::time::Duration; 6 7 use fixture::vm::Config; 8 use fixture::vm::TestVm; 9 10 #[test] psql() -> anyhow::Result<()>11fn psql() -> anyhow::Result<()> { 12 let cfg = Config::from_env() 13 .with_kernel("https://storage.googleapis.com/crosvm/integration_tests/guest-bzimage-x86_64-r0009") 14 .with_initrd("https://storage.googleapis.com/crosvm/integration_tests/benchmarks/custom-initramfs.cpio.gz-r0005") 15 // Created by e2e_tests/guest_under_test/rootfs_benches/postgres.sh 16 .with_rootfs("https://storage.googleapis.com/crosvm/integration_tests/benchmarks/postgres-rootfs.img.zst-r0001").rootfs_is_rw().rootfs_is_compressed() 17 .with_stdout_hardware("serial").extra_args(vec!["--mem".to_owned(), "512".to_owned()]); 18 let mut vm = TestVm::new(cfg).unwrap(); 19 assert_eq!( 20 vm.exec_in_guest_async("echo 42")? 21 .with_timeout(Duration::from_secs(500)) 22 .wait_ok(&mut vm)? 23 .stdout 24 .trim(), 25 "42" 26 ); 27 vm.exec_in_guest("cd /root")?; 28 vm.exec_in_guest("PATH=$PATH:/usr/lib/postgresql/15/bin PGDATA=/var/lib/postgresql/data POSTGRES_PASSWORD=mysecretpassword nohup /usr/local/bin/docker-entrypoint.sh postgres > /dev/null 2>&1 </dev/null &")?; 29 vm.exec_in_guest("sleep 5")?; 30 vm.exec_in_guest("pgbench -U postgres -i -s 10 postgres")?; 31 vm.exec_in_guest("pgbench -U postgres -c 1 -j 1 -t 1000 postgres 1>&2")?; 32 Ok(()) 33 } 34