初始化

This commit is contained in:
2025-12-11 11:39:02 +08:00
commit 156d6ccb06
1708 changed files with 1162911 additions and 0 deletions

View File

@@ -0,0 +1,465 @@

#define __FT_TEST__
using Aliyun.Api.LOG;
using Aliyun.Api.LOG.Common.Communication;
using Aliyun.Api.LOG.Common.Utilities;
using Aliyun.Api.LOG.Data;
using Aliyun.Api.LOG.Utilities;
using Aliyun.Api.LOG.Request;
using Aliyun.Api.LOG.Response;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using System.Threading;
namespace LOGSDKTest
{
[TestClass]
public class ClientTest
{
private String RequestUri;
private String Host;
private IDictionary<String, String> Headers = new Dictionary<String, String>();
[TestMethod]
public void TestException()
{
LogClient client = new LogClient(ClientTestData.TEST_ENDPOINT, ClientTestData.TEST_ACCESSKEYID, ClientTestData.TEST_ACCESSKEY);
client.SetWebSend(MockSend);
//server error
try
{
GetLogsRequest request = new GetLogsRequest();
request.Project = ClientTestData.TEST_PROJECT;
request.Logstore = "server_error_return";
request.Query = "error";
request.Topic = "mockTopic";
request.From = 1000;
request.To = 2000;
request.Lines = 200;
request.Offset = 0;
GetLogsResponse response = null;
response = client.GetLogs(request);
Assert.Fail("server exception is not triggered");
}
catch (LogException exp)
{
Assert.IsTrue(exp.ErrorCode.CompareTo("SLSServerErrorTest") == 0);
}
//json error
try
{
GetLogsRequest request = new GetLogsRequest();
request.Project = ClientTestData.TEST_PROJECT;
request.Logstore = "response_json_error_field";
request.Query = "error";
request.Topic = "mockTopic";
request.From = 1000;
request.To = 2000;
request.Lines = 200;
request.Offset = 0;
GetLogsResponse response = null;
response = client.GetLogs(request);
Assert.Fail("json exception is not triggered");
}
catch (LogException exp)
{
Assert.IsTrue(exp.ErrorCode.CompareTo("SLSBadResponse") == 0);
}
try
{
GetLogsRequest request = new GetLogsRequest();
request.Project = ClientTestData.TEST_PROJECT;
request.Logstore = "response_json_error_format";
request.Query = "error";
request.Topic = "mockTopic";
request.From = 1000;
request.To = 2000;
request.Lines = 200;
request.Offset = 0;
GetLogsResponse response = null;
response = client.GetLogs(request);
Assert.Fail("json exception is not triggered");
}
catch (LogException exp)
{
Assert.IsTrue(exp.ErrorCode.CompareTo("SLSBadResponse") == 0);
}
//response stream error
try
{
GetLogsRequest request = new GetLogsRequest();
request.Project = ClientTestData.TEST_PROJECT;
request.Logstore = "response_stream_error";
request.Query = "error";
request.Topic = "mockTopic";
request.From = 1000;
request.To = 2000;
request.Lines = 200;
request.Offset = 0;
GetLogsResponse response = null;
response = client.GetLogs(request);
Assert.Fail("io exception is not triggered");
}
catch (LogException exp)
{
Assert.IsTrue(exp.ErrorCode.CompareTo("SLSBadResponse") == 0);
}
}
[TestMethod]
public void TestUrlEncode()
{
Assert.IsTrue(HttpUtils.UrlEncode(ClientTestData.TEST_URLENCODE.Key).CompareTo(ClientTestData.TEST_URLENCODE.Value) == 0);
}
[TestMethod]
public void TestDateOperation()
{
Assert.IsTrue(DateUtils.FormatRfc822Date(ClientTestData.TEST_DATEPARSER.Key).CompareTo(ClientTestData.TEST_DATEPARSER.Value) == 0);
}
[TestMethod]
public void TestCalcMD5()
{
Assert.IsTrue(LogClientTools.GetMd5Value(ClientTestData.TEST_COMPUTMD5.Key).CompareTo(ClientTestData.TEST_COMPUTMD5.Value) == 0);
}
[TestMethod]
public void TestCalcSignature()
{
String signature = LogClientTools.SigInternal(ClientTestData.TEST_SIGNATURE.Key, ClientTestData.TEST_ACCESSKEYID,ClientTestData.TEST_ACCESSKEY);
Assert.IsTrue(signature.CompareTo(ClientTestData.TEST_SIGNATURE.Value) == 0);
}
[TestMethod]
public void TestPutData()
{
LogClient client = new LogClient(ClientTestData.TEST_ENDPOINT, ClientTestData.TEST_ACCESSKEYID, ClientTestData.TEST_ACCESSKEY);
client.SetWebSend(MockSend);
LogGroup.Builder lgBuilder = LogGroup.CreateBuilder();
lgBuilder.Topic = "testTopic";
lgBuilder.Source = "127.0.0.1";
Aliyun.Api.LOG.Log.Builder logBuilder = Aliyun.Api.LOG.Log.CreateBuilder();
logBuilder.Time = 1000;
Aliyun.Api.LOG.Log.Types.Content.Builder contentBuilder = Aliyun.Api.LOG.Log.Types.Content.CreateBuilder();
contentBuilder.Key = "mockKey";
contentBuilder.Value = "mockValue";
logBuilder.AddContents(contentBuilder);
lgBuilder.AddLogs(logBuilder);
LogGroup tmpLogGroup = lgBuilder.Build();
client.PutLogs(new PutLogsRequest(ClientTestData.TEST_PROJECT, "testlogstore"), tmpLogGroup);
Assert.IsTrue(DicToString(Headers).CompareTo("[x-sls-apiversion:0.4.0][x-sls-bodyrawsize:49][x-sls-signaturemethod:hmac-sha1][Content-Type:application/x-protobuf][x-sls-compresstype:deflate][Content-MD5:3D1836DDC6585AD78B60CCAE90C075DF][User-Agent:aliyun-sdk-dotnet/1.0.0.0]") == 0);
Assert.IsTrue(Host.CompareTo("mock_project.mockhost.aliyuncs.com") == 0);
Assert.IsTrue(RequestUri.CompareTo("http://mock_project.mockhost.aliyuncs.com/logstores/testlogstore") == 0);
}
[TestMethod]
public void TestLogClientWithRawIP()
{
try
{
LogClient client = new LogClient(ClientTestData.TEST_IP_ENDPOINT, ClientTestData.TEST_ACCESSKEYID, ClientTestData.TEST_ACCESSKEY);
Assert.Fail("sls doesn't support id address");
}
catch (LogException ex) {
Assert.IsTrue(ex.ErrorCode.CompareTo("LogClientError") == 0);
}
}
[TestMethod]
public void TestGetLogs()
{
LogClient client = new LogClient(ClientTestData.TEST_ENDPOINT, ClientTestData.TEST_ACCESSKEYID, ClientTestData.TEST_ACCESSKEY);
client.SetWebSend(MockSend);
GetLogsRequest request = new GetLogsRequest();
request.Project = ClientTestData.TEST_PROJECT;
request.Logstore = "testlogstore";
request.Query = "error";
request.Topic = "mockTopic";
request.From = 1000;
request.To = 2000;
request.Lines = 200;
request.Offset = 0;
GetLogsResponse response = client.GetLogs(request);
Assert.IsTrue(DicToString(Headers).CompareTo("[x-sls-apiversion:0.4.0][x-sls-bodyrawsize:0][x-sls-signaturemethod:hmac-sha1][User-Agent:aliyun-sdk-dotnet/1.0.0.0]") == 0);
Assert.IsTrue(response != null && response.Count == 2);
Assert.IsTrue(Host.CompareTo("mock_project.mockhost.aliyuncs.com") == 0);
Assert.IsTrue(RequestUri.CompareTo("http://mock_project.mockhost.aliyuncs.com/logstores/testlogstore?type=log&topic=mockTopic&from=1000&to=2000&query=error&line=200&offset=0") == 0);
}
[TestMethod]
public void TestListLogstore()
{
LogClient client = new LogClient(ClientTestData.TEST_ENDPOINT, ClientTestData.TEST_ACCESSKEYID, ClientTestData.TEST_ACCESSKEY);
client.SetWebSend(MockSend);
ListLogstoresRequest request = new ListLogstoresRequest();
request.Project = ClientTestData.TEST_PROJECT;
ListLogstoresResponse response = client.ListLogstores(request);
Assert.IsTrue(DicToString(Headers).CompareTo("[x-sls-apiversion:0.4.0][x-sls-bodyrawsize:0][x-sls-signaturemethod:hmac-sha1][User-Agent:aliyun-sdk-dotnet/1.0.0.0]") == 0);
Assert.IsTrue(response != null && response.Count == 3);
Assert.IsTrue(Host.CompareTo("mock_project.mockhost.aliyuncs.com") == 0);
Assert.IsTrue(RequestUri.CompareTo("http://mock_project.mockhost.aliyuncs.com/logstores") == 0);
}
[TestMethod]
public void TestGetHistograms()
{
LogClient client = new LogClient(ClientTestData.TEST_ENDPOINT, ClientTestData.TEST_ACCESSKEYID, ClientTestData.TEST_ACCESSKEY);
client.SetWebSend(MockSend);
GetHistogramsRequest request = new GetHistogramsRequest();
request.Project = ClientTestData.TEST_PROJECT;
request.Logstore = "testlogstore";
request.Query = "error";
request.Topic = "mockTopic";
request.From = 1000;
request.To = 2000;
GetHistogramsResponse response = client.GetHistograms(request);
Assert.IsTrue(DicToString(Headers).CompareTo("[x-sls-apiversion:0.4.0][x-sls-bodyrawsize:0][x-sls-signaturemethod:hmac-sha1][User-Agent:aliyun-sdk-dotnet/1.0.0.0]") == 0);
Assert.IsTrue(response != null && response.TotalCount == 2);
Assert.IsTrue(Host.CompareTo("mock_project.mockhost.aliyuncs.com") == 0);
Assert.IsTrue(RequestUri.CompareTo("http://mock_project.mockhost.aliyuncs.com/logstores/testlogstore?type=histogram&topic=mockTopic&from=1000&to=2000&query=error") == 0);
}
[TestMethod]
public void TestListTopics()
{
LogClient client = new LogClient(ClientTestData.TEST_ENDPOINT, ClientTestData.TEST_ACCESSKEYID, ClientTestData.TEST_ACCESSKEY);
client.SetWebSend(MockSend);
ListTopicsRequest request = new ListTopicsRequest();
request.Project = ClientTestData.TEST_PROJECT;
request.Logstore = "testlogstore";
request.Token = "atoken";
request.Lines = 100;
ListTopicsResponse response = client.ListTopics(request);
Assert.IsTrue(DicToString(Headers).CompareTo("[x-sls-apiversion:0.4.0][x-sls-bodyrawsize:0][x-sls-signaturemethod:hmac-sha1][User-Agent:aliyun-sdk-dotnet/1.0.0.0]") == 0);
Assert.IsTrue(response != null && response.Count == 2);
Assert.IsTrue(Host.CompareTo("mock_project.mockhost.aliyuncs.com") == 0);
Assert.IsTrue(RequestUri.CompareTo("http://mock_project.mockhost.aliyuncs.com/logstores/testlogstore?type=topic&token=atoken&line=100") == 0);
}
[TestMethod]
public void TestListTopicWithoutNextToken()
{
LogClient client = new LogClient(ClientTestData.TEST_ENDPOINT, ClientTestData.TEST_ACCESSKEYID, ClientTestData.TEST_ACCESSKEY);
client.SetWebSend(MockSend);
ListTopicsRequest request = new ListTopicsRequest();
request.Project = ClientTestData.TEST_PROJECT;
request.Logstore = "testlogstore_without_nexttoken";
request.Token = "atoken";
request.Lines = 100;
ListTopicsResponse response = client.ListTopics(request); ;
Assert.IsTrue(DicToString(Headers).CompareTo("[x-sls-apiversion:0.4.0][x-sls-bodyrawsize:0][x-sls-signaturemethod:hmac-sha1][User-Agent:aliyun-sdk-dotnet/1.0.0.0]") == 0);
Assert.IsTrue(response != null && response.Count == 2);
Assert.IsTrue(Host.CompareTo("mock_project.mockhost.aliyuncs.com") == 0);
Assert.IsTrue(RequestUri.CompareTo("http://mock_project.mockhost.aliyuncs.com/logstores/testlogstore_without_nexttoken?type=topic&token=atoken&line=100") == 0);
}
[TestMethod]
public void FT()
{
LogClient client = new LogClient("sls-failover.alibaba-inc.com", "", "");
uint topicFlag = DateUtils.TimeSpan();
int PUT_COUNT = 20, TOPIC_COUNT = 10, LOGITEM_COUNT = 20, CONTENT_COUNT = 10, SLEEP_INTERVAL = 2, SLEEP_TIME = 500;
for (int j = 1; j <= PUT_COUNT; ++j)
{
PutLogsRequest putLogsReqError = new PutLogsRequest();
putLogsReqError.Project = "ali-winlogtail-project";
putLogsReqError.Topic = "dotnet_topic_" + topicFlag + "_" + (j % TOPIC_COUNT);
putLogsReqError.Logstore = "sls-logstore-002";
putLogsReqError.LogItems = new List<LogItem>();
for (int i = 1; i <= LOGITEM_COUNT; ++i)
{
LogItem logItem = new LogItem();
logItem.Time = (uint)(topicFlag + j);
for (int k = 0; k < CONTENT_COUNT; ++k)
logItem.PushBack("error_" + (j % TOPIC_COUNT) + "_" + k, "invalid operation: " + i * j);
putLogsReqError.LogItems.Add(logItem);
}
PutLogsResponse putLogRespError = client.PutLogs(putLogsReqError);
if (j % SLEEP_INTERVAL == 0)
Thread.Sleep(SLEEP_TIME);
}
Thread.Sleep(50 * 1000);
ListLogstoresRequest req = new ListLogstoresRequest();
req.Project = "ali-winlogtail-project";
ListLogstoresResponse res = client.ListLogstores(req);
HashSet<String> logstoresSet = new HashSet<string>(res.Logstores);
Assert.IsTrue(logstoresSet.Contains("sls-logstore-002"));
ListTopicsRequest topicReq = new ListTopicsRequest();
topicReq.Project = "ali-winlogtail-project";
topicReq.Logstore = "sls-logstore-002";
topicReq.Lines = TOPIC_COUNT;
topicReq.Token = "dotnet_topic_" + topicFlag + "_";
ListTopicsResponse lstTopicsRequest = client.ListTopics(topicReq);
Assert.IsTrue(lstTopicsRequest.Count >= TOPIC_COUNT);
HashSet<String> topicSet = new HashSet<string>(lstTopicsRequest.Topics);
for (int i = 0; i < TOPIC_COUNT; ++i)
Assert.IsTrue(topicSet.Contains("dotnet_topic_" + topicFlag + "_" + i));
Thread.Sleep(SLEEP_TIME);
for (int i = 0; i < TOPIC_COUNT; ++i)
{
GetHistogramsRequest histReq = new GetHistogramsRequest();
histReq.Project = "ali-winlogtail-project";
histReq.Logstore = "sls-logstore-002";
histReq.Topic = "dotnet_topic_" + topicFlag + "_" + i;
histReq.To = (uint)(topicFlag + PUT_COUNT + 1);
histReq.From = (uint)topicFlag;
GetHistogramsResponse histResp = client.GetHistograms(histReq);
Assert.IsTrue(histResp.TotalCount == (PUT_COUNT / TOPIC_COUNT) * LOGITEM_COUNT);
if ((i + 1) % SLEEP_INTERVAL == 0)
Thread.Sleep(SLEEP_TIME);
}
Thread.Sleep(SLEEP_TIME);
for (int i = 0; i < TOPIC_COUNT; ++i)
for (int k = 0; k < 2; ++k)
{
GetHistogramsRequest histReq = new GetHistogramsRequest();
histReq.Project = "ali-winlogtail-project";
histReq.Logstore = "sls-logstore-002";
histReq.Topic = "dotnet_topic_" + topicFlag + "_" + i;
histReq.Query = "error_" + i + "_" + k;
histReq.To = (uint)(topicFlag + PUT_COUNT + 1);
histReq.From = (uint)topicFlag;
GetHistogramsResponse histResp = client.GetHistograms(histReq);
Assert.IsTrue(histResp.TotalCount == (PUT_COUNT / TOPIC_COUNT) * LOGITEM_COUNT);
if ((k +1)*(i + 1) % SLEEP_INTERVAL == 0)
Thread.Sleep(SLEEP_TIME);
}
Thread.Sleep(SLEEP_TIME);
for (int i = 0; i < TOPIC_COUNT; ++i)
{
GetLogsRequest getLogsReq = new GetLogsRequest();
getLogsReq.Project = "ali-winlogtail-project";
getLogsReq.Logstore = "sls-logstore-002";
getLogsReq.Topic = "dotnet_topic_" + topicFlag + "_" + i;
getLogsReq.Lines = 120;
getLogsReq.To = (uint)(topicFlag + PUT_COUNT + 1);
getLogsReq.From = (uint)topicFlag;
GetLogsResponse getLogsResp = client.GetLogs(getLogsReq);
Assert.IsTrue(getLogsResp.Count == (PUT_COUNT / TOPIC_COUNT) * LOGITEM_COUNT);
String logs = getLogsResp.Print();
for (int m = 0; m < CONTENT_COUNT; ++m)
{
String dstStr = "error_" + i + "_" + m;
Assert.IsTrue(ChildStringOccurTimes(logs, dstStr) == getLogsResp.Count);
}
if ((i + 1) % SLEEP_INTERVAL == 0)
Thread.Sleep(SLEEP_TIME);
}
Thread.Sleep(SLEEP_TIME);
for (int i = 0; i < TOPIC_COUNT; ++i)
for (int k = 0; k < 2; ++k)
{
GetLogsRequest getLogsReq = new GetLogsRequest();
getLogsReq.Project = "ali-winlogtail-project";
getLogsReq.Logstore = "sls-logstore-002";
getLogsReq.Topic = "dotnet_topic_" + topicFlag + "_" + i;
getLogsReq.Query = "error_" + i + "_" + k;
getLogsReq.Lines = 120;
getLogsReq.To = (uint)(topicFlag + PUT_COUNT + 1);
getLogsReq.From = (uint)topicFlag;
GetLogsResponse getLogsResp = client.GetLogs(getLogsReq);
Assert.IsTrue(getLogsResp.Count == (PUT_COUNT / TOPIC_COUNT) * LOGITEM_COUNT);
String logs = getLogsResp.Print();
for (int m = 0; m < CONTENT_COUNT; ++m)
{
String dstStr = "error_" + i + "_" + m;
Assert.IsTrue(ChildStringOccurTimes(logs, dstStr) == getLogsResp.Count);
}
if ((k + 1) * (i + 1) % SLEEP_INTERVAL == 0)
Thread.Sleep(SLEEP_TIME);
}
Console.WriteLine();
}
private Aliyun.Api.LOG.Common.Communication.ServiceClientImpl.ResponseImpl MockSend(HttpWebRequest request)
{
RequestUri = request.RequestUri.ToString();
//not supported by.Net35
Host = request.Host;
Headers.Clear();
string[] headers = request.Headers.AllKeys;
foreach (string s in headers)
{
Headers.Add(s, request.Headers.Get(s));
}
Aliyun.Api.LOG.Common.Communication.ServiceClientImpl.ResponseImpl response = new Aliyun.Api.LOG.Common.Communication.ServiceClientImpl.ResponseImpl();
if (request.Address.AbsoluteUri.ToString().StartsWith("http://mock_project.mockhost.aliyuncs.com/logstores/testlogstore?type=histogram"))
{
response.Content = new MemoryStream(Encoding.UTF8.GetBytes(ClientTestData.JSON_GETSTATUS));
}
else if (request.Address.AbsoluteUri.ToString().StartsWith("http://mock_project.mockhost.aliyuncs.com/logstores/testlogstore?type=topic"))
{
response.Content = new MemoryStream(Encoding.UTF8.GetBytes(ClientTestData.JSON_LISTTOPICS));
}
else if (request.Address.AbsoluteUri.ToString().StartsWith("http://mock_project.mockhost.aliyuncs.com/logstores/testlogstore_without_nexttoken?type=topic"))
{
response.Content = new MemoryStream(Encoding.UTF8.GetBytes(ClientTestData.JSON_LISTTOPICS_WITHOUT_NEXTTOKEN));
}
else if (request.Address.AbsoluteUri.ToString().StartsWith("http://mock_project.mockhost.aliyuncs.com/logstores/testlogstore"))
{
response.Content = new MemoryStream(Encoding.UTF8.GetBytes(ClientTestData.JSON_GETLOGS));
}
else if (request.Address.AbsoluteUri.ToString().StartsWith("http://mock_project.mockhost.aliyuncs.com/logstores/server_error_return"))
{
#if(!__FT_TEST__)
response.StatusCode = HttpStatusCode.NotAcceptable;
#endif
response.Content = new MemoryStream(Encoding.UTF8.GetBytes("{\"error_code\":\"SLSServerErrorTest\",\"error_message\":\"server error\"}"));
}
else if (request.Address.AbsoluteUri.ToString().StartsWith("http://mock_project.mockhost.aliyuncs.com/logstores/response_json_error_field"))
{
response.Content = new MemoryStream(Encoding.UTF8.GetBytes(ClientTestData.ERROR_JSON_GETLOGS_FIELD));
}
else if (request.Address.AbsoluteUri.ToString().StartsWith("http://mock_project.mockhost.aliyuncs.com/logstores/response_json_error_format"))
{
response.Content = new MemoryStream(Encoding.UTF8.GetBytes(ClientTestData.ERROR_JSON_GETLOGS_FORMAT));
}
else if (request.Address.AbsoluteUri.ToString().StartsWith("http://mock_project.mockhost.aliyuncs.com/logstores/response_stream_error"))
{
response.Content = new CannotReadStream();
}
else if (request.Address.AbsoluteUri.ToString().StartsWith("http://mock_project.mockhost.aliyuncs.com/logstores"))
{
response.Content = new MemoryStream(Encoding.UTF8.GetBytes(ClientTestData.JSON_LISTLOGSTORES));
}
return response;
}
private static String DicToString(IDictionary<String, String> Headers)
{
if (Headers == null || Headers.Count == 0)
return null;
StringBuilder sb = new StringBuilder();
foreach (KeyValuePair<String, String> pair in Headers)
{
if (pair.Key.CompareTo(LogConsts.NAME_HEADER_DATE) != 0 && pair.Key.CompareTo(LogConsts.NAME_HEADER_AUTH) != 0)
sb.Append("[" + pair.Key + ":" + pair.Value + "]");
}
return sb.ToString();
}
private static int ChildStringOccurTimes(String src, String dst,int start = 0)
{
int index = -1;
if ((index = src.IndexOf(dst, start)) < 0)
return 0;
return 1 + ChildStringOccurTimes(src, dst, index + dst.Length);
}
}
}

View File

@@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LOGSDKTest
{
internal class ClientTestData
{
public static KeyValuePair<String, String> TEST_URLENCODE = new KeyValuePair<String, String>("slssdk0.4&#%$ @!*", "slssdk0.4%26%23%25%24%20%40%21%2A");
public static KeyValuePair<DateTime, String> TEST_DATEPARSER = new KeyValuePair<DateTime, string>(new DateTime(2008, 3, 9, 16, 5, 7, 123), "Sun, 09 Mar 2008 08:05:07 GMT");
public static KeyValuePair<byte[], String> TEST_COMPUTMD5 = new KeyValuePair<byte[], String>(new byte[] { 9, 8, 1, 0, 13, 19 }, "6E809AA357CAB045F134D9B67B259C4F");
public static KeyValuePair<String, String> TEST_SIGNATURE = new KeyValuePair<String, String>("http://mock_project.mockhost.aliyuncs.com/logstores/testlogstore", "SLS mockkeyid:to3k5R5HMjZhBk8gO2sJRilcKFQ=");
public static String TEST_ENDPOINT = "http://mockhost.aliyuncs.com";
public static String TEST_IP_ENDPOINT = "http://192.168.1.101";
public static String TEST_PROJECT = "mock_project";
public static String TEST_ACCESSKEYID = "mockkeyid";
public static String TEST_ACCESSKEY = "mockkey";
public static String JSON_LISTLOGSTORES = "{ \"count\": 3, \"logstores\":[\"app_log\", \"access_log\", \"op_log\"] }";
public static String JSON_LISTTOPICS = "{ \"count\": 2, \"next_token\":\"Topic2\", \"topics\": [\"Topic1\", \"Topic2\"] }";
public static String JSON_LISTTOPICS_WITHOUT_NEXTTOKEN = "{ \"count\": 2, \"topics\": [\"Topic1\", \"Topic2\"] }";
public static String JSON_GETSTATUS = "{\"progress\":\"Complete\",\"count\": 2,\"histograms\":[{\"from\":1459001650,\"to\":1459001690,\"count\":11234,\"progress\":\"Complete\"},{\"from\":1459001790,\"to\":1459001990,\"count\":11234,\"progress\":\"Complete\"}]}";
public static String JSON_GETLOGS = "{\"count\":2,\"progress\":\"Complete\",\"logs\":[{\"__time__\" : 1450900861, \"__source__\" : \"10.237.0.17\",\"Key1\" : \"Value1\",\"Key2\" : \"Value2\"},{\"__time__\" : 1450900862, \"__source__\" : \"10.237.0.17\",\"Key1\" : \"Value1\",\"Key2\" : \"Value2\"}]}";
public static String ERROR_JSON_GETLOGS_FIELD = "{\"total\":2,\"progress\":\"Complete\",\"logs\":[{\"__time__\" : 1450900861, \"__source__\" : \"10.237.0.17\",\"Key1\" : \"Value1\",\"Key2\" : \"Value2\"},{\"__time__\" : 1450900862, \"__source__\" : \"10.237.0.17\",\"Key1\" : \"Value1\",\"Key2\" : \"Value2\"}]}";
public static String ERROR_JSON_GETLOGS_FORMAT = "{\"count\":2,\"progress\":\"Complete\",\"logs\":{{\"__time__\" : 1450900861, \"__source__\" : \"10.237.0.17\",\"Key1\" : \"Value1\",\"Key2\" : \"Value2\"},{\"__time__\" : 1450900862, \"__source__\" : \"10.237.0.17\",\"Key1\" : \"Value1\",\"Key2\" : \"Value2\"}]}";
}
internal class CannotReadStream : Stream
{
public override bool CanRead
{
get { throw new NotImplementedException(); }
}
public override bool CanSeek
{
get { throw new NotImplementedException(); }
}
public override bool CanWrite
{
get { throw new NotImplementedException(); }
}
public override void Flush()
{
throw new NotImplementedException();
}
public override long Length
{
get { throw new NotImplementedException(); }
}
public override long Position
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public override int Read(byte[] buffer, int offset, int count)
{
throw new NotImplementedException();
}
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotImplementedException();
}
public override void SetLength(long value)
{
throw new NotImplementedException();
}
public override void Write(byte[] buffer, int offset, int count)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SLSSDKTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SLSSDKTest")]
[assembly: AssemblyCopyright("Copyright © Aliyun 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("6c641d0e-f75e-4ca7-b398-f3b183e0d097")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{DF3F2C8B-0D0A-41D0-B862-3A36DEFD97A1}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LOGSDKTest</RootNamespace>
<AssemblyName>LOGSDKTest</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\net40\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\net40\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Google.ProtocolBuffers">
<HintPath>..\3rdParties\prtotbuf\net40\Google.ProtocolBuffers.dll</HintPath>
</Reference>
<Reference Include="Google.ProtocolBuffers.Serialization">
<HintPath>..\3rdParties\prtotbuf\net40\Google.ProtocolBuffers.Serialization.dll</HintPath>
</Reference>
<Reference Include="LZ4Sharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\3rdParties\lz4\net40\LZ4Sharp.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\3rdParties\Json60r3\Bin\Net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="zlibnet">
<HintPath>..\3rdParties\zlib\net40\zlibnet.dll</HintPath>
</Reference>
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
</ItemGroup>
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="ClientTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ClientTestData.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SLSSDK\SLSSDK40.csproj">
<Project>{4dbae4c0-1b9a-4bd0-a9d3-8029ae319287}</Project>
<Name>SLSSDK40</Name>
</ProjectReference>
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
</ItemGroup>
</When>
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>