Skip to content

Commit b9cd550

Browse files
author
邹嵩
committed
添加测试用例
1 parent 24b75ad commit b9cd550

File tree

7 files changed

+36
-18
lines changed

7 files changed

+36
-18
lines changed

nuget/DotnetSpider.Core.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
33
<metadata>
44
<id>DotnetSpider2.Core</id>
5-
<version>2.3.7-beta5</version>
5+
<version>2.3.7-beta6</version>
66
<authors>zlzforever@163.com;Walterwhatwater;xiaohuan0204</authors>
77
<owners>zlzforever@163.com</owners>
88
<iconUrl>https://github.com/zlzforever/DotnetSpider/blob/master/images/icon.png?raw=true</iconUrl>

nuget/DotnetSpider.Extension.nuspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
33
<metadata>
44
<id>DotnetSpider2.Extension</id>
5-
<version>2.3.7-beta5</version>
5+
<version>2.3.7-beta6</version>
66
<authors>zlzforever@163.com;Walterwhatwater;xiaohuan0204</authors>
77
<owners>zlzforever@163.com</owners>
88
<iconUrl>https://github.com/zlzforever/DotnetSpider/blob/master/images/icon.png?raw=true</iconUrl>
@@ -13,7 +13,7 @@
1313
<description>A .NET Standard web crawling library similar to WebMagic and Scrapy. It is a lightweight ,efficient and fast high-level web crawling &amp; scraping framework for .NET</description>
1414
<dependencies>
1515
<group targetFramework=".NETStandard2.0">
16-
<dependency id="DotnetSpider2.Core" version="2.3.7-beta5" />
16+
<dependency id="DotnetSpider2.Core" version="2.3.7-beta6" />
1717
<dependency id="Dapper" version="1.50.2"/>
1818
<dependency id="MailKit" version="1.20.0"/>
1919
<dependency id="MongoDB.Driver" version="2.4.4"/>
@@ -28,7 +28,7 @@
2828
<dependency id="MessagePack" version="1.7.2"/>
2929
</group>
3030
<group targetFramework=".NETFramework4.5" >
31-
<dependency id="DotnetSpider2.Core" version="2.3.7-beta5" />
31+
<dependency id="DotnetSpider2.Core" version="2.3.7-beta6" />
3232
<dependency id="Dapper" version="1.50.2"/>
3333
<dependency id="MailKit" version="1.20.0"/>
3434
<dependency id="MongoDB.Driver" version="2.4.4"/>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using Xunit;
5+
6+
namespace DotnetSpider.Core.Test
7+
{
8+
public class HttpExecuteRecordTest
9+
{
10+
[Fact]
11+
public void Record()
12+
{
13+
if (Env.IsWindows)
14+
{
15+
Env.EnterpiseServiceIncreaseRunningUrl = "http://localhost:30013/Task/IncreaseRunning";
16+
Env.EnterpiseServiceReduceRunningUrl = "http://localhost:30013/Task/ReduceRunning";
17+
var recorder = new HttpExecuteRecord();
18+
recorder.Add("-1", "test", "abcd");
19+
recorder.Remove("-1", "test", "abcd");
20+
}
21+
}
22+
}
23+
}

src/DotnetSpider.Core/Env.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,12 @@ public static class Env
157157
/// <summary>
158158
/// 向企业服务添加运行记录的地址
159159
/// </summary>
160-
public static string EnterpiseServiceIncreaseRunningUrl { get; private set; }
160+
public static string EnterpiseServiceIncreaseRunningUrl { get; internal set; }
161161

162162
/// <summary>
163163
/// 向企业服务删除运行记录的地址
164164
/// </summary>
165-
public static string EnterpiseServiceReduceRunningUrl { get; private set; }
165+
public static string EnterpiseServiceReduceRunningUrl { get; internal set; }
166166

167167
/// <summary>
168168
/// 访问企业服务时使用的凭证

src/DotnetSpider.Core/Spider.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ public class Spider : AppBase, ISpider, ISpeedMonitor
6363
private readonly List<IPipeline> _pipelines = new List<IPipeline>();
6464
private readonly List<IPageProcessor> _pageProcessors = new List<IPageProcessor>();
6565
private bool _exited;
66-
private ulong _downloadCostTime;
67-
private ulong _processorCostTime;
68-
private ulong _pipelineCostTime;
6966

7067
/// <summary>
7168
/// 是否需要通过StartUrlsBuilder来初始化起始链接
@@ -196,7 +193,7 @@ public override string Identity
196193
/// <summary>
197194
/// Set the retry times for pipeline.
198195
/// </summary>
199-
public int PipelineRetryTimes { get; set; } = 1;
196+
public int PipelineRetryTimes { get; set; } = 2;
200197

201198
/// <summary>
202199
/// Scheduler of spider.

src/DotnetSpider.Extension/CommonSpider.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,19 +263,19 @@ protected void RegisterControl(ISpider spider)
263263
}
264264
}
265265

266-
private bool IfRequireBuildStartRequests()
267-
{
268-
return RedisConnection.Default.Database.HashGet(InitStatusSetKey, Identity) != InitFinishedValue;
269-
}
270-
271266
/// <summary>
272267
/// 删除验证的锁, 让其它爬虫节点再次验证
273268
/// </summary>
274-
private void RemoveVerifidationLock()
269+
protected void RemoveVerifidationLock()
275270
{
276271
RedisConnection.Default?.Database.HashDelete(ValidateStatusKey, Identity);
277272
}
278273

274+
private bool IfRequireBuildStartRequests()
275+
{
276+
return RedisConnection.Default.Database.HashGet(InitStatusSetKey, Identity) != InitFinishedValue;
277+
}
278+
279279
/// <summary>
280280
/// 执行数据验证
281281
/// </summary>

src/DotnetSpider.Sample/Program.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ public static void Main(string[] args)
8080
/// </summary>
8181
private static void MyTest()
8282
{
83-
LogTest test = new LogTest();
84-
test.DatebaseLogAndStatus();
8583
}
8684
}
8785

0 commit comments

Comments
 (0)