Initial regression testing logging. Shows changes being done for every step while solving the puzzle.

This commit is contained in:
Tim Young 2024-02-06 13:00:11 -06:00
parent 5b20dd671c
commit 38a6107cea
10 changed files with 232 additions and 24 deletions

View File

@ -62,12 +62,12 @@ namespace EduNetworkBuilder
}
}
public ActionClass RunAction(int WhichIndex)
public ActionClass RunAction(int WhichIndex, bool NoteAllChanges = false)
{
if (CurrentNetAction == null) return null;
if (WhichIndex < CurrentNetAction.Actions.Count)
{
CurrentNetAction.Actions[WhichIndex].DoAction();
CurrentNetAction.Actions[WhichIndex].DoAction(NoteAllChanges);
return CurrentNetAction.Actions[WhichIndex];
}
return null;
@ -180,19 +180,21 @@ namespace EduNetworkBuilder
public NetworkComponentType newItemType = NetworkComponentType.none; //Making new device
public NetworkComponent ChangedComponent = null;
public void DoAction()
public void DoAction(bool NoteAllChanges=false)
{
Network myNet = NB.GetNetwork();
NetworkDevice source = myNet.GetDeviceFromID(SourceID);
NetworkComponent sourceC = myNet.GetComponentFromID(SourceID);
NetworkLink sourceNL;
string indent = " ";
switch (Action)
{
case NBAction.changecomponent:
//This could be a link or a device we are changing.
if(ChangedComponent is NetworkDevice)
{
source.UpdateFromComponent(ChangedComponent); //Copy any changes across
if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_ChangeDevice") + " " + source.hostname); }
source.UpdateFromComponent(ChangedComponent, NoteAllChanges); //Copy any changes across
source.SetImageFromType(); //The image was not saved. Re-make it
}
else
@ -200,6 +202,7 @@ namespace EduNetworkBuilder
if(source != null)
myNet.RemoveComponent(source);
sourceNL = (NetworkLink)ChangedComponent;
if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_Replace_Link") + " " + sourceNL.Src.HostName + " - " + sourceNL.Dst.HostName); }
myNet.MarkAsLinked(sourceNL.Src, sourceNL.GetUniqueIdentifier);
myNet.MarkAsLinked(sourceNL.Dst, sourceNL.GetUniqueIdentifier);
myNet.AddItem(ChangedComponent);
@ -212,6 +215,7 @@ namespace EduNetworkBuilder
source.ChangeLocation(Location);
source.UnHide(); //In case it was hidden
if (NB.DebugActions) { Console.WriteLine("Changing location for: " + source + " " + Location.X + ":" +Location.Y); }
if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_MoveDevice") + " " + source.hostname + " - " +Location.X + ":" + Location.Y); }
}
break;
case NBAction.deletecomponent:
@ -228,6 +232,7 @@ namespace EduNetworkBuilder
}
myNet.RemoveComponent(source);
if (NB.DebugActions) { Console.WriteLine("Deleting a device: " + source.hostname); }
if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_DeleteDevice") + " " + source.hostname + " - " + source.myType.ToString()); }
} else if(sourceC != null && sourceC is NetworkLink)
{
if (myNet.ItemIsCritical(sourceC.hostname))
@ -236,6 +241,7 @@ namespace EduNetworkBuilder
SourceL.Destroy(); //Mark both ends as being deleted
myNet.RemoveComponent(SourceL); //Get rid of this link
if (NB.DebugActions) { Console.WriteLine("Deleting a link: " + source.hostname); }
if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_DeleteLink") + " " + SourceL.Src.HostName + " - " + SourceL.Dst.HostName); }
}
break;
case NBAction.newdevice:
@ -254,13 +260,15 @@ namespace EduNetworkBuilder
if (myNet.BlockedByTree(BottomLeft)) CanDo = false;
if (CanDo)
{
ChangedComponent = (NetworkDevice)myNet.AddItem(newItemType, Location);
if (NB.DebugActions && source != null) { Console.WriteLine("Adding a Device: " + source.hostname); }
NetworkDevice newdevice = (NetworkDevice)myNet.AddItem(newItemType, Location);
if (NB.DebugActions && source != null) { Console.WriteLine("Adding a Device: " + newdevice.hostname); }
if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_AddDevice") + " " + newdevice.hostname + " - " + newdevice.myType.ToString()); }
}
else
{
NB.SetBuilderWindowStatis(NB.Translate("NB_TreePlacementError"));
if (NB.DebugActions) { Console.WriteLine("Unable to add device: " + source.hostname); }
if (NB.DebugActions) { Console.WriteLine("Unable to add device: " + ChangedComponent.hostname); }
}
break;
case NBAction.dhcp:
@ -268,27 +276,33 @@ namespace EduNetworkBuilder
{
source.DHCPRequestFromHere();
if (NB.DebugActions) { Console.WriteLine("Requesting DHCP: " + source.hostname); }
if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_RequestDHCP") + " " + source.hostname); }
}
break;
case NBAction.arp:
if (source != null)
{
//We have not implimented this well. But, here it is anyway. We would do this if showing ethernet stuff
source.AskArpFromHere(Destination);
if (NB.DebugActions) { Console.WriteLine("Requesting DHCP: " + source.hostname); }
if (NB.DebugActions) { Console.WriteLine("Requesting ARP: " + source.hostname); }
if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_RequestARP") + " " + source.hostname + " - " + Destination.GetIPString); }
}
break;
case NBAction.cleararp:
if (source != null)
{
//We have not implimented this well. But, here it is anyway. We would do this if showing ethernet stuff
source.ClearArps();
if (NB.DebugActions) { Console.WriteLine("Clearing ARP: " + source.hostname); }
if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_ClearArp") + " " + source.hostname + " - " + Destination.GetIPString); }
}
break;
case NBAction.ping:
if (source != null)
{
source.PingFromHere(Destination);
if (NB.DebugActions) { Console.WriteLine("Pinging " + Destination.GetIPString + " from " + source.hostname); }
if (NB.DebugActions) { Console.WriteLine("Pinging " + Destination.GetIPString + " from " + source.hostname); }
if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_DoPing") + " " + source.hostname + " - " + Destination.GetIPString); }
}
break;
case NBAction.traceroute:
@ -296,6 +310,7 @@ namespace EduNetworkBuilder
{
source.TracerouteFromHere(Destination);
if (NB.DebugActions) { Console.WriteLine("Traceroute: " + Destination.GetIPString + " from " + source.hostname); }
if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_DoTraceroute") + " " + source.hostname + " - " + Destination.GetIPString ); }
}
break;
case NBAction.replace:
@ -310,6 +325,7 @@ namespace EduNetworkBuilder
myNet.RegisterDeviceReplaced(source.hostname); //replace it.
if (NB.DebugActions) { Console.WriteLine("Replacing device: " + source.hostname); }
if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_Replace_Device") + " " + source.hostname); }
}
else if (sourceC is NetworkLink)
{
@ -322,27 +338,32 @@ namespace EduNetworkBuilder
myNet.RemoveComponent(sourceNL);
NetworkLink nNL = new NetworkLink(sourceID, destID, LinkType.normal);
myNet.AddItem(nNL);
if (NB.DebugActions) { Console.WriteLine("Replacing link: " + source.hostname); }
if (NB.DebugActions) { Console.WriteLine("Replacing link: " + sourceID.HostName + " - " + destID.HostName); }
if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_Replace_Link") + " " + sourceID.HostName + " - " + destID.HostName); }
}
}
break;
case NBAction.replaceUPS:
myNet.RegisterUPSAdded(source.hostname);
if (NB.DebugActions) { Console.WriteLine("Replacing UPS on: " + source.hostname); }
if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_Replace_UPS") + " " + source.hostname); }
break;
case NBAction.poweroff:
source.PowerOff = true;
myNet.RegisterDeviceReset(source.hostname);
if (NB.DebugActions) { Console.WriteLine("Powering off: " + source.hostname); }
if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_Powering_OFF") + " " + source.hostname); }
break;
case NBAction.poweron:
source.PowerOff = false;
if (NB.DebugActions) { Console.WriteLine("Powering on: " + source.hostname); }
if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_Powering_ON") + " " + source.hostname); }
//We might see about exploding the device here.
break;
case NBAction.reset:
source.ClearIPs(); //reset the device - IPs and VLANs
if (NB.DebugActions) { Console.WriteLine("Resetting: " + source.hostname); }
if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_Resetting") + " " + source.hostname); }
//We might see about exploding the device here.
break;

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\WiX.3.11.2\build\wix.props" Condition="Exists('..\packages\WiX.3.11.2\build\wix.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -28,11 +29,13 @@
<PublisherName>Tim Young</PublisherName>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.htm</WebPage>
<ApplicationRevision>53</ApplicationRevision>
<ApplicationRevision>54</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -263,6 +266,7 @@
<DependentUpon>VLANConfig.cs</DependentUpon>
</EmbeddedResource>
<None Include="EduNetworkBuilder_TemporaryKey.pfx" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@ -475,6 +479,12 @@
<Content Include="Resources\NBIco.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\WiX.3.11.2\build\wix.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\WiX.3.11.2\build\wix.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

View File

@ -1078,6 +1078,14 @@ namespace EduNetworkBuilder
return randomizedList;
}
public static void AddNetMessage(string host, string message)
{
Network thenet = GetNetwork();
//Console.WriteLine("Adding message: " + host + " : " + message);
if (thenet == null) return; //we cannot add it. do not blow up
thenet.AddMessage(new PacketMessage(host, message));
}
public static bool OpenURLInExternalBrowser(string URL)
{
Uri uriResult;

View File

@ -1696,7 +1696,7 @@ namespace EduNetworkBuilder
//We are doing a replay and enough time has passed from the last replay...
NBSettings Settings = NB.GetSettings();
ActionCollection AC = Settings.GetUserActionCollection();
ActionClass Success = AC.RunAction(NextReplayIndex++);
ActionClass Success = AC.RunAction(NextReplayIndex++, true); //note all changes as we do them
NextReplayAction = DateTime.UtcNow.AddMilliseconds(NB.MillisecondsBetweenReplays);

View File

@ -978,6 +978,17 @@ namespace EduNetworkBuilder
return null;
}
public string AllInterfacesString(bool UseCidr= false)
{
string thestring = "";
foreach (NetworkInterface oneIF in interfaces)
{
if (thestring != "") thestring += ",";
thestring += oneIF.InterfaceString(UseCidr);
}
return thestring;
}
public NB_IPAddress FirstIP()
{
List<NB_IPAddress> addresses = IPAddressList();

View File

@ -99,7 +99,7 @@ namespace EduNetworkBuilder
{
}
public virtual void UpdateFromComponent(NetworkComponent CopyFrom)
public virtual void UpdateFromComponent(NetworkComponent CopyFrom, bool NoteAllChanges = false)
{
}

View File

@ -1518,28 +1518,109 @@ namespace EduNetworkBuilder
return arps;
}
public override void UpdateFromComponent(NetworkComponent CopyFrom)
public override void UpdateFromComponent(NetworkComponent CopyFrom, bool NoteAllChanges = false)
{
if (CopyFrom.GetType() != this.GetType()) return; //we cannot copy from it if it is different
NetworkDevice ndCopyFrom = (NetworkDevice)CopyFrom;
if (Object.ReferenceEquals(this, CopyFrom)) return; //No need to copy values to itself
hostname = ndCopyFrom.hostname;
Network mainnet = NB.GetNetwork();
string indent = " ";
//if(NoteAllChanges && mainnet != null) mainnet.AddMessage(new PacketMessage("", indent + NB.Translate("NDUpdateComponent")));
if (hostname != ndCopyFrom.hostname)
{
if (NoteAllChanges && mainnet != null) mainnet.AddMessage(new PacketMessage("", indent + "hostname: " + hostname + " -> " + ndCopyFrom.hostname));
hostname = ndCopyFrom.hostname;
}
Size = ndCopyFrom.Size;
DefaultGW = ndCopyFrom.DefaultGW;
if (DefaultGW.GetIPString != ndCopyFrom.DefaultGW.GetIPString)
{
if (NoteAllChanges && mainnet != null) mainnet.AddMessage(new PacketMessage("", indent + "DefaultGW: " + DefaultGW.GetIPString + " -> " + ndCopyFrom.DefaultGW.GetIPString));
DefaultGW = ndCopyFrom.DefaultGW;
}
if (ndCopyFrom.MyImage != null)
MyImage = new Bitmap(ndCopyFrom.MyImage);
else
MyImage = null;
CanAddNics = ndCopyFrom.CanAddNics;
CanServeDHCP = ndCopyFrom.CanServeDHCP;
CanUseDHCP = ndCopyFrom.CanUseDHCP;
MustUseDHCP = ndCopyFrom.MustUseDHCP;
isDHCPServer = ndCopyFrom.isDHCPServer;
isDNSServer = ndCopyFrom.isDNSServer;
HasAdvFirewall = ndCopyFrom.HasAdvFirewall;
if (CanAddNics != ndCopyFrom.CanAddNics)
{
if (NoteAllChanges && mainnet != null) mainnet.AddMessage(new PacketMessage("", indent + "CanAddNics: " + CanAddNics + " -> " + ndCopyFrom.CanAddNics));
CanAddNics = ndCopyFrom.CanAddNics;
}
if (CanServeDHCP != ndCopyFrom.CanServeDHCP)
{
if (NoteAllChanges && mainnet != null) mainnet.AddMessage(new PacketMessage("", indent + "CanServeDHCP: " + CanServeDHCP + " -> " + ndCopyFrom.CanServeDHCP));
CanServeDHCP = ndCopyFrom.CanServeDHCP;
}
if (CanUseDHCP != ndCopyFrom.CanUseDHCP)
{
if (NoteAllChanges && mainnet != null) mainnet.AddMessage(new PacketMessage("", indent + "CanUseDHCP: " + CanUseDHCP + " -> " + ndCopyFrom.CanUseDHCP));
CanUseDHCP = ndCopyFrom.CanUseDHCP;
}
if (MustUseDHCP != ndCopyFrom.MustUseDHCP)
{
if (NoteAllChanges && mainnet != null) mainnet.AddMessage(new PacketMessage("", indent + "MustUseDHCP: " + MustUseDHCP + " -> " + ndCopyFrom.MustUseDHCP));
MustUseDHCP = ndCopyFrom.MustUseDHCP;
}
if (isDHCPServer != ndCopyFrom.isDHCPServer)
{
if (NoteAllChanges && mainnet != null) mainnet.AddMessage(new PacketMessage("", indent + "IsDHCPServer: " + isDHCPServer + " -> " + ndCopyFrom.isDHCPServer));
isDHCPServer = ndCopyFrom.isDHCPServer;
}
if (isDNSServer != ndCopyFrom.isDNSServer)
{
if (NoteAllChanges && mainnet != null) mainnet.AddMessage(new PacketMessage("", indent + "IsDNSserver: " + isDNSServer + " -> " + ndCopyFrom.isDNSServer));
isDNSServer = ndCopyFrom.isDNSServer;
}
if (HasAdvFirewall != ndCopyFrom.HasAdvFirewall)
{
if (NoteAllChanges && mainnet != null) mainnet.AddMessage(new PacketMessage("", indent + "HasAdvancedFirewall: " + HasAdvFirewall + " -> " + ndCopyFrom.HasAdvFirewall));
HasAdvFirewall = ndCopyFrom.HasAdvFirewall;
}
MyLocation = ndCopyFrom.MyLocation;
//Process NICs.
if (NoteAllChanges && mainnet != null)
{
//List all nics that we are dropping
foreach (NetworkCard nic in NICs)
{
NetworkCard foundnic = ndCopyFrom.NicFromName(nic.NicName());
if (foundnic == null)
mainnet.AddMessage(new PacketMessage("", indent + "DropNIC: " + nic.NicName()));
else
{
//The nic still exists. Note any major changes. IP, netmask
if((foundnic.myNicType == NicType.wport || foundnic.myNicType == NicType.wlan) && foundnic.SSID != nic.SSID)
mainnet.AddMessage(new PacketMessage("", indent + "SSID: " + nic.SSID + " -> " + foundnic.SSID));
if ((foundnic.myNicType == NicType.vpn || foundnic.myNicType == NicType.vpn) && foundnic.EncryptionKey != nic.EncryptionKey)
mainnet.AddMessage(new PacketMessage("", indent + "EncryptionKey: " + nic.EncryptionKey + " -> " + foundnic.EncryptionKey));
//Compare interfaces - should be done at nic level...
if (foundnic.AllInterfacesString() != nic.AllInterfacesString())
mainnet.AddMessage(new PacketMessage("", indent + "Interfaces: " + nic.AllInterfacesString(true) + " -> " + foundnic.AllInterfacesString(true)));
}
}
//List all nics that we are dropping
foreach (NetworkCard nic in ndCopyFrom.NICs)
{
NetworkCard mynic = NicFromName(nic.NicName());
if (mynic == null)
mainnet.AddMessage(new PacketMessage("", indent + "AddNIC: " + nic.NicName() + " " +nic.AllInterfacesString()));
}
}
//Now, copy across the NICs
NICs.Clear();
foreach(NetworkCard nic in ndCopyFrom.NICs)
{

View File

@ -1,7 +1,12 @@
{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033\deflangfe1033{\fonttbl{\f0\fswiss\fprq2\fcharset0 Calibri;}}
{\colortbl ;\red0\green0\blue255;}
{\*\generator Riched20 10.0.22621}{\*\mmathPr\mdispDef1\mwrapIndent1440 }\viewkind4\uc1
\pard\nowidctlpar\sa200\sl276\slmult1\b\f0\fs22\lang9 Version 1.0.52\par
\pard\nowidctlpar\sa200\sl276\slmult1\b\f0\fs22\lang9 Version 1.0.54\b0\par
* Minor changefor developers allowing more information about what is happening during regression testing. \par
\b Version 1.0.53\par
*\b0 Show a line between devices when dragging ethernet cables. Makes it easier to see.\par
* Tried highlighting what you are supposed to be filling out next, when creating network links.\b\par
Version 1.0.52\par
\b0 * Change publish URL to an actual domain.\b\par
Version 1.0.51\par
\b0 * Added small time-based delay when printing packets; on fast computers the packets would fly by too fast.\par

View File

@ -2129,4 +2129,72 @@
<value>Regression testing</value>
<comment>LBW_Regression_Testing = Regression testing</comment>
</data>
<data name="AC_AddDevice" xml:space="preserve">
<value>Add Device</value>
<comment>AC_AddDevice = Add Device</comment>
</data>
<data name="AC_ChangeDevice" xml:space="preserve">
<value>Change Device</value>
<comment>AC_ChangeDevice = Change Device</comment>
</data>
<data name="AC_ClearArp" xml:space="preserve">
<value>Clear ARP</value>
<comment>AC_ClearArp = Clear ARP</comment>
</data>
<data name="AC_DeleteDevice" xml:space="preserve">
<value>Delete Device</value>
<comment>AC_DeleteDevice = Delete Device</comment>
</data>
<data name="AC_DeleteLink" xml:space="preserve">
<value>Delete link</value>
<comment>AC_DeleteLink = Delete link</comment>
</data>
<data name="AC_DoPing" xml:space="preserve">
<value>Do ping</value>
<comment>AC_DoPing = Do ping</comment>
</data>
<data name="AC_DoTraceroute" xml:space="preserve">
<value>Do Traceroute</value>
<comment>AC_DoTraceroute = Do Traceroute</comment>
</data>
<data name="AC_MoveDevice" xml:space="preserve">
<value>Move Device</value>
<comment>AC_MoveDevice = Move Device</comment>
</data>
<data name="AC_Powering_OFF" xml:space="preserve">
<value>Powering Off</value>
<comment>AC_Powering_OFF = Powering Off</comment>
</data>
<data name="AC_Powering_ON" xml:space="preserve">
<value>Powering On</value>
<comment>AC_Powering_OFF - Powering On</comment>
</data>
<data name="AC_Replace_Device" xml:space="preserve">
<value>Replace Device</value>
<comment>AC_Replace_Device = Replace Device</comment>
</data>
<data name="AC_Replace_Link" xml:space="preserve">
<value>Replace Link</value>
<comment>AC_Replace_Link = Replace Link</comment>
</data>
<data name="AC_Replace_UPS" xml:space="preserve">
<value>Replace UPS</value>
<comment>AC_Replace_UPS = Replace UPS</comment>
</data>
<data name="AC_RequestARP" xml:space="preserve">
<value>Request ARP</value>
<comment>AC_RequestARP = Request ARP</comment>
</data>
<data name="AC_RequestDHCP" xml:space="preserve">
<value>Request DHCP</value>
<comment>AC_RequestDHCP = Request DHCP</comment>
</data>
<data name="AC_Resetting" xml:space="preserve">
<value>Resetting</value>
<comment>AC_Resetting = Resetting</comment>
</data>
<data name="NDUpdateComponent" xml:space="preserve">
<value>Updating Device</value>
<comment>NDUpdateComponent = Update Device</comment>
</data>
</root>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="WiX" version="3.11.2" targetFramework="net45" />
</packages>