2017-03-10 14:29:11 +00:00
|
|
|
package ipfshttp
|
2016-12-08 16:24:38 +00:00
|
|
|
|
|
|
|
import (
|
2017-03-29 20:52:13 +00:00
|
|
|
"bytes"
|
2018-04-16 09:01:20 +00:00
|
|
|
"context"
|
2016-12-08 16:24:38 +00:00
|
|
|
"fmt"
|
|
|
|
"testing"
|
2017-03-23 18:34:33 +00:00
|
|
|
"time"
|
2016-12-08 16:24:38 +00:00
|
|
|
|
2020-03-13 20:40:02 +00:00
|
|
|
logging "github.com/ipfs/go-log/v2"
|
2017-10-13 16:44:43 +00:00
|
|
|
ma "github.com/multiformats/go-multiaddr"
|
2018-04-20 04:09:07 +00:00
|
|
|
|
2019-10-22 05:40:32 +00:00
|
|
|
merkledag "github.com/ipfs/go-merkledag"
|
2022-06-15 09:19:17 +00:00
|
|
|
"github.com/ipfs-cluster/ipfs-cluster/api"
|
|
|
|
"github.com/ipfs-cluster/ipfs-cluster/test"
|
2016-12-08 16:24:38 +00:00
|
|
|
)
|
|
|
|
|
2017-03-23 18:34:33 +00:00
|
|
|
func init() {
|
|
|
|
_ = logging.Logger
|
Adders: stream blocks to destinations
This commit fixes #810 and adds block streaming to the final destinations when
adding. This should add major performance gains when adding data to clusters.
Before, everytime cluster issued a block, it was broadcasted individually to
all destinations (new libp2p stream), where it was block/put to IPFS (a single
block/put http roundtrip per block).
Now, blocks are streamed all the way from the adder module to the ipfs daemon,
by making every block as it arrives a single part in a multipart block/put
request.
Before, block-broadcast needed to wait for all destinations to finish in order
to process the next block. Now, buffers allow some destinations to be faster
than others while sending and receiving blocks.
Before, if a block put request failed to be broadcasted everywhere, an error
would happen at that moment.
Now, we keep streaming until the end and only then report any errors. The
operation succeeds as long as at least one stream finished successfully.
Errors block/putting to IPFS will not abort streams. Instead, subsequent
blocks are retried with a new request, although the method will return an
error when the stream finishes if there were errors at any point.
2022-03-24 01:17:10 +00:00
|
|
|
logging.SetLogLevel("*", "DEBUG")
|
2017-03-23 18:34:33 +00:00
|
|
|
}
|
|
|
|
|
2017-03-14 15:37:29 +00:00
|
|
|
func testIPFSConnector(t *testing.T) (*Connector, *test.IpfsMock) {
|
2019-02-20 14:24:25 +00:00
|
|
|
mock := test.NewIpfsMock(t)
|
2021-07-02 00:20:39 +00:00
|
|
|
nodeMAddr := ma.StringCast(fmt.Sprintf("/ip4/%s/tcp/%d", mock.Addr, mock.Port))
|
2016-12-08 16:24:38 +00:00
|
|
|
|
Issue #162: Rework configuration format
The following commit reimplements ipfs-cluster configuration under
the following premises:
* Each component is initialized with a configuration object
defined by its module
* Each component decides how the JSON representation of its
configuration looks like
* Each component parses and validates its own configuration
* Each component exposes its own defaults
* Component configurations are make the sections of a
central JSON configuration file (which replaces the current
JSON format)
* Component configurations implement a common interface
(config.ComponentConfig) with a set of common operations
* The central configuration file is managed by a
config.ConfigManager which:
* Registers ComponentConfigs
* Assigns the correspondent sections from the JSON file to each
component and delegates the parsing
* Delegates the JSON generation for each section
* Can be notified when the configuration is updated and must be
saved to disk
The new service.json would then look as follows:
```json
{
"cluster": {
"id": "QmTVW8NoRxC5wBhV7WtAYtRn7itipEESfozWN5KmXUQnk2",
"private_key": "<...>",
"secret": "00224102ae6aaf94f2606abf69a0e278251ecc1d64815b617ff19d6d2841f786",
"peers": [],
"bootstrap": [],
"leave_on_shutdown": false,
"listen_multiaddress": "/ip4/0.0.0.0/tcp/9096",
"state_sync_interval": "1m0s",
"ipfs_sync_interval": "2m10s",
"replication_factor": -1,
"monitor_ping_interval": "15s"
},
"consensus": {
"raft": {
"heartbeat_timeout": "1s",
"election_timeout": "1s",
"commit_timeout": "50ms",
"max_append_entries": 64,
"trailing_logs": 10240,
"snapshot_interval": "2m0s",
"snapshot_threshold": 8192,
"leader_lease_timeout": "500ms"
}
},
"api": {
"restapi": {
"listen_multiaddress": "/ip4/127.0.0.1/tcp/9094",
"read_timeout": "30s",
"read_header_timeout": "5s",
"write_timeout": "1m0s",
"idle_timeout": "2m0s"
}
},
"ipfs_connector": {
"ipfshttp": {
"proxy_listen_multiaddress": "/ip4/127.0.0.1/tcp/9095",
"node_multiaddress": "/ip4/127.0.0.1/tcp/5001",
"connect_swarms_delay": "7s",
"proxy_read_timeout": "10m0s",
"proxy_read_header_timeout": "5s",
"proxy_write_timeout": "10m0s",
"proxy_idle_timeout": "1m0s"
}
},
"monitor": {
"monbasic": {
"check_interval": "15s"
}
},
"informer": {
"disk": {
"metric_ttl": "30s",
"metric_type": "freespace"
},
"numpin": {
"metric_ttl": "10s"
}
}
}
```
This new format aims to be easily extensible per component. As such,
it already surfaces quite a few new options which were hardcoded
before.
Additionally, since Go API have changed, some redundant methods have been
removed and small refactoring has happened to take advantage of the new
way.
License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
2017-10-11 18:23:03 +00:00
|
|
|
cfg := &Config{}
|
|
|
|
cfg.Default()
|
|
|
|
cfg.NodeAddr = nodeMAddr
|
|
|
|
cfg.ConnectSwarmsDelay = 0
|
2022-01-31 16:44:35 +00:00
|
|
|
cfg.InformerTriggerInterval = 10
|
Issue #162: Rework configuration format
The following commit reimplements ipfs-cluster configuration under
the following premises:
* Each component is initialized with a configuration object
defined by its module
* Each component decides how the JSON representation of its
configuration looks like
* Each component parses and validates its own configuration
* Each component exposes its own defaults
* Component configurations are make the sections of a
central JSON configuration file (which replaces the current
JSON format)
* Component configurations implement a common interface
(config.ComponentConfig) with a set of common operations
* The central configuration file is managed by a
config.ConfigManager which:
* Registers ComponentConfigs
* Assigns the correspondent sections from the JSON file to each
component and delegates the parsing
* Delegates the JSON generation for each section
* Can be notified when the configuration is updated and must be
saved to disk
The new service.json would then look as follows:
```json
{
"cluster": {
"id": "QmTVW8NoRxC5wBhV7WtAYtRn7itipEESfozWN5KmXUQnk2",
"private_key": "<...>",
"secret": "00224102ae6aaf94f2606abf69a0e278251ecc1d64815b617ff19d6d2841f786",
"peers": [],
"bootstrap": [],
"leave_on_shutdown": false,
"listen_multiaddress": "/ip4/0.0.0.0/tcp/9096",
"state_sync_interval": "1m0s",
"ipfs_sync_interval": "2m10s",
"replication_factor": -1,
"monitor_ping_interval": "15s"
},
"consensus": {
"raft": {
"heartbeat_timeout": "1s",
"election_timeout": "1s",
"commit_timeout": "50ms",
"max_append_entries": 64,
"trailing_logs": 10240,
"snapshot_interval": "2m0s",
"snapshot_threshold": 8192,
"leader_lease_timeout": "500ms"
}
},
"api": {
"restapi": {
"listen_multiaddress": "/ip4/127.0.0.1/tcp/9094",
"read_timeout": "30s",
"read_header_timeout": "5s",
"write_timeout": "1m0s",
"idle_timeout": "2m0s"
}
},
"ipfs_connector": {
"ipfshttp": {
"proxy_listen_multiaddress": "/ip4/127.0.0.1/tcp/9095",
"node_multiaddress": "/ip4/127.0.0.1/tcp/5001",
"connect_swarms_delay": "7s",
"proxy_read_timeout": "10m0s",
"proxy_read_header_timeout": "5s",
"proxy_write_timeout": "10m0s",
"proxy_idle_timeout": "1m0s"
}
},
"monitor": {
"monbasic": {
"check_interval": "15s"
}
},
"informer": {
"disk": {
"metric_ttl": "30s",
"metric_type": "freespace"
},
"numpin": {
"metric_ttl": "10s"
}
}
}
```
This new format aims to be easily extensible per component. As such,
it already surfaces quite a few new options which were hardcoded
before.
Additionally, since Go API have changed, some redundant methods have been
removed and small refactoring has happened to take advantage of the new
way.
License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
2017-10-11 18:23:03 +00:00
|
|
|
|
|
|
|
ipfs, err := NewConnector(cfg)
|
2016-12-08 16:24:38 +00:00
|
|
|
if err != nil {
|
2016-12-08 18:04:28 +00:00
|
|
|
t.Fatal("creating an IPFSConnector should work: ", err)
|
2016-12-08 16:24:38 +00:00
|
|
|
}
|
2018-08-18 00:45:47 +00:00
|
|
|
|
2017-02-09 15:29:17 +00:00
|
|
|
ipfs.SetClient(test.NewMockRPCClient(t))
|
2016-12-16 16:22:37 +00:00
|
|
|
return ipfs, mock
|
2016-12-08 18:04:28 +00:00
|
|
|
}
|
|
|
|
|
2017-03-14 15:37:29 +00:00
|
|
|
func TestNewConnector(t *testing.T) {
|
2018-06-27 04:03:15 +00:00
|
|
|
ctx := context.Background()
|
2016-12-23 18:35:37 +00:00
|
|
|
ipfs, mock := testIPFSConnector(t)
|
2016-12-16 16:22:37 +00:00
|
|
|
defer mock.Close()
|
2018-06-27 04:03:15 +00:00
|
|
|
defer ipfs.Shutdown(ctx)
|
2016-12-08 18:04:28 +00:00
|
|
|
}
|
2016-12-08 16:24:38 +00:00
|
|
|
|
2017-01-26 18:59:31 +00:00
|
|
|
func TestIPFSID(t *testing.T) {
|
2018-06-27 04:03:15 +00:00
|
|
|
ctx := context.Background()
|
2017-01-26 18:59:31 +00:00
|
|
|
ipfs, mock := testIPFSConnector(t)
|
2018-06-27 04:03:15 +00:00
|
|
|
defer ipfs.Shutdown(ctx)
|
|
|
|
id, err := ipfs.ID(ctx)
|
2017-01-26 18:59:31 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2019-02-27 20:19:10 +00:00
|
|
|
if id.ID != test.PeerID1 {
|
2017-01-26 18:59:31 +00:00
|
|
|
t.Error("expected testPeerID")
|
|
|
|
}
|
2020-02-28 16:16:16 +00:00
|
|
|
if len(id.Addresses) != 2 {
|
|
|
|
t.Error("expected 2 address")
|
2017-01-26 18:59:31 +00:00
|
|
|
}
|
|
|
|
if id.Error != "" {
|
|
|
|
t.Error("expected no error")
|
|
|
|
}
|
|
|
|
mock.Close()
|
2020-04-14 17:58:00 +00:00
|
|
|
_, err = ipfs.ID(ctx)
|
2017-01-26 18:59:31 +00:00
|
|
|
if err == nil {
|
|
|
|
t.Error("expected an error")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-09 14:45:54 +00:00
|
|
|
func TestPin(t *testing.T) {
|
2018-04-16 09:01:20 +00:00
|
|
|
ctx := context.Background()
|
2016-12-23 18:35:37 +00:00
|
|
|
ipfs, mock := testIPFSConnector(t)
|
2016-12-16 16:22:37 +00:00
|
|
|
defer mock.Close()
|
2018-06-27 04:03:15 +00:00
|
|
|
defer ipfs.Shutdown(ctx)
|
2016-12-16 16:22:37 +00:00
|
|
|
|
2020-04-20 14:21:27 +00:00
|
|
|
pin := api.PinCid(test.Cid1)
|
2021-12-13 16:31:18 +00:00
|
|
|
pin.Origins = []api.Multiaddr{
|
|
|
|
api.NewMultiaddrWithValue(ma.StringCast("/ip4/1.2.3.4/tcp/1234/p2p/12D3KooWKewdAMAU3WjYHm8qkAJc5eW6KHbHWNigWraXXtE1UCng")),
|
|
|
|
api.NewMultiaddrWithValue(ma.StringCast("/ip4/2.3.3.4/tcp/1234/p2p/12D3KooWF6BgwX966ge5AVFs9Gd2wVTBmypxZVvaBR12eYnUmXkR")),
|
2021-07-02 00:09:27 +00:00
|
|
|
}
|
2020-04-20 14:21:27 +00:00
|
|
|
err := ipfs.Pin(ctx, pin)
|
2018-03-07 13:51:37 +00:00
|
|
|
if err != nil {
|
2019-05-17 14:26:27 +00:00
|
|
|
t.Error("expected success pinning cid:", err)
|
2018-03-07 13:51:37 +00:00
|
|
|
}
|
2020-04-20 14:21:27 +00:00
|
|
|
pinSt, err := ipfs.PinLsCid(ctx, pin)
|
2018-03-07 13:51:37 +00:00
|
|
|
if err != nil {
|
2019-05-17 14:26:27 +00:00
|
|
|
t.Fatal("expected success doing ls:", err)
|
2018-03-07 13:51:37 +00:00
|
|
|
}
|
2018-07-23 09:14:43 +00:00
|
|
|
if !pinSt.IsPinned(-1) {
|
2018-03-07 13:51:37 +00:00
|
|
|
t.Error("cid should have been pinned")
|
|
|
|
}
|
|
|
|
|
2020-04-20 14:21:27 +00:00
|
|
|
pin2 := api.PinCid(test.ErrorCid)
|
|
|
|
err = ipfs.Pin(ctx, pin2)
|
2018-03-07 13:51:37 +00:00
|
|
|
if err == nil {
|
|
|
|
t.Error("expected error pinning cid")
|
|
|
|
}
|
2019-05-28 08:35:04 +00:00
|
|
|
|
2019-08-09 14:45:54 +00:00
|
|
|
ipfs.config.PinTimeout = 5 * time.Second
|
|
|
|
c4 := test.SlowCid1
|
|
|
|
err = ipfs.Pin(ctx, api.PinCid(c4))
|
|
|
|
if err == nil {
|
|
|
|
t.Error("expected error pinning cid")
|
2019-05-28 08:35:04 +00:00
|
|
|
}
|
2018-03-07 13:51:37 +00:00
|
|
|
}
|
|
|
|
|
2019-08-09 14:45:54 +00:00
|
|
|
func TestPinUpdate(t *testing.T) {
|
2019-07-12 14:40:29 +00:00
|
|
|
ctx := context.Background()
|
|
|
|
ipfs, mock := testIPFSConnector(t)
|
|
|
|
defer mock.Close()
|
|
|
|
defer ipfs.Shutdown(ctx)
|
|
|
|
|
|
|
|
pin := api.PinCid(test.Cid1)
|
|
|
|
pin.PinUpdate = test.Cid1
|
|
|
|
err := ipfs.Pin(ctx, pin)
|
2019-08-09 14:45:54 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Error("pin update should have worked even if not pinned")
|
2019-07-12 14:40:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = ipfs.Pin(ctx, pin)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// This should trigger the pin/update path
|
|
|
|
pin.Cid = test.Cid2
|
|
|
|
err = ipfs.Pin(ctx, pin)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2019-08-09 14:45:54 +00:00
|
|
|
if mock.GetCount("pin/update") != 1 {
|
|
|
|
t.Error("pin/update should have been called once")
|
|
|
|
}
|
|
|
|
|
|
|
|
if mock.GetCount("pin/add") != 1 {
|
|
|
|
t.Error("pin/add should have been called once")
|
|
|
|
}
|
2018-03-08 10:35:29 +00:00
|
|
|
}
|
|
|
|
|
2016-12-15 13:07:19 +00:00
|
|
|
func TestIPFSUnpin(t *testing.T) {
|
2018-04-16 09:01:20 +00:00
|
|
|
ctx := context.Background()
|
2016-12-23 18:35:37 +00:00
|
|
|
ipfs, mock := testIPFSConnector(t)
|
2016-12-16 16:22:37 +00:00
|
|
|
defer mock.Close()
|
2018-06-27 04:03:15 +00:00
|
|
|
defer ipfs.Shutdown(ctx)
|
2019-02-27 20:19:10 +00:00
|
|
|
c := test.Cid1
|
2018-04-16 09:01:20 +00:00
|
|
|
err := ipfs.Unpin(ctx, c)
|
2016-12-08 16:24:38 +00:00
|
|
|
if err != nil {
|
2016-12-16 16:22:37 +00:00
|
|
|
t.Error("expected success unpinning non-pinned cid")
|
2016-12-08 16:24:38 +00:00
|
|
|
}
|
2019-07-12 14:40:29 +00:00
|
|
|
ipfs.Pin(ctx, api.PinCid(c))
|
2018-04-16 09:01:20 +00:00
|
|
|
err = ipfs.Unpin(ctx, c)
|
2016-12-08 16:24:38 +00:00
|
|
|
if err != nil {
|
2016-12-16 16:22:37 +00:00
|
|
|
t.Error("expected success unpinning pinned cid")
|
2016-12-08 16:24:38 +00:00
|
|
|
}
|
2016-12-08 18:04:28 +00:00
|
|
|
}
|
|
|
|
|
2019-07-09 00:24:33 +00:00
|
|
|
func TestIPFSUnpinDisabled(t *testing.T) {
|
|
|
|
ctx := context.Background()
|
|
|
|
ipfs, mock := testIPFSConnector(t)
|
|
|
|
defer mock.Close()
|
|
|
|
defer ipfs.Shutdown(ctx)
|
|
|
|
ipfs.config.UnpinDisable = true
|
2019-07-12 14:40:29 +00:00
|
|
|
err := ipfs.Pin(ctx, api.PinCid(test.Cid1))
|
2019-07-09 00:24:33 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = ipfs.Unpin(ctx, test.Cid1)
|
|
|
|
if err == nil {
|
|
|
|
t.Fatal("pin should be disabled")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-25 17:07:19 +00:00
|
|
|
func TestIPFSPinLsCid(t *testing.T) {
|
2018-04-16 09:01:20 +00:00
|
|
|
ctx := context.Background()
|
2016-12-23 18:35:37 +00:00
|
|
|
ipfs, mock := testIPFSConnector(t)
|
2016-12-16 16:22:37 +00:00
|
|
|
defer mock.Close()
|
2018-06-27 04:03:15 +00:00
|
|
|
defer ipfs.Shutdown(ctx)
|
2019-02-27 20:19:10 +00:00
|
|
|
c := test.Cid1
|
|
|
|
c2 := test.Cid2
|
2016-12-08 16:24:38 +00:00
|
|
|
|
2020-04-20 14:21:27 +00:00
|
|
|
pin := api.PinCid(c)
|
|
|
|
ipfs.Pin(ctx, pin)
|
|
|
|
ips, err := ipfs.PinLsCid(ctx, pin)
|
2019-06-07 17:02:27 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !ips.IsPinned(-1) {
|
2016-12-08 16:24:38 +00:00
|
|
|
t.Error("c should appear pinned")
|
|
|
|
}
|
|
|
|
|
2020-04-20 14:21:27 +00:00
|
|
|
ips, err = ipfs.PinLsCid(ctx, api.PinCid(c2))
|
2017-02-08 17:04:08 +00:00
|
|
|
if err != nil || ips != api.IPFSPinStatusUnpinned {
|
2016-12-08 16:24:38 +00:00
|
|
|
t.Error("c2 should appear unpinned")
|
|
|
|
}
|
2016-12-08 18:04:28 +00:00
|
|
|
}
|
|
|
|
|
2019-06-07 17:02:27 +00:00
|
|
|
func TestIPFSPinLsCid_DifferentEncoding(t *testing.T) {
|
|
|
|
ctx := context.Background()
|
|
|
|
ipfs, mock := testIPFSConnector(t)
|
|
|
|
defer mock.Close()
|
|
|
|
defer ipfs.Shutdown(ctx)
|
|
|
|
c := test.Cid4 // ipfs mock treats this specially
|
|
|
|
|
2020-04-20 14:21:27 +00:00
|
|
|
pin := api.PinCid(c)
|
|
|
|
ipfs.Pin(ctx, pin)
|
|
|
|
ips, err := ipfs.PinLsCid(ctx, pin)
|
2019-06-07 17:02:27 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !ips.IsPinned(-1) {
|
|
|
|
t.Error("c should appear pinned")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-22 09:56:16 +00:00
|
|
|
func collectPins(t *testing.T, pch <-chan api.IPFSPinInfo) []api.IPFSPinInfo {
|
|
|
|
t.Helper()
|
|
|
|
|
|
|
|
var pins []api.IPFSPinInfo
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
for {
|
|
|
|
select {
|
|
|
|
case <-ctx.Done():
|
|
|
|
t.Fatal(ctx.Err())
|
|
|
|
return nil
|
|
|
|
case p, ok := <-pch:
|
|
|
|
if !ok {
|
|
|
|
return pins
|
|
|
|
}
|
|
|
|
pins = append(pins, p)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-25 17:07:19 +00:00
|
|
|
func TestIPFSPinLs(t *testing.T) {
|
2018-04-16 09:01:20 +00:00
|
|
|
ctx := context.Background()
|
2017-01-25 17:07:19 +00:00
|
|
|
ipfs, mock := testIPFSConnector(t)
|
|
|
|
defer mock.Close()
|
2018-06-27 04:03:15 +00:00
|
|
|
defer ipfs.Shutdown(ctx)
|
2019-02-27 20:19:10 +00:00
|
|
|
c := test.Cid1
|
|
|
|
c2 := test.Cid2
|
2017-01-25 17:07:19 +00:00
|
|
|
|
2019-07-12 14:40:29 +00:00
|
|
|
ipfs.Pin(ctx, api.PinCid(c))
|
|
|
|
ipfs.Pin(ctx, api.PinCid(c2))
|
2022-03-22 09:56:16 +00:00
|
|
|
pinCh := make(chan api.IPFSPinInfo, 10)
|
|
|
|
go func() {
|
|
|
|
err := ipfs.PinLs(ctx, []string{""}, pinCh)
|
|
|
|
if err != nil {
|
|
|
|
t.Error("should not error")
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
pins := collectPins(t, pinCh)
|
|
|
|
|
|
|
|
if len(pins) != 2 {
|
|
|
|
t.Fatal("the pin list does not contain the expected number of keys")
|
2017-01-25 17:07:19 +00:00
|
|
|
}
|
|
|
|
|
2022-03-22 09:56:16 +00:00
|
|
|
if !pins[0].Type.IsPinned(-1) || !pins[1].Type.IsPinned(-1) {
|
2017-01-25 17:07:19 +00:00
|
|
|
t.Error("c1 and c2 should appear pinned")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-15 13:07:19 +00:00
|
|
|
func TestIPFSShutdown(t *testing.T) {
|
2018-06-27 04:03:15 +00:00
|
|
|
ctx := context.Background()
|
2016-12-23 18:35:37 +00:00
|
|
|
ipfs, mock := testIPFSConnector(t)
|
2016-12-16 16:22:37 +00:00
|
|
|
defer mock.Close()
|
2018-06-27 04:03:15 +00:00
|
|
|
if err := ipfs.Shutdown(ctx); err != nil {
|
2016-12-08 16:24:38 +00:00
|
|
|
t.Error("expected a clean shutdown")
|
|
|
|
}
|
2018-06-27 04:03:15 +00:00
|
|
|
if err := ipfs.Shutdown(ctx); err != nil {
|
2016-12-16 16:22:37 +00:00
|
|
|
t.Error("expected a second clean shutdown")
|
|
|
|
}
|
2016-12-08 16:24:38 +00:00
|
|
|
}
|
2017-03-16 14:51:24 +00:00
|
|
|
|
2017-03-23 18:34:33 +00:00
|
|
|
func TestConnectSwarms(t *testing.T) {
|
|
|
|
// In order to interactively test uncomment the following.
|
|
|
|
// Otherwise there is no good way to test this with the
|
|
|
|
// ipfs mock
|
|
|
|
// logging.SetDebugLogging()
|
|
|
|
|
2018-06-27 04:03:15 +00:00
|
|
|
ctx := context.Background()
|
2017-03-23 18:34:33 +00:00
|
|
|
ipfs, mock := testIPFSConnector(t)
|
|
|
|
defer mock.Close()
|
2018-06-27 04:03:15 +00:00
|
|
|
defer ipfs.Shutdown(ctx)
|
2017-03-23 18:34:33 +00:00
|
|
|
time.Sleep(time.Second)
|
|
|
|
}
|
|
|
|
|
2018-01-18 02:49:35 +00:00
|
|
|
func TestSwarmPeers(t *testing.T) {
|
2018-06-27 04:03:15 +00:00
|
|
|
ctx := context.Background()
|
2018-01-18 02:49:35 +00:00
|
|
|
ipfs, mock := testIPFSConnector(t)
|
|
|
|
defer mock.Close()
|
2018-06-27 04:03:15 +00:00
|
|
|
defer ipfs.Shutdown(ctx)
|
2018-01-18 02:49:35 +00:00
|
|
|
|
2018-06-27 04:03:15 +00:00
|
|
|
swarmPeers, err := ipfs.SwarmPeers(ctx)
|
2018-01-18 02:49:35 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if len(swarmPeers) != 2 {
|
|
|
|
t.Fatal("expected 2 swarm peers")
|
|
|
|
}
|
2019-02-27 20:19:10 +00:00
|
|
|
if swarmPeers[0] != test.PeerID4 {
|
2018-01-18 02:49:35 +00:00
|
|
|
t.Error("unexpected swarm peer")
|
|
|
|
}
|
2019-02-27 20:19:10 +00:00
|
|
|
if swarmPeers[1] != test.PeerID5 {
|
2018-01-18 02:49:35 +00:00
|
|
|
t.Error("unexpected swarm peer")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Adders: stream blocks to destinations
This commit fixes #810 and adds block streaming to the final destinations when
adding. This should add major performance gains when adding data to clusters.
Before, everytime cluster issued a block, it was broadcasted individually to
all destinations (new libp2p stream), where it was block/put to IPFS (a single
block/put http roundtrip per block).
Now, blocks are streamed all the way from the adder module to the ipfs daemon,
by making every block as it arrives a single part in a multipart block/put
request.
Before, block-broadcast needed to wait for all destinations to finish in order
to process the next block. Now, buffers allow some destinations to be faster
than others while sending and receiving blocks.
Before, if a block put request failed to be broadcasted everywhere, an error
would happen at that moment.
Now, we keep streaming until the end and only then report any errors. The
operation succeeds as long as at least one stream finished successfully.
Errors block/putting to IPFS will not abort streams. Instead, subsequent
blocks are retried with a new request, although the method will return an
error when the stream finishes if there were errors at any point.
2022-03-24 01:17:10 +00:00
|
|
|
func TestBlockStream(t *testing.T) {
|
2018-06-27 04:03:15 +00:00
|
|
|
ctx := context.Background()
|
2018-02-14 04:44:43 +00:00
|
|
|
ipfs, mock := testIPFSConnector(t)
|
|
|
|
defer mock.Close()
|
2018-06-27 04:03:15 +00:00
|
|
|
defer ipfs.Shutdown(ctx)
|
2018-02-14 04:44:43 +00:00
|
|
|
|
Adders: stream blocks to destinations
This commit fixes #810 and adds block streaming to the final destinations when
adding. This should add major performance gains when adding data to clusters.
Before, everytime cluster issued a block, it was broadcasted individually to
all destinations (new libp2p stream), where it was block/put to IPFS (a single
block/put http roundtrip per block).
Now, blocks are streamed all the way from the adder module to the ipfs daemon,
by making every block as it arrives a single part in a multipart block/put
request.
Before, block-broadcast needed to wait for all destinations to finish in order
to process the next block. Now, buffers allow some destinations to be faster
than others while sending and receiving blocks.
Before, if a block put request failed to be broadcasted everywhere, an error
would happen at that moment.
Now, we keep streaming until the end and only then report any errors. The
operation succeeds as long as at least one stream finished successfully.
Errors block/putting to IPFS will not abort streams. Instead, subsequent
blocks are retried with a new request, although the method will return an
error when the stream finishes if there were errors at any point.
2022-03-24 01:17:10 +00:00
|
|
|
blocks := make(chan api.NodeWithMeta, 10)
|
|
|
|
blocks <- api.NodeWithMeta{
|
2020-03-06 15:35:15 +00:00
|
|
|
Data: []byte(test.Cid4Data),
|
|
|
|
Cid: test.Cid4,
|
Adders: stream blocks to destinations
This commit fixes #810 and adds block streaming to the final destinations when
adding. This should add major performance gains when adding data to clusters.
Before, everytime cluster issued a block, it was broadcasted individually to
all destinations (new libp2p stream), where it was block/put to IPFS (a single
block/put http roundtrip per block).
Now, blocks are streamed all the way from the adder module to the ipfs daemon,
by making every block as it arrives a single part in a multipart block/put
request.
Before, block-broadcast needed to wait for all destinations to finish in order
to process the next block. Now, buffers allow some destinations to be faster
than others while sending and receiving blocks.
Before, if a block put request failed to be broadcasted everywhere, an error
would happen at that moment.
Now, we keep streaming until the end and only then report any errors. The
operation succeeds as long as at least one stream finished successfully.
Errors block/putting to IPFS will not abort streams. Instead, subsequent
blocks are retried with a new request, although the method will return an
error when the stream finishes if there were errors at any point.
2022-03-24 01:17:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Because this has a different prefix,
|
|
|
|
// it will produce a warning.
|
|
|
|
blocks <- api.NodeWithMeta{
|
|
|
|
Data: []byte(test.Cid5Data),
|
|
|
|
Cid: test.Cid5,
|
|
|
|
}
|
|
|
|
close(blocks)
|
|
|
|
|
|
|
|
err := ipfs.BlockStream(ctx, blocks)
|
2018-02-14 04:44:43 +00:00
|
|
|
if err != nil {
|
2020-05-17 00:39:02 +00:00
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
|
Adders: stream blocks to destinations
This commit fixes #810 and adds block streaming to the final destinations when
adding. This should add major performance gains when adding data to clusters.
Before, everytime cluster issued a block, it was broadcasted individually to
all destinations (new libp2p stream), where it was block/put to IPFS (a single
block/put http roundtrip per block).
Now, blocks are streamed all the way from the adder module to the ipfs daemon,
by making every block as it arrives a single part in a multipart block/put
request.
Before, block-broadcast needed to wait for all destinations to finish in order
to process the next block. Now, buffers allow some destinations to be faster
than others while sending and receiving blocks.
Before, if a block put request failed to be broadcasted everywhere, an error
would happen at that moment.
Now, we keep streaming until the end and only then report any errors. The
operation succeeds as long as at least one stream finished successfully.
Errors block/putting to IPFS will not abort streams. Instead, subsequent
blocks are retried with a new request, although the method will return an
error when the stream finishes if there were errors at any point.
2022-03-24 01:17:10 +00:00
|
|
|
// Try only adding v0 cid now
|
|
|
|
blocks2 := make(chan api.NodeWithMeta, 1)
|
|
|
|
blocks2 <- api.NodeWithMeta{
|
2020-05-17 00:39:02 +00:00
|
|
|
Data: []byte(test.Cid5Data),
|
|
|
|
Cid: test.Cid5,
|
Adders: stream blocks to destinations
This commit fixes #810 and adds block streaming to the final destinations when
adding. This should add major performance gains when adding data to clusters.
Before, everytime cluster issued a block, it was broadcasted individually to
all destinations (new libp2p stream), where it was block/put to IPFS (a single
block/put http roundtrip per block).
Now, blocks are streamed all the way from the adder module to the ipfs daemon,
by making every block as it arrives a single part in a multipart block/put
request.
Before, block-broadcast needed to wait for all destinations to finish in order
to process the next block. Now, buffers allow some destinations to be faster
than others while sending and receiving blocks.
Before, if a block put request failed to be broadcasted everywhere, an error
would happen at that moment.
Now, we keep streaming until the end and only then report any errors. The
operation succeeds as long as at least one stream finished successfully.
Errors block/putting to IPFS will not abort streams. Instead, subsequent
blocks are retried with a new request, although the method will return an
error when the stream finishes if there were errors at any point.
2022-03-24 01:17:10 +00:00
|
|
|
}
|
|
|
|
close(blocks2)
|
|
|
|
|
|
|
|
err = ipfs.BlockStream(ctx, blocks2)
|
2020-05-17 00:39:02 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
2018-02-14 04:44:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-18 19:29:02 +00:00
|
|
|
func TestBlockGet(t *testing.T) {
|
2018-06-27 04:03:15 +00:00
|
|
|
ctx := context.Background()
|
2018-03-18 19:29:02 +00:00
|
|
|
ipfs, mock := testIPFSConnector(t)
|
|
|
|
defer mock.Close()
|
2018-06-27 04:03:15 +00:00
|
|
|
defer ipfs.Shutdown(ctx)
|
2018-04-24 00:39:07 +00:00
|
|
|
|
2019-02-27 20:19:10 +00:00
|
|
|
shardCid := test.ShardCid
|
2018-04-24 00:39:07 +00:00
|
|
|
// Fail when getting before putting
|
2019-02-27 20:09:31 +00:00
|
|
|
_, err := ipfs.BlockGet(ctx, shardCid)
|
2018-04-24 00:39:07 +00:00
|
|
|
if err == nil {
|
|
|
|
t.Fatal("expected to fail getting unput block")
|
|
|
|
}
|
|
|
|
|
Adders: stream blocks to destinations
This commit fixes #810 and adds block streaming to the final destinations when
adding. This should add major performance gains when adding data to clusters.
Before, everytime cluster issued a block, it was broadcasted individually to
all destinations (new libp2p stream), where it was block/put to IPFS (a single
block/put http roundtrip per block).
Now, blocks are streamed all the way from the adder module to the ipfs daemon,
by making every block as it arrives a single part in a multipart block/put
request.
Before, block-broadcast needed to wait for all destinations to finish in order
to process the next block. Now, buffers allow some destinations to be faster
than others while sending and receiving blocks.
Before, if a block put request failed to be broadcasted everywhere, an error
would happen at that moment.
Now, we keep streaming until the end and only then report any errors. The
operation succeeds as long as at least one stream finished successfully.
Errors block/putting to IPFS will not abort streams. Instead, subsequent
blocks are retried with a new request, although the method will return an
error when the stream finishes if there were errors at any point.
2022-03-24 01:17:10 +00:00
|
|
|
blocks := make(chan api.NodeWithMeta, 1)
|
|
|
|
blocks <- api.NodeWithMeta{
|
2020-03-06 15:35:15 +00:00
|
|
|
Data: test.ShardData,
|
|
|
|
Cid: test.ShardCid,
|
Adders: stream blocks to destinations
This commit fixes #810 and adds block streaming to the final destinations when
adding. This should add major performance gains when adding data to clusters.
Before, everytime cluster issued a block, it was broadcasted individually to
all destinations (new libp2p stream), where it was block/put to IPFS (a single
block/put http roundtrip per block).
Now, blocks are streamed all the way from the adder module to the ipfs daemon,
by making every block as it arrives a single part in a multipart block/put
request.
Before, block-broadcast needed to wait for all destinations to finish in order
to process the next block. Now, buffers allow some destinations to be faster
than others while sending and receiving blocks.
Before, if a block put request failed to be broadcasted everywhere, an error
would happen at that moment.
Now, we keep streaming until the end and only then report any errors. The
operation succeeds as long as at least one stream finished successfully.
Errors block/putting to IPFS will not abort streams. Instead, subsequent
blocks are retried with a new request, although the method will return an
error when the stream finishes if there were errors at any point.
2022-03-24 01:17:10 +00:00
|
|
|
}
|
|
|
|
close(blocks)
|
|
|
|
err = ipfs.BlockStream(ctx, blocks)
|
2018-04-24 00:39:07 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2018-06-27 04:03:15 +00:00
|
|
|
data, err := ipfs.BlockGet(ctx, shardCid)
|
2018-04-24 00:39:07 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
2019-02-27 20:19:10 +00:00
|
|
|
if !bytes.Equal(data, test.ShardData) {
|
2018-03-18 19:29:02 +00:00
|
|
|
t.Fatal("unexpected data returned")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-20 18:43:27 +00:00
|
|
|
func TestRepoStat(t *testing.T) {
|
2018-04-16 09:01:20 +00:00
|
|
|
ctx := context.Background()
|
2017-03-27 13:07:12 +00:00
|
|
|
ipfs, mock := testIPFSConnector(t)
|
|
|
|
defer mock.Close()
|
2018-06-27 04:03:15 +00:00
|
|
|
defer ipfs.Shutdown(ctx)
|
2017-03-27 13:07:12 +00:00
|
|
|
|
2018-06-27 04:03:15 +00:00
|
|
|
s, err := ipfs.RepoStat(ctx)
|
2017-03-27 13:07:12 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
// See the ipfs mock implementation
|
2018-08-20 18:43:27 +00:00
|
|
|
if s.RepoSize != 0 {
|
2017-03-27 13:07:12 +00:00
|
|
|
t.Error("expected 0 bytes of size")
|
|
|
|
}
|
|
|
|
|
2019-02-27 20:19:10 +00:00
|
|
|
c := test.Cid1
|
2019-07-12 14:40:29 +00:00
|
|
|
err = ipfs.Pin(ctx, api.PinCid(c))
|
2017-03-27 13:07:12 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Error("expected success pinning cid")
|
|
|
|
}
|
|
|
|
|
2018-06-27 04:03:15 +00:00
|
|
|
s, err = ipfs.RepoStat(ctx)
|
2017-03-27 13:07:12 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2018-08-20 18:43:27 +00:00
|
|
|
if s.RepoSize != 1000 {
|
2017-03-27 13:07:12 +00:00
|
|
|
t.Error("expected 1000 bytes of size")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add PinPath/UnpinPath support.
Squashed commit of the following:
commit 38cf569c6aed77c46ee4e0f8baa4d1a9daf8f03e
Merge: d125f69 aaada42
Author: Hector Sanjuan <hsanjuan@users.noreply.github.com>
Date: Wed Feb 20 11:02:00 2019 +0000
Merge pull request #634 from ipfs/issue_450
Support PinPath, UnpinPath (resolve before pinning)
commit aaada42054e1f1c7b2abb1270859d0de41a0e5d8
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 19 22:16:25 2019 +0530
formatResponse accepts api.Pin and not api.PinSerial
commit b5da4bea045865814cc422da71827b44ddd44b90
Merge: ba59036 cc8dd7e
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 19 21:36:46 2019 +0530
Merge branch 'master' into issue_450
commit ba5903649c1df1dba20f4d6f7e3573d6fe24921f
Merge: f002914 d59880c
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Mon Feb 18 08:41:11 2019 +0530
Merge branch 'issue_450' of github.com:ipfs/ipfs-cluster into issue_450
commit f00291494c0c02621c2296cbb7ac71e4c23aa9ec
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Mon Feb 18 08:31:39 2019 +0530
PinPath: more improvements
Added tracing for new methods
commit d59880c338eaa8214fe06b4f930a540793d78407
Merge: 0ca4c7c b4f0eb3
Author: Hector Sanjuan <hsanjuan@users.noreply.github.com>
Date: Wed Feb 13 15:22:49 2019 +0000
Merge branch 'master' into issue_450
commit 0ca4c7c3b0670ed9c8279f8274d36e3485c10030
Merge: d35017a ecef9ea
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 12 13:10:13 2019 +0530
Merge branch 'master' into issue_450
commit d35017a8de91ca9fc9a9a047c48c75134cee9f98
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 12 13:07:25 2019 +0530
PinPath: more improvements
- Worth having `PinOptions` as a separate field in the struct and
constructing the query in the test with ToQuery()
- sharness: "intialization" line can be placed outside the tests at
the top
commit 68e3b90417ffbad89d41a70ac81d85f9037f8848
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Sun Feb 10 21:43:50 2019 +0530
Using if-continue pattern instead of if-else
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 3c29799f3b85be328b27508332ab92049d8b82f3
Merge: 956790b 4324889
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Thu Feb 7 10:25:52 2019 +0530
Merge branch 'master' into issue_450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 956790b381db9858e4194f983e898b07dc51ba66
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 21:11:20 2019 +0530
Removing resolved path
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 7191cc46cedfbec116a9746937e28881b50ca044
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 16:45:07 2019 +0530
Fix go vet
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit f8b3d5b63b1b7569e2a3e0d82894fd4491c246c4
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 16:07:03 2019 +0530
Fixed linting error
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 23c57eb467755a1f21387a1615a7f34e97348053
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 09:20:41 2019 +0530
Fixed tests
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 0caedd94aefeb3b6649dedc214cb4b849ace2ea4
Merge: 17e555e 5a7ee1d
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 00:07:10 2019 +0530
Merge branch 'master' into issue_450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 17e555e4a7c574413df90aac70c5cc29cab98f54
Author: Hector Sanjuan <code@hector.link>
Date: Tue Feb 5 16:58:50 2019 +0000
PinPath: address some feedback + improvements
* Changed client's Pin() API and PinPath to be consistent
* Added helper methods to turn PinPath to query and back
* Make code and tests build
* Use TestCidResolved everywhere
* Fix cluster.PinPath arguments
* Fix formatting of responses with --no-status
* Make tests readable and call Fatal when needed
* Use a pathTestCases variable
commit f0e7369c47c5ddadc8ed45df5fd2d4d9b2d42b38
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 5 18:34:26 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
Addressed review comments as in
https://github.com/ipfs/ipfs-cluster/pull/634#pullrequestreview-198751932
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit a8b4f181d2d7afed32ee41331dfaab19fd66a173
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 29 22:41:27 2019 +0530
Fixing tests
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit e39b95ca19e4d75506f4f492678245ef13936a44
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 29 14:52:53 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
- PinPath and UnpinPath should return api.Pin
- PinPath should accept pin options
- Removing duplicate logic for Resolve from cluster
- And many other review comments https://github.com/ipfs/ipfs-cluster/pull/634#pullrequestreview-195509504
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit d146075126320896665ba58d337a13789f68ea86
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 23 17:08:41 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
PinPath(in both rest and rpc) should return a serializable struct in the
form `{"\":"Q...cid..string..."}` (as used in "github.com/ipfs/go-cid"
to marshal and unmarshal)
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 1f4869568a8adb450275257154ea3a26d03a30f3
Merge: 7acfd28 a244af9
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 23 07:18:56 2019 +0530
Merge branch 'master' into issue_450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 7acfd282732ddf2282a67d4f9d0170a494eb3ed4
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 22 18:14:32 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
- RPC must always use serializable structs
- In command, just use pin with path as cid is also a valid path
- Addressing many other small review comments as in
https://github.com/ipfs/ipfs-cluster/pull/634#pullrequestreview-192122534
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 36905041e1e3f0b204942030aab3ab7b5b9e4d62
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 16 09:36:42 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
Extra logic for path checking should go into resolve so that it can be
properly reused
Added sharness tests
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 9116bda3534e77bb391d873051bb520a1b01a326
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 16 08:08:07 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
error strings should not be capitalized
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit ca7e61861374f456300a85ddc0374e594f74f963
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 15 23:40:25 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
Tests
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 522fbcd899f01c01680375561a32a87464157c0a
Merge: f1a56ab f7bc468
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 15 10:40:54 2019 +0530
Merge branch 'master' into issue_450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit f1a56ab925fb74c0c44273a4524afa4843cf757f
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Mon Jan 14 20:58:17 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
- IPFS Connector should act as a pure IPFS client, any extra logic
should go to cluster.go
- Use cid.Undef, instead of cid.Cid{}
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit c83b91054f6774f1f9d4930cfc3f1fa28236f57c
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Thu Jan 10 08:57:17 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
- Separate handlers, methods and rpc apis for PinPath and UnpinPath from
Pin and Unpin
- Support ipld paths as well
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 719dff88129366ce3ccb5e04cb6f8082a0915c5c
Merge: 91ceb47 21170c4
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 9 19:38:35 2019 +0530
Merge branch 'issue_450_old' into HEAD
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 91ceb4796259ca7ef2974ec43e6a278a12796b13
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 9 19:36:41 2019 +0530
Revert "WIP: Figure out why test does not impleme"
This reverts commit 28a3a3f25dce6f296c8cbef86221644c099a7e75.
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 28a3a3f25dce6f296c8cbef86221644c099a7e75
Author: cd10012 <ced361@nyu.edu>
Date: Tue Jul 24 23:23:10 2018 -0400
WIP: Figure out why test does not implement IPFSConnector interface...
License: MIT
Signed-off-by: cd10012 <ced361@nyu.edu>
commit 21170c48e77e69583db64544b08120a9baf40d8d
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 8 10:37:59 2019 +0530
Support PinPath, UnpinPath (resolve before pinning)
This commit adds API support for pinning using path
`POST /pins/<ipfs or ipns path>` and `DELETE /pins/<ipfs or ipns path>`
will resolve the path into a cid and perform perform pinning or
unpinning
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Co-authored-by: Hector Sanjuan <hector@protocol.ai>
License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
2019-02-20 11:07:50 +00:00
|
|
|
func TestResolve(t *testing.T) {
|
|
|
|
ctx := context.Background()
|
|
|
|
ipfs, mock := testIPFSConnector(t)
|
|
|
|
defer mock.Close()
|
|
|
|
defer ipfs.Shutdown(ctx)
|
|
|
|
|
2019-02-27 20:19:10 +00:00
|
|
|
s, err := ipfs.Resolve(ctx, test.PathIPFS2)
|
Add PinPath/UnpinPath support.
Squashed commit of the following:
commit 38cf569c6aed77c46ee4e0f8baa4d1a9daf8f03e
Merge: d125f69 aaada42
Author: Hector Sanjuan <hsanjuan@users.noreply.github.com>
Date: Wed Feb 20 11:02:00 2019 +0000
Merge pull request #634 from ipfs/issue_450
Support PinPath, UnpinPath (resolve before pinning)
commit aaada42054e1f1c7b2abb1270859d0de41a0e5d8
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 19 22:16:25 2019 +0530
formatResponse accepts api.Pin and not api.PinSerial
commit b5da4bea045865814cc422da71827b44ddd44b90
Merge: ba59036 cc8dd7e
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 19 21:36:46 2019 +0530
Merge branch 'master' into issue_450
commit ba5903649c1df1dba20f4d6f7e3573d6fe24921f
Merge: f002914 d59880c
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Mon Feb 18 08:41:11 2019 +0530
Merge branch 'issue_450' of github.com:ipfs/ipfs-cluster into issue_450
commit f00291494c0c02621c2296cbb7ac71e4c23aa9ec
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Mon Feb 18 08:31:39 2019 +0530
PinPath: more improvements
Added tracing for new methods
commit d59880c338eaa8214fe06b4f930a540793d78407
Merge: 0ca4c7c b4f0eb3
Author: Hector Sanjuan <hsanjuan@users.noreply.github.com>
Date: Wed Feb 13 15:22:49 2019 +0000
Merge branch 'master' into issue_450
commit 0ca4c7c3b0670ed9c8279f8274d36e3485c10030
Merge: d35017a ecef9ea
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 12 13:10:13 2019 +0530
Merge branch 'master' into issue_450
commit d35017a8de91ca9fc9a9a047c48c75134cee9f98
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 12 13:07:25 2019 +0530
PinPath: more improvements
- Worth having `PinOptions` as a separate field in the struct and
constructing the query in the test with ToQuery()
- sharness: "intialization" line can be placed outside the tests at
the top
commit 68e3b90417ffbad89d41a70ac81d85f9037f8848
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Sun Feb 10 21:43:50 2019 +0530
Using if-continue pattern instead of if-else
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 3c29799f3b85be328b27508332ab92049d8b82f3
Merge: 956790b 4324889
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Thu Feb 7 10:25:52 2019 +0530
Merge branch 'master' into issue_450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 956790b381db9858e4194f983e898b07dc51ba66
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 21:11:20 2019 +0530
Removing resolved path
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 7191cc46cedfbec116a9746937e28881b50ca044
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 16:45:07 2019 +0530
Fix go vet
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit f8b3d5b63b1b7569e2a3e0d82894fd4491c246c4
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 16:07:03 2019 +0530
Fixed linting error
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 23c57eb467755a1f21387a1615a7f34e97348053
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 09:20:41 2019 +0530
Fixed tests
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 0caedd94aefeb3b6649dedc214cb4b849ace2ea4
Merge: 17e555e 5a7ee1d
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 00:07:10 2019 +0530
Merge branch 'master' into issue_450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 17e555e4a7c574413df90aac70c5cc29cab98f54
Author: Hector Sanjuan <code@hector.link>
Date: Tue Feb 5 16:58:50 2019 +0000
PinPath: address some feedback + improvements
* Changed client's Pin() API and PinPath to be consistent
* Added helper methods to turn PinPath to query and back
* Make code and tests build
* Use TestCidResolved everywhere
* Fix cluster.PinPath arguments
* Fix formatting of responses with --no-status
* Make tests readable and call Fatal when needed
* Use a pathTestCases variable
commit f0e7369c47c5ddadc8ed45df5fd2d4d9b2d42b38
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 5 18:34:26 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
Addressed review comments as in
https://github.com/ipfs/ipfs-cluster/pull/634#pullrequestreview-198751932
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit a8b4f181d2d7afed32ee41331dfaab19fd66a173
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 29 22:41:27 2019 +0530
Fixing tests
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit e39b95ca19e4d75506f4f492678245ef13936a44
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 29 14:52:53 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
- PinPath and UnpinPath should return api.Pin
- PinPath should accept pin options
- Removing duplicate logic for Resolve from cluster
- And many other review comments https://github.com/ipfs/ipfs-cluster/pull/634#pullrequestreview-195509504
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit d146075126320896665ba58d337a13789f68ea86
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 23 17:08:41 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
PinPath(in both rest and rpc) should return a serializable struct in the
form `{"\":"Q...cid..string..."}` (as used in "github.com/ipfs/go-cid"
to marshal and unmarshal)
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 1f4869568a8adb450275257154ea3a26d03a30f3
Merge: 7acfd28 a244af9
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 23 07:18:56 2019 +0530
Merge branch 'master' into issue_450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 7acfd282732ddf2282a67d4f9d0170a494eb3ed4
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 22 18:14:32 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
- RPC must always use serializable structs
- In command, just use pin with path as cid is also a valid path
- Addressing many other small review comments as in
https://github.com/ipfs/ipfs-cluster/pull/634#pullrequestreview-192122534
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 36905041e1e3f0b204942030aab3ab7b5b9e4d62
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 16 09:36:42 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
Extra logic for path checking should go into resolve so that it can be
properly reused
Added sharness tests
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 9116bda3534e77bb391d873051bb520a1b01a326
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 16 08:08:07 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
error strings should not be capitalized
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit ca7e61861374f456300a85ddc0374e594f74f963
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 15 23:40:25 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
Tests
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 522fbcd899f01c01680375561a32a87464157c0a
Merge: f1a56ab f7bc468
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 15 10:40:54 2019 +0530
Merge branch 'master' into issue_450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit f1a56ab925fb74c0c44273a4524afa4843cf757f
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Mon Jan 14 20:58:17 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
- IPFS Connector should act as a pure IPFS client, any extra logic
should go to cluster.go
- Use cid.Undef, instead of cid.Cid{}
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit c83b91054f6774f1f9d4930cfc3f1fa28236f57c
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Thu Jan 10 08:57:17 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
- Separate handlers, methods and rpc apis for PinPath and UnpinPath from
Pin and Unpin
- Support ipld paths as well
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 719dff88129366ce3ccb5e04cb6f8082a0915c5c
Merge: 91ceb47 21170c4
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 9 19:38:35 2019 +0530
Merge branch 'issue_450_old' into HEAD
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 91ceb4796259ca7ef2974ec43e6a278a12796b13
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 9 19:36:41 2019 +0530
Revert "WIP: Figure out why test does not impleme"
This reverts commit 28a3a3f25dce6f296c8cbef86221644c099a7e75.
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 28a3a3f25dce6f296c8cbef86221644c099a7e75
Author: cd10012 <ced361@nyu.edu>
Date: Tue Jul 24 23:23:10 2018 -0400
WIP: Figure out why test does not implement IPFSConnector interface...
License: MIT
Signed-off-by: cd10012 <ced361@nyu.edu>
commit 21170c48e77e69583db64544b08120a9baf40d8d
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 8 10:37:59 2019 +0530
Support PinPath, UnpinPath (resolve before pinning)
This commit adds API support for pinning using path
`POST /pins/<ipfs or ipns path>` and `DELETE /pins/<ipfs or ipns path>`
will resolve the path into a cid and perform perform pinning or
unpinning
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Co-authored-by: Hector Sanjuan <hector@protocol.ai>
License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
2019-02-20 11:07:50 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
2019-02-27 20:19:10 +00:00
|
|
|
if !s.Equals(test.CidResolved) {
|
|
|
|
t.Errorf("expected different cid, expected: %s, found: %s\n", test.CidResolved, s.String())
|
Add PinPath/UnpinPath support.
Squashed commit of the following:
commit 38cf569c6aed77c46ee4e0f8baa4d1a9daf8f03e
Merge: d125f69 aaada42
Author: Hector Sanjuan <hsanjuan@users.noreply.github.com>
Date: Wed Feb 20 11:02:00 2019 +0000
Merge pull request #634 from ipfs/issue_450
Support PinPath, UnpinPath (resolve before pinning)
commit aaada42054e1f1c7b2abb1270859d0de41a0e5d8
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 19 22:16:25 2019 +0530
formatResponse accepts api.Pin and not api.PinSerial
commit b5da4bea045865814cc422da71827b44ddd44b90
Merge: ba59036 cc8dd7e
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 19 21:36:46 2019 +0530
Merge branch 'master' into issue_450
commit ba5903649c1df1dba20f4d6f7e3573d6fe24921f
Merge: f002914 d59880c
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Mon Feb 18 08:41:11 2019 +0530
Merge branch 'issue_450' of github.com:ipfs/ipfs-cluster into issue_450
commit f00291494c0c02621c2296cbb7ac71e4c23aa9ec
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Mon Feb 18 08:31:39 2019 +0530
PinPath: more improvements
Added tracing for new methods
commit d59880c338eaa8214fe06b4f930a540793d78407
Merge: 0ca4c7c b4f0eb3
Author: Hector Sanjuan <hsanjuan@users.noreply.github.com>
Date: Wed Feb 13 15:22:49 2019 +0000
Merge branch 'master' into issue_450
commit 0ca4c7c3b0670ed9c8279f8274d36e3485c10030
Merge: d35017a ecef9ea
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 12 13:10:13 2019 +0530
Merge branch 'master' into issue_450
commit d35017a8de91ca9fc9a9a047c48c75134cee9f98
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 12 13:07:25 2019 +0530
PinPath: more improvements
- Worth having `PinOptions` as a separate field in the struct and
constructing the query in the test with ToQuery()
- sharness: "intialization" line can be placed outside the tests at
the top
commit 68e3b90417ffbad89d41a70ac81d85f9037f8848
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Sun Feb 10 21:43:50 2019 +0530
Using if-continue pattern instead of if-else
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 3c29799f3b85be328b27508332ab92049d8b82f3
Merge: 956790b 4324889
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Thu Feb 7 10:25:52 2019 +0530
Merge branch 'master' into issue_450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 956790b381db9858e4194f983e898b07dc51ba66
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 21:11:20 2019 +0530
Removing resolved path
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 7191cc46cedfbec116a9746937e28881b50ca044
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 16:45:07 2019 +0530
Fix go vet
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit f8b3d5b63b1b7569e2a3e0d82894fd4491c246c4
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 16:07:03 2019 +0530
Fixed linting error
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 23c57eb467755a1f21387a1615a7f34e97348053
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 09:20:41 2019 +0530
Fixed tests
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 0caedd94aefeb3b6649dedc214cb4b849ace2ea4
Merge: 17e555e 5a7ee1d
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Feb 6 00:07:10 2019 +0530
Merge branch 'master' into issue_450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 17e555e4a7c574413df90aac70c5cc29cab98f54
Author: Hector Sanjuan <code@hector.link>
Date: Tue Feb 5 16:58:50 2019 +0000
PinPath: address some feedback + improvements
* Changed client's Pin() API and PinPath to be consistent
* Added helper methods to turn PinPath to query and back
* Make code and tests build
* Use TestCidResolved everywhere
* Fix cluster.PinPath arguments
* Fix formatting of responses with --no-status
* Make tests readable and call Fatal when needed
* Use a pathTestCases variable
commit f0e7369c47c5ddadc8ed45df5fd2d4d9b2d42b38
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Feb 5 18:34:26 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
Addressed review comments as in
https://github.com/ipfs/ipfs-cluster/pull/634#pullrequestreview-198751932
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit a8b4f181d2d7afed32ee41331dfaab19fd66a173
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 29 22:41:27 2019 +0530
Fixing tests
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit e39b95ca19e4d75506f4f492678245ef13936a44
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 29 14:52:53 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
- PinPath and UnpinPath should return api.Pin
- PinPath should accept pin options
- Removing duplicate logic for Resolve from cluster
- And many other review comments https://github.com/ipfs/ipfs-cluster/pull/634#pullrequestreview-195509504
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit d146075126320896665ba58d337a13789f68ea86
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 23 17:08:41 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
PinPath(in both rest and rpc) should return a serializable struct in the
form `{"\":"Q...cid..string..."}` (as used in "github.com/ipfs/go-cid"
to marshal and unmarshal)
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 1f4869568a8adb450275257154ea3a26d03a30f3
Merge: 7acfd28 a244af9
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 23 07:18:56 2019 +0530
Merge branch 'master' into issue_450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 7acfd282732ddf2282a67d4f9d0170a494eb3ed4
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 22 18:14:32 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
- RPC must always use serializable structs
- In command, just use pin with path as cid is also a valid path
- Addressing many other small review comments as in
https://github.com/ipfs/ipfs-cluster/pull/634#pullrequestreview-192122534
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 36905041e1e3f0b204942030aab3ab7b5b9e4d62
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 16 09:36:42 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
Extra logic for path checking should go into resolve so that it can be
properly reused
Added sharness tests
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 9116bda3534e77bb391d873051bb520a1b01a326
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 16 08:08:07 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
error strings should not be capitalized
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit ca7e61861374f456300a85ddc0374e594f74f963
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 15 23:40:25 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
Tests
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 522fbcd899f01c01680375561a32a87464157c0a
Merge: f1a56ab f7bc468
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 15 10:40:54 2019 +0530
Merge branch 'master' into issue_450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit f1a56ab925fb74c0c44273a4524afa4843cf757f
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Mon Jan 14 20:58:17 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
- IPFS Connector should act as a pure IPFS client, any extra logic
should go to cluster.go
- Use cid.Undef, instead of cid.Cid{}
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit c83b91054f6774f1f9d4930cfc3f1fa28236f57c
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Thu Jan 10 08:57:17 2019 +0530
Support PinPath, UnpinPath(resolve before pinning)
- Separate handlers, methods and rpc apis for PinPath and UnpinPath from
Pin and Unpin
- Support ipld paths as well
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 719dff88129366ce3ccb5e04cb6f8082a0915c5c
Merge: 91ceb47 21170c4
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 9 19:38:35 2019 +0530
Merge branch 'issue_450_old' into HEAD
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 91ceb4796259ca7ef2974ec43e6a278a12796b13
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Wed Jan 9 19:36:41 2019 +0530
Revert "WIP: Figure out why test does not impleme"
This reverts commit 28a3a3f25dce6f296c8cbef86221644c099a7e75.
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
commit 28a3a3f25dce6f296c8cbef86221644c099a7e75
Author: cd10012 <ced361@nyu.edu>
Date: Tue Jul 24 23:23:10 2018 -0400
WIP: Figure out why test does not implement IPFSConnector interface...
License: MIT
Signed-off-by: cd10012 <ced361@nyu.edu>
commit 21170c48e77e69583db64544b08120a9baf40d8d
Author: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Date: Tue Jan 8 10:37:59 2019 +0530
Support PinPath, UnpinPath (resolve before pinning)
This commit adds API support for pinning using path
`POST /pins/<ipfs or ipns path>` and `DELETE /pins/<ipfs or ipns path>`
will resolve the path into a cid and perform perform pinning or
unpinning
Fixes #450
License: MIT
Signed-off-by: Kishan Mohanbhai Sagathiya <kishansagathiya@gmail.com>
Co-authored-by: Hector Sanjuan <hector@protocol.ai>
License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
2019-02-20 11:07:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-27 13:07:12 +00:00
|
|
|
func TestConfigKey(t *testing.T) {
|
2018-06-27 04:03:15 +00:00
|
|
|
ctx := context.Background()
|
2017-03-27 13:07:12 +00:00
|
|
|
ipfs, mock := testIPFSConnector(t)
|
|
|
|
defer mock.Close()
|
2018-06-27 04:03:15 +00:00
|
|
|
defer ipfs.Shutdown(ctx)
|
2017-03-27 13:07:12 +00:00
|
|
|
|
|
|
|
v, err := ipfs.ConfigKey("Datastore/StorageMax")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
sto, ok := v.(string)
|
|
|
|
if !ok {
|
|
|
|
t.Fatal("error converting to string")
|
|
|
|
}
|
|
|
|
if sto != "10G" {
|
|
|
|
t.Error("StorageMax shouold be 10G")
|
|
|
|
}
|
|
|
|
|
|
|
|
v, err = ipfs.ConfigKey("Datastore")
|
2020-04-14 17:58:00 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2017-03-27 13:07:12 +00:00
|
|
|
_, ok = v.(map[string]interface{})
|
|
|
|
if !ok {
|
|
|
|
t.Error("should have returned the whole Datastore config object")
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = ipfs.ConfigKey("")
|
|
|
|
if err == nil {
|
|
|
|
t.Error("should not work with an empty path")
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = ipfs.ConfigKey("Datastore/abc")
|
|
|
|
if err == nil {
|
|
|
|
t.Error("should not work with a bad path")
|
|
|
|
}
|
|
|
|
}
|
2019-10-22 05:40:32 +00:00
|
|
|
|
|
|
|
func TestRepoGC(t *testing.T) {
|
|
|
|
ctx := context.Background()
|
|
|
|
ipfs, mock := testIPFSConnector(t)
|
|
|
|
defer mock.Close()
|
|
|
|
defer ipfs.Shutdown(ctx)
|
|
|
|
|
|
|
|
res, err := ipfs.RepoGC(ctx)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if res.Error != "" {
|
|
|
|
t.Errorf("expected error to be empty: %s", res.Error)
|
|
|
|
}
|
|
|
|
|
|
|
|
if res.Keys == nil {
|
|
|
|
t.Fatal("expected a non-nil array of IPFSRepoGC")
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(res.Keys) < 5 {
|
|
|
|
t.Fatal("expected at least five keys")
|
|
|
|
}
|
|
|
|
|
|
|
|
if !res.Keys[0].Key.Equals(test.Cid1) {
|
|
|
|
t.Errorf("expected different cid, expected: %s, found: %s\n", test.Cid1, res.Keys[0].Key)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !res.Keys[3].Key.Equals(test.Cid4) {
|
|
|
|
t.Errorf("expected different cid, expected: %s, found: %s\n", test.Cid4, res.Keys[3].Key)
|
|
|
|
}
|
|
|
|
|
|
|
|
if res.Keys[4].Error != merkledag.ErrLinkNotFound.Error() {
|
|
|
|
t.Errorf("expected different error, expected: %s, found: %s\n", merkledag.ErrLinkNotFound, res.Keys[4].Error)
|
|
|
|
}
|
|
|
|
}
|