Skip to content
This repository has been archived by the owner on Jul 7, 2019. It is now read-only.

Commit

Permalink
MemcachedTest now has a membase test.
Browse files Browse the repository at this point in the history
  • Loading branch information
enyim committed Aug 12, 2010
1 parent f53b1e7 commit 85c2e54
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 19 deletions.
46 changes: 46 additions & 0 deletions MemcachedTest/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />

<sectionGroup name="enyim.com">
<section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching" />
</sectionGroup>
Expand All @@ -15,6 +17,9 @@
<section name="validConfig" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching" />
<section name="textConfig" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching" />
<section name="binaryConfig" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching" />

<section name="northscaleMemcached" type="NorthScale.Store.Configuration.NorthScaleClientSection, NorthScale.Store" />
<section name="northscaleMembase" type="NorthScale.Store.Configuration.NorthScaleClientSection, NorthScale.Store" />
</sectionGroup>
</configSections>
<enyim.com>
Expand All @@ -27,6 +32,21 @@
</enyim.com>

<test>

<northscaleMembase>
<servers userName="Administrator" password="11111111">
<add uri="http://192.168.2.160:8080/pools/default" />
<add uri="http://192.168.2.162:8080/pools/default" />
</servers>
</northscaleMembase>

<northscaleMemcached>
<servers userName="Administrator" password="11111111">
<add uri="http://192.168.2.202:8080/pools/default" />
<add uri="http://192.168.2.200:8080/pools/default" />
</servers>
</northscaleMemcached>

<!-- type vs factory test -->

<newProviders>
Expand Down Expand Up @@ -96,4 +116,30 @@
</servers>
</invalidConfig>-->
</test>

<log4net>
<appender name="TraceAppender" type="log4net.Appender.TraceAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger %message%newline" />
</layout>
</appender>

<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" />
</layout>
</appender>

<appender name="OutputDebugStringAppender" type="log4net.Appender.OutputDebugStringAppender" >
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger %message%newline" />
</layout>
</appender>

<root>
<level value="Fatal" />
<appender-ref ref="TraceAppender" />
</root>
</log4net>

</configuration>
4 changes: 2 additions & 2 deletions MemcachedTest/MemcachedClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ protected string MakeRandomKey(int partCount)
}

[TestCase]
public void MultiGetTest()
public virtual void MultiGetTest()
{


// note, this test will fail, if memcached version is < 1.2.4
using (var client = GetClient())
Expand Down
6 changes: 6 additions & 0 deletions MemcachedTest/MemcachedTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
<Compile Include="BinaryMemcachedClientTest.cs" />
<Compile Include="ConfigTest.cs" />
<Compile Include="KetamaTest.cs" />
<Compile Include="NorthScaleMembaseClientTest.cs" />
<Compile Include="NorthScaleMemcachedClientTest.cs" />
<Compile Include="TextMemcachedClientTest.cs" />
<Compile Include="MemcachedClientTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand All @@ -76,6 +78,10 @@
<Project>{D438C0B3-A168-40B8-BDDD-61F0939DFF35}</Project>
<Name>Enyim.Caching</Name>
</ProjectReference>
<ProjectReference Include="..\Northscale.Store\Northscale.Store.csproj">
<Project>{708A2350-A26C-444D-B975-8164263951A7}</Project>
<Name>Northscale.Store</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
Expand Down
53 changes: 53 additions & 0 deletions MemcachedTest/NorthScaleMembaseClientTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Enyim.Caching;
using NUnit.Framework;

namespace MemcachedTest
{
/// <summary>
///This is a test class for Enyim.Caching.MemcachedClient and is intended
///to contain all Enyim.Caching.MemcachedClient Unit Tests
///</summary>
[TestFixture]
public class NorthScaleMembaseClientTest : BinaryMemcachedClientTest
{
protected override MemcachedClient GetClient()
{
var client = new NorthScale.Store.NorthScaleClient("test/northscaleMembase", null);
client.FlushAll();

return client;
}

[TestFixtureSetUp]
public void Init()
{
log4net.Config.XmlConfigurator.Configure();
}

[TestCase]
public override void MultiGetTest()
{
base.MultiGetTest();
}
}
}

#region [ License information ]
/* ************************************************************
*
* Copyright (c) 2010 Attila Kiskó, enyim.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ************************************************************/
#endregion
41 changes: 41 additions & 0 deletions MemcachedTest/NorthScaleMemcachedClientTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Enyim.Caching;
using NUnit.Framework;

namespace MemcachedTest
{
/// <summary>
///This is a test class for Enyim.Caching.MemcachedClient and is intended
///to contain all Enyim.Caching.MemcachedClient Unit Tests
///</summary>
[TestFixture]
public class NorthScaleMemcachedClientTest : BinaryMemcachedClientTest
{
protected override MemcachedClient GetClient()
{
var client = new NorthScale.Store.NorthScaleClient("test/northscaleMemcached", null);
client.FlushAll();

return client;
}
}
}

#region [ License information ]
/* ************************************************************
*
* Copyright (c) 2010 Attila Kiskó, enyim.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ************************************************************/
#endregion
38 changes: 21 additions & 17 deletions Northscale.Store/NorthScalePool.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#define DISABLE_VBUCKET
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
Expand Down Expand Up @@ -111,23 +112,26 @@ private void InitNodes(ClusterConfig config)
IMemcachedNodeLocator locator;
IList<IMemcachedNode> nodes;

#if !DISABLE_VBUCKET
if (config == null || config.vBucketServerMap == null)
{
// no vbucket config, use the node list and the ports
var portType = this.configuration.Port;

endpoints = config == null
? Enumerable.Empty<IPEndPoint>()
: (from node in config.nodes
where node.status == "healthy"
select new IPEndPoint(
IPAddress.Parse(node.hostname),
(portType == BucketPortType.Proxy
? node.ports.proxy
: node.ports.direct)));

locator = this.configuration.CreateNodeLocator() ?? new KetamaNodeLocator();
nodes = endpoints.Select(ip => new MemcachedNode(ip, this.configuration.SocketPool, auth)).ToArray();
#endif
// no vbucket config, use the node list and the ports
var portType = this.configuration.Port;

endpoints = config == null
? Enumerable.Empty<IPEndPoint>()
: (from node in config.nodes
where node.status == "healthy"
select new IPEndPoint(
IPAddress.Parse(node.hostname),
(portType == BucketPortType.Proxy
? node.ports.proxy
: node.ports.direct)));

locator = this.configuration.CreateNodeLocator() ?? new KetamaNodeLocator();
nodes = endpoints.Select(ip => new MemcachedNode(ip, this.configuration.SocketPool, auth)).ToArray();
#if !DISABLE_VBUCKET
}
else
{
Expand All @@ -149,7 +153,7 @@ private void InitNodes(ClusterConfig config)

nodes = endpoints.Select(ip => new MemcachedNode(ip, this.configuration.SocketPool, auth) { Bucket = Array.IndexOf(buckets, bucketNodeMap[ip].FirstOrDefault()) }).ToArray();
}

#endif
locator.Initialize(nodes);

Interlocked.Exchange(ref this.currentNodes, new ReadOnlyCollection<IMemcachedNode>(nodes));
Expand Down

0 comments on commit 85c2e54

Please sign in to comment.