etcd2.3.2 - sinherle/Recipes GitHub Wiki

Building etcd

etcd v2.3.2 has been successfully built and tested for Linux on z Systems. The following instructions can be used for RHEL 7.1 , SLES 12 and UBUNTU 16.04.

General Notes: i) When following the steps below please use a standard permission user unless otherwise specified.

ii) A directory /<source_root>/ will be referred to in these instructions, this is a temporary writeable directory anywhere you'd like to place it.

Prerequisites (for RHEL 7.1 and SLES 12)

  • Go -- Instructions for building Go can be found here.

Building etcd

  1. Install the build dependencies

    For UBUNTU 16.04

    sudo apt-get update
    sudo apt-get install wget golang curl
    

    For RHEL7

    sudo yum install curl wget tar 
    

    For SLES12

    sudo zypper install curl wget tar 
    
    
  2. Get etcd v2.3.2 source code from github

    cd /<source_root>/
    $ wget https://github.com/coreos/etcd/archive/v2.3.2.tar.gz
    
  3. Untar and cd to the work directory

    $ tar zxvf v2.3.2.tar.gz
    
  4. Check go version

    $ go version
    
  5. Build etcd

    cd /<source_root>/etcd-2.3.2
    $ ./build
    
  6. Environment Configuration

    Do the following environment configuration otherwise running the etcd service cluster ./bin/etcd will break with error "etcdmain: etcd on unsupported platform without ETCD_UNSUPPORTED_ARCH=s390x set"

    export ETCD_UNSUPPORTED_ARCH=s390x
    
  7. Running Testcases

    i) You will need to change file to /<source_root>/etcd-2.3.2/test,which allows not use the go test option -race, which is not supported in z system, otherwise the test will end with error “go test: -race and -msan are only supported on linux/amd64, freebsd/amd64,windows”

    Update code section in file /<source_root>/etcd-2.3.2/test to

    MACHINE_TYPE=$(uname -m)
    

if [ $MACHINE_TYPE != "armv7l" ];[ $MACHINE_TYPE != "s390x" ];then RACE="--race" fi

```

 instead of 
 
 ```shell
MACHINE_TYPE=$(uname -m)

if [ $MACHINE_TYPE != "armv7l" ];then RACE="--race" fi

 ```
ii) Running test cases for etcd
```
cd /<source_root>/etcd-2.3.2
$ ./test
```
_**Note:**_

i) Testcase failures are intermittent and are expected to pass on multiple run.

ii) If wait_time_test.go is observed failing with error cannot receive from ch as expected , try to increase the timeout as follow

Update testcase TestWaitTime in file  `./pkg/wait/wait_time_test.go` to
```

func TestWaitTime(t *testing.T) { wt := NewTimeList() ch1 := wt.Wait(time.Now()) t1 := time.Now() wt.Trigger(t1) select { case <-ch1: case <-time.After(100 * time.Millisecond): t.Fatalf("cannot receive from ch as expected") }

    ch2 := wt.Wait(time.Now())
    t2 := time.Now()
    wt.Trigger(t1)
    select {
    case <-ch2:
            t.Fatalf("unexpected to receive from ch")
    case <-time.After(10 * time.Millisecond):
    }
    wt.Trigger(t2)
    select {
    case <-ch2:
    case <-time.After(100 * time.Millisecond):
            t.Fatalf("cannot receive from ch as expected")
    }

} ``` instead of

func TestWaitTime(t *testing.T) {
      wt := NewTimeList()
      ch1 := wt.Wait(time.Now())
      t1 := time.Now()
      wt.Trigger(t1)
      select {
      case <-ch1:
      case <-time.After(100 * time.Millisecond):
              t.Fatalf("cannot receive from ch as expected")
      }

      ch2 := wt.Wait(time.Now())
      t2 := time.Now()
      wt.Trigger(t1)
      select {
      case <-ch2:
              t.Fatalf("unexpected to receive from ch")
      case <-time.After(10 * time.Millisecond):
      }
      wt.Trigger(t2)
      select {
      case <-ch2:
      case <-time.After(10 * time.Millisecond):
              t.Fatalf("cannot receive from ch as expected")
      }
}

If the testcase is still failing try to increase the value from 100 to higher value(200,300,500).

iii) If fileutil test case is observed failing due to TestPurgeFileHoldingLock or TestPurgeFile error , try to increase the timeout as follow

Update testcase purge_test.go in file  `./pkg/fileutil/purge_test.go` in function `TestPurgeFile` and ` TestPurgeFileHoldingLock` at line no 52, 67, 116 and 147 to 

```
time.Sleep(5000 * time.Millisecond)
```

instead of

  time.Sleep(10 * time.Millisecond)	

If the testcase is still failing try to increase the value even higher. 8. Test etcd

First start a single-member cluster of etcd:

```
cd /<source_root>/etcd-2.3.2
$ ./bin/etcd
```

This will bring up etcd listening on port 2379 for client communication and on port 2380 for server-to-server communication.

Next, let's set a single key, and then retrieve it:

```
$ curl -L http://127.0.0.1:2379/v2/keys/mykey -XPUT -d value="this is awesome"
$ curl -L http://127.0.0.1:2379/v2/keys/mykey
```

You have successfully started an etcd and written a key to the store.  

References:

https://coreos.com/etcd/