public static void ClassSetup(TestContext context) { APServer = null; if (context.Properties.Contains("DeviceSupports5Ghz")) { DeviceSupports5Ghz = bool.Parse(context.Properties["DeviceSupports5Ghz"].ToString()); testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "DeviceSupports5Ghz = {0}", DeviceSupports5Ghz)); } if (context.Properties.Contains("APServer")) { APServer = context.Properties["APServer"].ToString(); testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "APServer Name = {0}", APServer)); } if (context.Properties.Contains("ServiceAPChannelAddress")) { ServiceAPChannelAddress = context.Properties["ServiceAPChannelAddress"].ToString(); testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "ServiceAPChannelAddress = {0}", ServiceAPChannelAddress)); } if (context.Properties.Contains("Duration")) { int duration; if (Int32.TryParse(context.Properties["Duration"].ToString(), out duration)) { TestDuration = duration; testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "Duration = {0} minutes", TestDuration)); } else { testLogger.LogComment("Could not parse Duration. Using default."); } } if (APServer == null) { testLogger.LogError("Did not get AP Server name as parameter"); return; } testLogger.LogComment("Connecting to AP Config Server - " + APServer); using (ApConfigClient apConfigClient = new ApConfigClient(APServer)) { bool connect = apConfigClient.Connect(); if (connect) { testLogger.LogComment("Connection Succeeded"); } else { testLogger.LogError("Connection failed"); return; } testLogger.LogComment("Enum Routers"); routers = apConfigClient.EnumerateAccessPoints(); if (routers == null) { testLogger.LogError("Unable to enum routers, EnumerateAccessPoints returned null"); return; } if (routers.Count >= 2) { testLogger.LogComment("Found 2 routers as expected"); } else { testLogger.LogError("Did not find both APs"); return; } } }
private void AssociateSameAP(int routerIndex, bool b5Ghz, bool bHibernate) { Log("Deleting all wlan profiles"); DeleteProfiles(); Log("Starting Echo Services"); CreateEchoServer(); //Radios of all APs are turned on by the SetupRoutersIfNeeded(); Log("Setting up Routers"); SetupRoutersIfNeeded(); string Profile; APConfig apConfig = m_APConfigs[routerIndex]; string ap_ssid = (b5Ghz) ? apConfig.SSID_5GHZ : apConfig.SSID_24GHZ; //Turn off all APs SetRadioState(0, false, false); SetRadioState(0, false, true); SetRadioState(1, false, false); SetRadioState(1, false, true); //Turn on AP used for this run SetRadioState(routerIndex, true, b5Ghz); LogMajor("Associate with manual profile to " + ap_ssid + " - Enter lower powerstate - Wake - Verify connectivity to same AP"); Log("Creating a manual profile for SSID " + ap_ssid); Profile = CreateProfile(routerIndex, ConnectionMode.Manual, b5Ghz); LogMajor("Connecting to " + ap_ssid); if (!ConnectToAP(ap_ssid)) { return; } LogMajor("Validating association bssid"); if (!ValidateRadioAssociation(routerIndex, b5Ghz)) { return; } LogMajor("Validating connection by connecting to echo services and performing echo"); if (!PerformEcho(routerIndex, b5Ghz)) { return; } m_ApConfigClient.Disconnect(); //must disconnect from ap controller before going to sleep if (bHibernate) { LogMajor("Entering hibernate"); m_PowerManager.Sleep(120 * 1000, SleepState.S4); } else { LogMajor("Entering deepest supported sleep"); m_PowerManager.DeepestSleep(120 * 1000); } LogMajor("Sleeping for 30 seconds after wake up"); Wlan.Sleep(30 * 1000); // 30s m_ApConfigClient.Connect(); //must reconnect to ap controller after waking up if (!Helpers.IsConnected(m_WlanApi, m_TestInterface)) { LogError("After resuming system not connected to " + ap_ssid); return; } LogMajor("Validating association bssid"); if (!ValidateRadioAssociation(routerIndex, b5Ghz)) { return; } LogMajor("Validating connection by connecting to echo services and performing echo"); if (!PerformEcho(routerIndex, b5Ghz)) { return; } m_WlanApi.DeleteAllProfiles(m_TestInterface.Id); }
private bool RunIntegrityCheck() { testLogger.LogComment("Running integrity check"); UInt16 port = 7777; UInt16 streamBytes = Convert.ToUInt16(random.Next(10, 2000)); nextIntegrityCheckTime = DateTime.Now.Add(integrityCheckInterval); using (ApConfigClient apConfigClient = new ApConfigClient(WlanStress.APServer)) { testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "WlanStress.APServer: {0}", WlanStress.APServer)); int retries = 3; bool connected = false; while (retries > 0) { retries--; testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "Attempting to connect to AP machine. Retries remaining: {0}", retries)); bool connect = apConfigClient.Connect(); if (connect) { testLogger.LogComment("Connection to AP Server Succeeded"); connected = true; break; } else { testLogger.LogComment("Connection AP Server failed"); Wlan.Sleep(10000); } } if (connected == false) { testLogger.LogError("Giving up connecting to AP machine"); return(false); } apConfigClient.StartEchoServer(port, streamBytes, 1); ConnectForIntegrityCheck(apConfigClient, port, streamBytes); try { using (Wlan wlanApi = new Wlan()) { var wlanInterfaceList = wlanApi.EnumWlanInterfaces(); Verify.IsTrue(wlanInterfaceList.Count >= 1, string.Format(CultureInfo.InvariantCulture, "wlanInterfaceList.Count = {0}", wlanInterfaceList.Count)); var wlanInterface = wlanInterfaceList[0]; using (Win32Sockets win32Sockets = new Win32Sockets()) { string localAddress = win32Sockets.FindIpAddress(wlanInterface.Id); testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "IPAddress: {0}", localAddress)); using (TCPEchoClient echoClient = new TCPEchoClient(localAddress, ServiceAPChannelAddress, port, streamBytes)) { echoClient.Connect(); echoClient.PerformEcho(); bool result = echoClient.IsResponseBufferValid(); testLogger.LogComment(string.Format(CultureInfo.InvariantCulture, "Echo Client Success: {0}", result)); return(result); } } } } catch (Exception error) { testLogger.LogComment("TlukeTest: Exception hit"); testLogger.LogError(string.Format(CultureInfo.InvariantCulture, "Error While trying data path: {0}", error.ToString())); return(false); } finally { testLogger.LogComment("Cleaning Up Each Server"); apConfigClient.StopEchoServer(); using (Wlan wlanApi = new Wlan()) { var wlanInterfaceList = wlanApi.EnumWlanInterfaces(); Verify.IsTrue(wlanInterfaceList.Count >= 1, string.Format(CultureInfo.InvariantCulture, "wlanInterfaceList.Count = {0}", wlanInterfaceList.Count)); var wlanInterface = wlanInterfaceList[0]; if (wlanInterface.State == WLAN_INTERFACE_STATE.wlan_interface_state_connected) { wlanApi.Disconnect(wlanInterface.Id, DisconnectWait); } } } } }