7159: Fix error handling when reading full size block. refs #7159
[arvados.git] / services / keepstore / azure_blob_volume_test.go
index 74c94ec79a49152c971f25b7c77ad17e6eb6adc7..a4c6e62a7d5f6f02c938ae27872cb96bb6a8e3e6 100644 (file)
@@ -1,6 +1,7 @@
 package main
 
 import (
+       "bytes"
        "encoding/base64"
        "encoding/xml"
        "flag"
@@ -338,6 +339,8 @@ func TestAzureBlobVolumeWithGeneric(t *testing.T) {
        http.DefaultTransport = &http.Transport{
                Dial: (&azStubDialer{}).Dial,
        }
+       azureWriteRaceInterval = time.Millisecond
+       azureWriteRacePollTime = time.Nanosecond
        DoGenericVolumeTests(t, func(t *testing.T) TestableVolume {
                return NewTestableAzureBlobVolume(t, false, azureStorageReplication)
        })
@@ -350,6 +353,8 @@ func TestReadonlyAzureBlobVolumeWithGeneric(t *testing.T) {
        http.DefaultTransport = &http.Transport{
                Dial: (&azStubDialer{}).Dial,
        }
+       azureWriteRaceInterval = time.Millisecond
+       azureWriteRacePollTime = time.Nanosecond
        DoGenericVolumeTests(t, func(t *testing.T) TestableVolume {
                return NewTestableAzureBlobVolume(t, true, azureStorageReplication)
        })
@@ -423,6 +428,13 @@ func TestAzureBlobVolumeCreateBlobRaceDeadline(t *testing.T) {
        azureWriteRacePollTime = 5 * time.Millisecond
 
        v.PutRaw(TestHash, []byte{})
+
+       buf := new(bytes.Buffer)
+       v.IndexTo("", buf)
+       if buf.Len() != 0 {
+               t.Errorf("Index %+q should be empty", buf.Bytes())
+       }
+
        v.TouchWithDate(TestHash, time.Now().Add(-1982 * time.Millisecond))
 
        allDone := make(chan struct{})
@@ -443,6 +455,12 @@ func TestAzureBlobVolumeCreateBlobRaceDeadline(t *testing.T) {
        case <-time.After(time.Second):
                t.Error("Get should have stopped waiting for race when block was 2s old")
        }
+
+       buf.Reset()
+       v.IndexTo("", buf)
+       if !bytes.HasPrefix(buf.Bytes(), []byte(TestHash+"+0")) {
+               t.Errorf("Index %+q should have %+q", buf.Bytes(), TestHash+"+0")
+       }
 }
 
 func (v *TestableAzureBlobVolume) PutRaw(locator string, data []byte) {