Skip to content

Commit

Permalink
Fix failing integration test due to changed server::Context construct…
Browse files Browse the repository at this point in the history
…or. (#115)
  • Loading branch information
jordanhendricks authored Apr 15, 2022
1 parent ac50018 commit be664c6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 36 deletions.
36 changes: 33 additions & 3 deletions server/src/lib/vnc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ use propolis::common::GuestAddr;
use propolis::dispatch::AsyncCtx;
use propolis::hw::qemu::ramfb::Config;
use rfb::encodings::RawEncoding;
use rfb::rfb::{FramebufferUpdate, Rectangle};
use rfb::server::Server;
use slog::{debug, error, Logger};
use rfb::rfb::{
FramebufferUpdate, ProtoVersion, Rectangle, SecurityType, SecurityTypes,
};
use rfb::server::{Server, VncServer, VncServerConfig, VncServerData};
use slog::{debug, error, o, Logger};
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::sync::Arc;
use tokio::sync::Mutex;

Expand Down Expand Up @@ -123,3 +126,30 @@ impl Server for PropolisVncServer {
fb
}
}

// Default VNC server configuration.
// XXX: Do we want to specify this information in the config file?
pub fn setup_vnc(log: &Logger) -> VncServer<PropolisVncServer> {
let initial_width = 1024;
let initial_height = 768;

let config = VncServerConfig {
addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 5900),
version: ProtoVersion::Rfb38,
// vncviewer won't work without offering VncAuth, even though it doesn't ask to use
// it.
sec_types: SecurityTypes(vec![
SecurityType::None,
SecurityType::VncAuthentication,
]),
name: "propolis-vnc".to_string(),
};
let data = VncServerData { width: initial_width, height: initial_height };
let pvnc = PropolisVncServer::new(
initial_width,
initial_height,
log.new(o!("component" => "vnc-server")),
);

VncServer::new(pvnc, config, data)
}
35 changes: 3 additions & 32 deletions server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@ use dropshot::{
};
use futures::join;
use propolis::usdt::register_probes;
use rfb::rfb::{ProtoVersion, SecurityType, SecurityTypes};
use rfb::server::VncServer;
use rfb::server::{VncServerConfig, VncServerData};
use slog::{info, o, Logger};
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use slog::info;
use std::net::SocketAddr;
use std::path::PathBuf;
use structopt::StructOpt;

use propolis_server::vnc::PropolisVncServer;
use propolis_server::vnc::setup_vnc;
use propolis_server::{config, server};

#[derive(Debug, StructOpt)]
Expand Down Expand Up @@ -50,32 +47,6 @@ pub fn run_openapi() -> Result<(), String> {
.map_err(|e| e.to_string())
}

fn setup_vnc(log: &Logger) -> VncServer<PropolisVncServer> {
// XXX: Do we want to specify this information in the config file?
let initial_width = 1024;
let initial_height = 768;

let config = VncServerConfig {
addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 5900),
version: ProtoVersion::Rfb38,
// vncviewer won't work without offering VncAuth, even though it doesn't ask to use
// it.
sec_types: SecurityTypes(vec![
SecurityType::None,
SecurityType::VncAuthentication,
]),
name: "propolis-vnc".to_string(),
};
let data = VncServerData { width: initial_width, height: initial_height };
let pvnc = PropolisVncServer::new(
initial_width,
initial_height,
log.new(o!("component" => "vnc-server")),
);

VncServer::new(pvnc, config, data)
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Ensure proper setup of USDT probes
Expand Down
4 changes: 3 additions & 1 deletion server/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use propolis_client::{Client, Error as ClientError};
use propolis_server::{
config::{BlockDevice, Config, Device},
server,
vnc::setup_vnc,
};
use slog::{o, Logger};
use std::collections::BTreeMap;
Expand Down Expand Up @@ -59,8 +60,9 @@ async fn initialize_server(log: &Logger) -> HttpServer<server::Context> {
let mut devices = BTreeMap::new();
devices.insert("block0".to_string(), dev);

let vnc_server = setup_vnc(&log);
let config = Config::new(artifacts.bootrom.path(), devices, block_devices);
let context = server::Context::new(config, log.new(slog::o!()));
let context = server::Context::new(config, vnc_server, log.new(slog::o!()));

let config_dropshot = ConfigDropshot {
bind_address: "127.0.0.1:0".parse().unwrap(),
Expand Down

0 comments on commit be664c6

Please sign in to comment.