Skip to content

Commit 1a981f2

Browse files
2023.2 release
1 parent a5b8b64 commit 1a981f2

13 files changed

Lines changed: 673 additions & 146 deletions

LICENSE.txt

Lines changed: 207 additions & 120 deletions
Large diffs are not rendered by default.

RELEASENOTES.txt

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Release Notes for
22
P4API.NET, the Helix P4API for .NET
33

4-
Version 2023.1
4+
Version 2023.2
55

66
Introduction
77

@@ -80,8 +80,8 @@ Compatibility Statements
8080

8181
API Compatibility
8282

83-
This release of P4API.NET requires the 2023.1 Helix Core API
84-
(2023.1/2442900) for C/C++ (P4API), built with Visual Studio 2019 or
83+
This release of P4API.NET requires the 2023.2 Helix Core API
84+
(2023.2/2519561) for C/C++ (P4API), built with Visual Studio 2019 or
8585
later.
8686

8787
C#/.NET Compatibility
@@ -134,7 +134,23 @@ Key to symbols used in change notes below.
134134

135135
--------------------------------------------------------------------------
136136

137-
New functionality in 2023.1 Patch 1
137+
New functionality in 2023.2 (2023.2/2553501) (2024/02/07)
138+
139+
#2526799 (Job #117566) * **
140+
Updated P4API.NET to support 2023.2 release of Helix Core
141+
142+
#2539918 (Job #117014) * **
143+
Added support for 'Support Traits Depot' feature for fstat command
144+
145+
#2539918 (Job #117015) * **
146+
Added support for 'Support Traits Depot' feature for attribute command
147+
148+
#2546194 (Job #117018) * **
149+
Added support for --viewmatch argument in streams command
150+
151+
--------------------------------------------------------------------------
152+
153+
New functionality in 2023.1 Patch 1 (2023.1/2484623) (2023/09/05)
138154

139155
#2473015 (Job #116680) *
140156
The CreateClient() method is now backward compatible and no longer
@@ -155,7 +171,7 @@ New functionality in 2023.1 Patch 1
155171

156172
--------------------------------------------------------------------------
157173

158-
Bugs fixed in 2023.1 Patch 1
174+
Bugs fixed in 2023.1 Patch 1 (2023.1/2484623) (2023/09/05)
159175

160176
#2475194, #2475153 (Job #116804, #116653) *
161177
The GetProtectionTable() method now parses the comments in the
@@ -175,6 +191,14 @@ New functionality in 2023.1 (2023.1/2456134) (2023/06/20)
175191

176192
--------------------------------------------------------------------------
177193

194+
New functionality in 2022.2 Patch 2 (2022.2/2545965) (2024/01/30)
195+
196+
(Job #118909) *
197+
This release is built against P4API (2022.2/2531894),
198+
to address possible vulnerability: CVE-2023-5759.
199+
200+
--------------------------------------------------------------------------
201+
178202
New functionality in 2022.2 Patch 1 (2022.2/2432799) (2023/04/24)
179203

180204
#2431166 (Job #115331) *

p4api.net-unit-test/ClientTest.cs

Lines changed: 243 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4921,5 +4921,247 @@ public void MergeFilesTest()
49214921
}
49224922
}
49234923
}
4924-
}
4924+
4925+
/// <summary>
4926+
/// Test creation of new attribute on file and displays attributes using fstat command to check usage of new configurable trait.storagedepot.min.
4927+
/// </summary>
4928+
[TestMethod()]
4929+
[DynamicData(nameof(GetAttributeAndFstatTestData), DynamicDataSourceType.Method)]
4930+
public void AttributeAndFstatTest(int config_trait_storagedepot_min, string attributeName, object attributeValue, GetFileMetadataCmdFlags getFileMetadataCmdFlags, string expectedValue, bool useDbTraitTable = false)
4931+
{
4932+
Utilities.CheckpointType cptype = Utilities.CheckpointType.A;
4933+
4934+
string uri = configuration.ServerPort;
4935+
string user = "admin";
4936+
string pass = string.Empty;
4937+
string ws_client = "admin_space";
4938+
4939+
4940+
for (int i = 0; i < 1; i++) // run once for ascii, once for unicode
4941+
{
4942+
Process p4d = null;
4943+
Repository rep = null;
4944+
try
4945+
{
4946+
p4d = Utilities.DeployP4TestServer(TestDir, cptype, TestContext.TestName);
4947+
Assert.IsNotNull(p4d, "Setup Failure");
4948+
4949+
var clientRoot = Utilities.TestClientRoot(TestDir, cptype);
4950+
var adminSpace = Path.Combine(clientRoot, "admin_space");
4951+
Directory.CreateDirectory(adminSpace);
4952+
4953+
Server server = new Server(new ServerAddress(uri));
4954+
rep = new Repository(server);
4955+
Utilities.SetClientRoot(rep, TestDir, cptype, ws_client);
4956+
4957+
using (Connection con = rep.Connection)
4958+
{
4959+
con.UserName = user;
4960+
con.Client = new Client();
4961+
con.Client.Name = ws_client;
4962+
4963+
Assert.AreEqual(con.Status, ConnectionStatus.Disconnected);
4964+
Assert.AreEqual(con.Server.State, ServerState.Unknown);
4965+
Assert.IsTrue(con.Connect(null));
4966+
Assert.AreEqual(con.Server.State, ServerState.Online);
4967+
Assert.AreEqual(con.Status, ConnectionStatus.Connected);
4968+
Assert.AreEqual("admin", con.Client.OwnerName);
4969+
4970+
var codePath = Path.Combine(clientRoot, "admin_space", "MyCode");
4971+
4972+
Directory.CreateDirectory(codePath);
4973+
4974+
FileSpec fs = FileSpec.DepotSpec("//depot/MyCode/ReadMe.txt");
4975+
4976+
bool setRv;
4977+
4978+
if (config_trait_storagedepot_min >= 0)
4979+
{
4980+
logger.Debug("Set new configurable trait.storagedepot.min");
4981+
setRv = P4ConfigureSetAttributeStorageConfigurable(con, config_trait_storagedepot_min);
4982+
Assert.IsTrue(setRv);
4983+
}
4984+
4985+
logger.Debug("Checkout file {0} to set attribute.", fs.DepotPath.Path);
4986+
4987+
using (P4Command editCmd = new P4Command(rep, "edit", true, fs.DepotPath.Path))
4988+
{
4989+
4990+
P4CommandResult attributeResult = editCmd.Run();
4991+
4992+
}
4993+
4994+
logger.Debug("Adding new Attribute to the file {0}", fs.DepotPath.Path);
4995+
4996+
using (P4Command attributeCmd = new P4Command(rep, "attribute", true, fs.DepotPath.Path))
4997+
{
4998+
4999+
Options opts = new Options();
5000+
opts["-f"] = null;
5001+
opts["-n"] = attributeName;
5002+
opts["-v"] = attributeValue.ToString();
5003+
5004+
if (useDbTraitTable)
5005+
{
5006+
opts["-T0"] = null;
5007+
}
5008+
5009+
if (config_trait_storagedepot_min < 0)
5010+
{
5011+
opts["-T1"] = null;
5012+
}
5013+
5014+
string value = "";
5015+
5016+
try
5017+
{
5018+
//run command and get results
5019+
P4CommandResult results = attributeCmd.Run(opts);
5020+
results.TaggedOutput[0].TryGetValue("status", out value);
5021+
}
5022+
catch (Exception ex)
5023+
{
5024+
// Check if we got expected exception while trying to add attribute using -T1 flag without setting new configurable.
5025+
Assert.AreEqual(ex.Message, expectedValue);
5026+
}
5027+
5028+
if (config_trait_storagedepot_min >= 0)
5029+
{
5030+
// confirm if attribute is added successfully to the file.
5031+
Assert.AreEqual(value, "set");
5032+
Options ops = new Options();
5033+
switch (getFileMetadataCmdFlags)
5034+
{
5035+
case GetFileMetadataCmdFlags.Attributes:
5036+
ops["-Oa"] = null;
5037+
break;
5038+
5039+
case GetFileMetadataCmdFlags.AttributesProp:
5040+
ops["-On"] = null;
5041+
break;
5042+
}
5043+
5044+
IList<FileMetaData> actual = rep.GetFileMetaData(ops, fs);
5045+
5046+
Assert.AreEqual(true, actual?.Count > 0);
5047+
object attributeActualValue;
5048+
Assert.IsTrue(actual[0].Attributes.ContainsKey(attributeName));
5049+
Assert.IsTrue(actual[0].Attributes.TryGetValue(attributeName, out attributeActualValue));
5050+
5051+
switch (getFileMetadataCmdFlags)
5052+
{
5053+
// -Oa flag
5054+
case GetFileMetadataCmdFlags.Attributes:
5055+
Assert.AreEqual(opts["-v"], attributeActualValue);
5056+
break;
5057+
5058+
// -On flag
5059+
case GetFileMetadataCmdFlags.AttributesProp:
5060+
Assert.AreEqual(expectedValue, attributeActualValue);
5061+
break;
5062+
}
5063+
}
5064+
logger.Debug("Finished fstat");
5065+
}
5066+
}
5067+
}
5068+
finally
5069+
{
5070+
Utilities.RemoveTestServer(p4d, TestDir);
5071+
p4d?.Dispose();
5072+
rep?.Dispose();
5073+
}
5074+
5075+
cptype = Utilities.CheckpointType.U;
5076+
}
5077+
}
5078+
5079+
/// <summary>
5080+
/// Configure the server to set trait.storagedepot.min
5081+
/// Log in as "admin" and run "p4 configure set trait.storagedepot.min = value"
5082+
/// </summary>
5083+
/// <param name="con">Connection to server</param>
5084+
/// <param name="value">If set to a value greater than 0, the value of a newly created attribute is stored in the trait depot if its size in bytes matches or exceeds the setting of this configurable.</param>
5085+
/// <returns>true if no error</returns>
5086+
private bool P4ConfigureSetAttributeStorageConfigurable(Connection con, int value)
5087+
{
5088+
string oldUser = con.UserName;
5089+
con.UserName = "admin";
5090+
con.Login("");
5091+
5092+
// Tell the server to support parallel
5093+
string[] args = { "set", "trait.storagedepot.min=" + value };
5094+
using (var cmd = new P4Command(con, "configure", false, args))
5095+
{
5096+
var cmdr = cmd.Run(new Options());
5097+
// now force a reconnect, or p4d might not use the new config
5098+
con.getP4Server().Reconnect();
5099+
5100+
con.UserName = oldUser;
5101+
return cmdr.Success;
5102+
}
5103+
}
5104+
5105+
/// <summary>
5106+
/// Method is used by MSTest holds test data.
5107+
/// </summary>
5108+
/// <returns>Returns IEnumerable collection of test data</returns>
5109+
private static IEnumerable<object[]> GetAttributeAndFstatTestData()
5110+
{
5111+
// config_trait_storagedepot_min : trait.storagedepot.min=0
5112+
// attributeName: attribute name : FileID
5113+
// attributeValue: attribute value : 10
5114+
// getFileMetadataCmdFlags: fstat command flag : -Oa
5115+
// expectedValue: expected value from command result: 10
5116+
yield return new object[]
5117+
{
5118+
0,
5119+
"FileID",
5120+
10,
5121+
GetFileMetadataCmdFlags.Attributes,
5122+
"10"
5123+
};
5124+
yield return new object[]
5125+
{
5126+
1,
5127+
"InitialFileSize",
5128+
100,
5129+
GetFileMetadataCmdFlags.AttributesProp,
5130+
".p4traits"
5131+
};
5132+
yield return new object[]
5133+
{
5134+
-3,
5135+
"fileVersion",
5136+
100,
5137+
GetFileMetadataCmdFlags.AttributesProp,
5138+
"Trait depot storage has not been configured by 'trait.storagedepot.min'. This value must be greater than 0 to enable trait depot storage.\n"
5139+
};
5140+
yield return new object[]
5141+
{
5142+
3,
5143+
"IsFileReadOnly",
5144+
1,
5145+
GetFileMetadataCmdFlags.AttributesProp,
5146+
"db.traits"
5147+
};
5148+
yield return new object[]
5149+
{
5150+
3,
5151+
"FileSize",
5152+
"4000KB",
5153+
GetFileMetadataCmdFlags.AttributesProp,
5154+
".p4traits"
5155+
};
5156+
yield return new object[]
5157+
{
5158+
2,
5159+
"FileUsers",
5160+
"admin,super user",
5161+
GetFileMetadataCmdFlags.AttributesProp,
5162+
"db.traits",
5163+
true
5164+
};
5165+
}
5166+
}
49255167
}

p4api.net-unit-test/RepositoryTest.Depot.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ public void CheckDepotTypesTest(Utilities.CheckpointType cptype)
506506
d.Type = DepotType.Remote;
507507
d.Map = "RemoteDepot/...";
508508
d.StreamDepth = "//StreamDepot/1";
509+
d.Address = new ServerAddress(con.getP4Server().Port);
509510

510511
rep.CreateDepot(d);
511512

@@ -549,8 +550,6 @@ public void CheckDepotTypesTest(Utilities.CheckpointType cptype)
549550

550551
rep.CreateDepot(d);
551552

552-
rep.CreateDepot(d);
553-
554553
d = new Depot();
555554
d.Id = "GraphDepot";
556555
d.Description = "created by perforce";
@@ -560,7 +559,7 @@ public void CheckDepotTypesTest(Utilities.CheckpointType cptype)
560559
d.StreamDepth = "//StreamDepot/1";
561560

562561
rep.CreateDepot(d);
563-
562+
564563
IList<Depot> dlist = rep.GetDepots();
565564

566565
Assert.IsTrue(dlist[0].Type.Equals(DepotType.Archive));

0 commit comments

Comments
 (0)